db

package
v0.0.0-...-c9cba37 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2018 License: Unlicense Imports: 11 Imported by: 0

Documentation

Overview

Package db is the collection of types required to run a wallet service and store the data securely on disk in a Badger database.

Index

Constants

View Source
const (
	// DefaultBaseDir is the default name for the configuration directory if none other is specified
	DefaultBaseDir = ".duo"
	// DefaultValueDir is the default subfolder for the value log
	DefaultValueDir = "values"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	Path     string
	BaseDir  string
	ValueDir string
	Options  *badger.Options
	DB       *badger.DB
	BC       *bc.BlockCrypt
	core.State
}

DB is the central data repository for the wallet database

func NewWalletDB

func NewWalletDB(params ...string) (db *DB)

NewWalletDB creates a new walletDB. Path, BaseDir, ValueDir the order of how the variadic options will be processed to override thte defaults

func (*DB) Close

func (r *DB) Close()

Close shuts down a wallet database

func (*DB) Decrypt

func (r *DB) Decrypt(in *buf.Byte) (out *buf.Secure)

Decrypt transparently uses a BlockCrypt if available to deecrypt the data before it is returned to the caller, or it writes plaintext

func (*DB) DeleteAll

func (r *DB) DeleteAll() *DB

DeleteAll basically empties the database. For testing purposes.

func (*DB) Dump

func (r *DB) Dump()

Dump is a debugging function that outputs all the key pairs in the database to the stdout

func (*DB) Encrypt

func (r *DB) Encrypt(in *buf.Secure) (out *buf.Byte)

Encrypt transparently uses a BlockCrypt if available to encrypt the data before it is written to the database, or it writes plaintext

func (*DB) EraseAccount

func (r *DB) EraseAccount(address *[]byte) *DB

EraseAccount deletes an account from the wallet database

func (*DB) EraseAccountingEntry

func (r *DB) EraseAccountingEntry()

EraseAccountingEntry writes an accounting entry based on a transaction

func (*DB) EraseAllMasterKeys

func (r *DB) EraseAllMasterKeys() *DB

EraseAllMasterKeys deletes all of the masterkeys

func (*DB) EraseKey

func (r *DB) EraseKey(address *[]byte) *DB

EraseKey deletes a key entry

func (*DB) EraseMasterKey

func (r *DB) EraseMasterKey(idx *[]byte) *DB

EraseMasterKey deletes a masterkey entry from the database

func (*DB) EraseName

func (r *DB) EraseName(address *[]byte) *DB

EraseName removes a name entry from the database

func (*DB) ErasePool

func (r *DB) ErasePool(pool *rec.Pool) *DB

ErasePool removes a pool key

func (*DB) EraseScript

func (r *DB) EraseScript()

EraseScript deletes a script entry from the database

func (*DB) EraseTx

func (r *DB) EraseTx()

EraseTx deletes a transaction entry from the database

func (*DB) GetAccountCreditDebit

func (r *DB) GetAccountCreditDebit()

GetAccountCreditDebit finds entries in the credit/debit records written related to each input transaction from a list of indexes of accounts of interest

func (*DB) GetAllAccountIDs

func (r *DB) GetAllAccountIDs() (out []rec.Idx)

GetAllAccountIDs returns an array containing all of the accounts in the database by their index

func (*DB) LoadWallet

func (r *DB) LoadWallet()

LoadWallet opens a wallet ready to use

func (*DB) NewIf

func (r *DB) NewIf() *DB

NewIf creates a new WalletDB

func (*DB) ReadAccount

func (r *DB) ReadAccount(address *[]byte) (out *rec.Account)

ReadAccount finds an account stored due to being a correspondent account

func (*DB) ReadAccountingEntry

func (r *DB) ReadAccountingEntry()

ReadAccountingEntry writes an accounting entry based on a transaction

func (*DB) ReadBestBlock

func (r *DB) ReadBestBlock()

ReadBestBlock gets the current best block entry

func (*DB) ReadDefaultKey

func (r *DB) ReadDefaultKey()

ReadDefaultKey returns the current set default key

func (*DB) ReadKey

func (r *DB) ReadKey(address *[]byte) (out *key.Priv)

ReadKey reads a key entry from the database

func (*DB) ReadMasterKeys

func (r *DB) ReadMasterKeys() (BC []*bc.BlockCrypt)

ReadMasterKeys returns all of the masterkey entries in the database

func (*DB) ReadMinVersion

func (r *DB) ReadMinVersion()

ReadMinVersion returns the minimum version required to read this database

func (*DB) ReadName

func (r *DB) ReadName(id *[]byte) (out *rec.Name)

ReadName reads a name entry out of the database

func (*DB) ReadPool

func (r *DB) ReadPool() *rec.Pool

ReadPool gets the oldest (lowest sequence number) key and moves it to the private key map, and triggers a keypool refill if it drops below KeyPoolLow

func (*DB) ReadTx

func (r *DB) ReadTx()

ReadTx reads a transaction entry from the database

func (*DB) Recover

func (r *DB) Recover()

Recover attempts to recover as much data as possible from the database files by parsing their key and value tables as raw data

func (*DB) RemoveBC

func (r *DB) RemoveBC() *DB

RemoveBC removes the BlockCrypt and decrypts all the records in the database.

func (*DB) WithBC

func (r *DB) WithBC(BC *bc.BlockCrypt) *DB

WithBC attaches a BlockCrypt and thus enabling encryption of sensitive data in the wallet. Changes the encryption if already encrypted or enables it.

func (*DB) WriteAccount

func (r *DB) WriteAccount(address, pub *[]byte) *DB

WriteAccount writes a new account entry

func (*DB) WriteAccountingEntry

func (r *DB) WriteAccountingEntry()

WriteAccountingEntry writes an accounting entry based on a transaction

func (*DB) WriteBestBlock

func (r *DB) WriteBestBlock()

WriteBestBlock gets the current best block entry

func (*DB) WriteDefaultKey

func (r *DB) WriteDefaultKey()

WriteDefaultKey updates the default key used by interfaces when receiving payments

func (*DB) WriteKey

func (r *DB) WriteKey(priv *key.Priv) *DB

WriteKey writes a key entry to the database

func (*DB) WriteMasterKey

func (r *DB) WriteMasterKey(BC *bc.BlockCrypt) *DB

WriteMasterKey adds a master key entry to the database

func (*DB) WriteMinVersion

func (r *DB) WriteMinVersion()

WriteMinVersion updates the minimum version

func (*DB) WriteName

func (r *DB) WriteName(address, label *[]byte) *DB

WriteName writes a name entry to the database

func (*DB) WritePool

func (r *DB) WritePool(newPool *rec.Pool) *DB

WritePool blindly writes a pool record, assuming its indices do not conflict (used by the NewKeyPool function)

func (*DB) WriteScript

func (r *DB) WriteScript()

WriteScript writes a script entry to the database

func (*DB) WriteTx

func (r *DB) WriteTx()

WriteTx writes a transaction entry from the database

Directories

Path Synopsis
Package rec is a maybe unnecessary collection of specifications of the data formats used in the walletdb.
Package rec is a maybe unnecessary collection of specifications of the data formats used in the walletdb.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL