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
- type DB
- func (r *DB) Close()
- func (r *DB) Decrypt(in *buf.Byte) (out *buf.Secure)
- func (r *DB) DeleteAll() *DB
- func (r *DB) Dump()
- func (r *DB) Encrypt(in *buf.Secure) (out *buf.Byte)
- func (r *DB) EraseAccount(address *[]byte) *DB
- func (r *DB) EraseAccountingEntry()
- func (r *DB) EraseAllMasterKeys() *DB
- func (r *DB) EraseKey(address *[]byte) *DB
- func (r *DB) EraseMasterKey(idx *[]byte) *DB
- func (r *DB) EraseName(address *[]byte) *DB
- func (r *DB) ErasePool(pool *rec.Pool) *DB
- func (r *DB) EraseScript()
- func (r *DB) EraseTx()
- func (r *DB) GetAccountCreditDebit()
- func (r *DB) GetAllAccountIDs() (out []rec.Idx)
- func (r *DB) LoadWallet()
- func (r *DB) NewIf() *DB
- func (r *DB) ReadAccount(address *[]byte) (out *rec.Account)
- func (r *DB) ReadAccountingEntry()
- func (r *DB) ReadBestBlock()
- func (r *DB) ReadDefaultKey()
- func (r *DB) ReadKey(address *[]byte) (out *key.Priv)
- func (r *DB) ReadMasterKeys() (BC []*bc.BlockCrypt)
- func (r *DB) ReadMinVersion()
- func (r *DB) ReadName(id *[]byte) (out *rec.Name)
- func (r *DB) ReadPool() *rec.Pool
- func (r *DB) ReadTx()
- func (r *DB) Recover()
- func (r *DB) RemoveBC() *DB
- func (r *DB) WithBC(BC *bc.BlockCrypt) *DB
- func (r *DB) WriteAccount(address, pub *[]byte) *DB
- func (r *DB) WriteAccountingEntry()
- func (r *DB) WriteBestBlock()
- func (r *DB) WriteDefaultKey()
- func (r *DB) WriteKey(priv *key.Priv) *DB
- func (r *DB) WriteMasterKey(BC *bc.BlockCrypt) *DB
- func (r *DB) WriteMinVersion()
- func (r *DB) WriteName(address, label *[]byte) *DB
- func (r *DB) WritePool(newPool *rec.Pool) *DB
- func (r *DB) WriteScript()
- func (r *DB) WriteTx()
Constants ¶
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 ¶
NewWalletDB creates a new walletDB. Path, BaseDir, ValueDir the order of how the variadic options will be processed to override thte defaults
func (*DB) Decrypt ¶
Decrypt transparently uses a BlockCrypt if available to deecrypt the data before it is returned to the caller, or it writes plaintext
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 ¶
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 ¶
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 ¶
EraseAllMasterKeys deletes all of the masterkeys
func (*DB) EraseMasterKey ¶
EraseMasterKey deletes a masterkey entry from the database
func (*DB) EraseScript ¶
func (r *DB) EraseScript()
EraseScript deletes a script 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 ¶
GetAllAccountIDs returns an array containing all of the accounts in the database by their index
func (*DB) ReadAccount ¶
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) 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) ReadPool ¶
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) 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) 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 ¶
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) 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) WritePool ¶
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