Documentation
¶
Overview ¶
A library for working with a duo blockchain client wallet
Index ¶
- Constants
- Variables
- func DeleteBuffer(b *memguard.LockedBuffer)
- func DeleteBuffers(b ...*memguard.LockedBuffer)
- func NewBuffer(size int) (B *memguard.LockedBuffer, err error)
- func NewBufferFromBytes(b []byte) (B *memguard.LockedBuffer, err error)
- func ToJSON(p interface{}) (j string)
- type Account
- type AccountingEntry
- type AddressBook
- type BCKey
- type BDefaultKey
- type BKey
- type BMetadata
- type BName
- type BWKey
- type DB
- func (db *DB) Backup(*Wallet, string) (err error)
- func (db *DB) Close() (err error)
- func (db *DB) Dump() (dump string)
- func (db *DB) Encrypt() (err error)
- func (db *DB) EraseDefaultKey() (err error)
- func (db *DB) EraseMasterKey(id int64) (err error)
- func (db *DB) EraseName(addr string) (err error)
- func (db *DB) ErasePool(int64) (err error)
- func (db *DB) EraseTx(u *Uint.U256) (err error)
- func (db *DB) Find(t int, k string) (r *jvzc.Range, err error)
- func (db *DB) Flush()
- func (db *DB) GetAccountCreditDebit(string) (err error)
- func (db *DB) GetBalance() float64
- func (db *DB) GetKeyPoolSize() int
- func (db *DB) GetOldestKeyPoolTime() int64
- func (db *DB) GetUpdateCount() uint64
- func (db *DB) ImportWalletDat(string) (err error)
- func (db *DB) ListAccountCreditDebit(string, []*AccountingEntry) (err error)
- func (db *DB) LoadWallet(*Wallet) (err error)
- func (db *DB) ReadAccount(accname string, acc *Account) (err error)
- func (db *DB) ReadBestBlock(*block.Locator) (err error)
- func (db *DB) ReadPool(int64, KeyPool) (err error)
- func (db *DB) Recover(string) (err error)
- func (db *DB) RecoverOnlyKeys(string) (err error)
- func (db *DB) ReorderTransactions(*Wallet) (err error)
- func (db *DB) Unlock() (err error)
- func (db *DB) Verify() (err error)
- func (db *DB) Version() int
- func (db *DB) WriteAccount(string, *Account) (err error)
- func (db *DB) WriteAccountingEntry(*AccountingEntry) (err error)
- func (db *DB) WriteBestBlock(*block.Locator) (err error)
- func (db *DB) WriteCryptedKey(pub *key.Pub, priv []byte, meta *KeyMetadata) (err error)
- func (db *DB) WriteDefaultKey(p *key.Pub) (err error)
- func (db *DB) WriteKey(key *Key, meta *KeyMetadata) (err error)
- func (db *DB) WriteMasterKey(mkey *MasterKey) (err error)
- func (db *DB) WriteMinVersion(int) (err error)
- func (db *DB) WriteName(n *AddressBook) (err error)
- func (db *DB) WriteOrderPosNext(p int64) (err error)
- func (db *DB) WritePool(int64, KeyPool) (err error)
- func (db *DB) WriteScript(hashID *Uint.U160, script *key.Script) (err error)
- func (db *DB) WriteTx(u *Uint.U256, t []byte) (err error)
- type EncryptedStore
- type Imports
- type Key
- type KeyMetadata
- type KeyPool
- type MasterKey
- type MasterKeyMap
- type Metadata
- type Orders
- type Pool
- type ReserveKey
- type ScanState
- type Script
- type Serializable
- type Setting
- type Transaction
- type Tx
- type TxItems
- type TxOutput
- type TxPair
- type ValueMap
- type Wallet
- func (r *Wallet) AddCryptedKey(*key.Pub, *KeyMetadata) (success bool)
- func (r *Wallet) AddKeyPair(*key.Priv, *key.Pub) (success bool)
- func (r *Wallet) AddReserveKey(*KeyPool) int64
- func (r *Wallet) AddScript(*key.Script) (success bool)
- func (r *Wallet) AddToWallet(Tx) (success bool)
- func (r *Wallet) AddToWalletIfInvolvingMe(*Uint.U256, *tx.Transaction, *block.Block, bool, bool) (success bool)
- func (r *Wallet) AvailableCoins([]TxOutput, bool)
- func (r *Wallet) CanSupportFeature(int) (success bool)
- func (r *Wallet) ChangeWalletPassphrase(string, string) (success bool)
- func (r *Wallet) CommitTransaction(*Tx, *ReserveKey) (success bool)
- func (r *Wallet) CreateTransaction(*key.Script, int64, *Tx, *ReserveKey, int64, string) (success bool)
- func (r *Wallet) CreateTransactions([]map[*key.Script]int64, *Tx, *ReserveKey, int64, string) (success bool)
- func (r *Wallet) DelAddressBookName(*key.TxDestination) (success bool)
- func (r *Wallet) EncryptWallet(string)
- func (r *Wallet) EraseFromWallet(*Uint.U256) (success bool)
- func (r *Wallet) GenerateNewKey() *key.Pub
- func (r *Wallet) GetAddressBalances() map[*key.TxDestination]int64
- func (r *Wallet) GetAddressGroupings() []key.TxDestination
- func (r *Wallet) GetAllReserveKeys() []key.ID
- func (r *Wallet) GetBalance() int64
- func (r *Wallet) GetChange(*tx.Out) int64
- func (r *Wallet) GetCredit(*tx.Out) int64
- func (r *Wallet) GetDebit(*tx.In) int64
- func (r *Wallet) GetImmatureBalance() int64
- func (r *Wallet) GetKeyBirthTimes(map[*key.ID]int64)
- func (r *Wallet) GetKeyFromPool(*key.Pub, bool) (success bool)
- func (r *Wallet) GetKeyPoolSize() int
- func (r *Wallet) GetOldestKeyPoolTime() int64
- func (r *Wallet) GetTransaction(*Uint.U256, *Tx) (success bool)
- func (r *Wallet) GetTxChange(*tx.Transaction) int64
- func (r *Wallet) GetTxCredit(*tx.Transaction) int64
- func (r *Wallet) GetTxDebit(*tx.Transaction) int64
- func (r *Wallet) GetUnconfirmedBalance() int64
- func (r *Wallet) GetVersion() int
- func (r *Wallet) IncOrderPosNext(*DB) int64
- func (r *Wallet) Inventory(*Uint.U256)
- func (r *Wallet) IsChange(*tx.Out) (success bool)
- func (r *Wallet) IsFromMe(*tx.Transaction) (success bool)
- func (r *Wallet) IsLockedCoin(*Uint.U256, uint) (success bool)
- func (r *Wallet) IsMyTX(*tx.Transaction) (success bool)
- func (r *Wallet) IsMyTxIn(*tx.In) (success bool)
- func (r *Wallet) IsMyTxOut(*tx.Out) (success bool)
- func (r *Wallet) KeepKey(int64)
- func (r *Wallet) ListLockedCoins([]tx.OutPoint)
- func (r *Wallet) LoadCryptedKey(*key.Pub, []byte) (success bool)
- func (r *Wallet) LoadKey(*key.Priv, *key.Pub) (success bool)
- func (r *Wallet) LoadKeyMetadata(*key.Pub, *KeyMetadata) (success bool)
- func (r *Wallet) LoadMinVersion(int) (success bool)
- func (r *Wallet) LoadScript(*key.Script) (success bool)
- func (r *Wallet) LoadWallet(bool) error
- func (r *Wallet) LockCoin(*tx.OutPoint)
- func (r *Wallet) MarkDirty()
- func (r *Wallet) NewKeyPool() (success bool)
- func (r *Wallet) NotifyAddressBookChanged(*Wallet, *key.TxDestination, string, bool, int)
- func (r *Wallet) NotifyTransactionChanged(*Wallet, *Uint.U256, int)
- func (r *Wallet) OrderedTxItems([]AccountingEntry, string) *TxItems
- func (r *Wallet) PrintWallet(*block.Block)
- func (r *Wallet) ReacceptWalletTransactions()
- func (r *Wallet) ResendWalletTransactions()
- func (r *Wallet) ReserveKeyFromKeyPool(int64, *KeyPool)
- func (r *Wallet) ReturnKey(int64)
- func (r *Wallet) ScanForWalletTransactions(*block.Index, bool) int
- func (r *Wallet) SelectCoinsMinConf(int64, int, int, []TxOutput) (err error)
- func (r *Wallet) SendMoney(*key.Script, int64, *Tx, bool) string
- func (r *Wallet) SendMoneyToDestination(*key.TxDestination) string
- func (r *Wallet) SetAddressBookName(*key.TxDestination, string) (success bool)
- func (r *Wallet) SetBestChain(*block.Locator)
- func (r *Wallet) SetDefaultKey(*key.Pub) (success bool)
- func (r *Wallet) SetMaxVersion(int) (success bool)
- func (r *Wallet) SetMinVersion(int, *DB, bool) (success bool)
- func (r *Wallet) TopUpKeyPool() (success bool)
- func (r *Wallet) Unlock(string) (success bool)
- func (r *Wallet) UnlockAllCoins()
- func (r *Wallet) UnlockCoin(*tx.OutPoint)
- func (r *Wallet) UpdatedTransaction(*Uint.U256)
- func (r *Wallet) WalletUpdateSpent(*tx.Transaction)
- type Wdata
Constants ¶
const ( Fname = iota Ftx Facentry Fkey Fwkey Fmkey Fckey Fkeymeta Fdefaultkey Fpool Fversion Fcscript Forderposnext Faccount Fbestblock Fminversion Flast )
const ( // FeatureBase is the base version number for a wallet FeatureBase = 10500 // FeatureWalletCrypt indicates if the wallet enables encrypted keys FeatureWalletCrypt = 40000 // FeatureCompressedPubKey indicates if the wallet enables compressed public keys FeatureCompressedPubKey = 60000 // FeatureLatest is the newest version of the wallet FeatureLatest = 60000 )
const (
CurrentVersion = 1
)
Variables ¶
var ( ErrPaddingSize = errors.New("padding size error") PKCS5 = &pkcs5{} // difference with pkcs5 only block must be 8 PKCS7 = &pkcs5{} )
var ( Filename string KeyNames = []string{"name", "tx", "acentry", "key", "wkey", "mkey", "ckey", "keymeta", "defaultkey", "pool", "version", "cscript", "orderposnext", "acc", "bestblock", "minversion"} K = KeyNames )
var (
AccountingEntryNumber = 0
)
var AllLockedBuffers []*memguard.LockedBuffer
var AllocatedBufferCount int
var AllocatedBufferTotalSize int
Functions ¶
func DeleteBuffer ¶
func DeleteBuffer(b *memguard.LockedBuffer)
Deallocates a memguard LockedBuffer and removes it from its register
func NewBuffer ¶
func NewBuffer(size int) (B *memguard.LockedBuffer, err error)
Allocates a new memguard LockedBuffer of a given size and keeps track of it
func NewBufferFromBytes ¶
func NewBufferFromBytes(b []byte) (B *memguard.LockedBuffer, err error)
Allocates a new memguard Lockbuffer and fills it with the contents of a byte slice and keeps track of it
Types ¶
type Account ¶
type Account struct { *Serializable Account []byte Version int32 Pub []byte }
I'm not sure what this is used for
type AccountingEntry ¶
type AddressBook ¶
type AddressBook struct { *Serializable Pub []byte Label []byte }
Stores the details of human readable labels for own and others addresses
func NewAddressBook ¶
func NewAddressBook(s *Serializable) (a *AddressBook)
Creates a new AddressBook
func (*AddressBook) Decrypt ¶
func (a *AddressBook) Decrypt() (A AddressBook)
Decrypt an addressbook record
func (*AddressBook) Encrypt ¶
func (a *AddressBook) Encrypt() (A AddressBook)
Encrypt an addressbook record
type BDefaultKey ¶
type BDefaultKey struct {
Key []byte
}
Stores the default key that will appear in a wallet interface when creating a payment request
type BWKey ¶
type BWKey struct { Pub []byte Priv []byte TimeCreated time.Time TimeExpires time.Time Comment string }
An unencrypted key pair with extra metadata for managing expiry in a wallet.dat
type DB ¶
type DB struct { *cete.DB UnlockedUntil int64 Net string Data EncryptedStore // contains filtered or unexported fields }
DB is the structure for encryptable wallet database
func (*DB) EraseDefaultKey ¶
EraseDefaultKey erases the default key
func (*DB) EraseMasterKey ¶
EraseMasterKey erases a master key record from a wallet database
func (*DB) Find ¶
Find searches the wallet database for an item in a specified table with a given key
func (*DB) GetAccountCreditDebit ¶
GetAccountCreditDebit gets the Account credit/debit
func (*DB) GetBalance ¶
GetBalance gets the balance of the wallet
func (*DB) GetOldestKeyPoolTime ¶
GetOldestKeyPoolTime gets the oldest keypool time
func (*DB) GetUpdateCount ¶
GetUpdateCount returns the number of times the wallet has been modified in the current session
func (*DB) ImportWalletDat ¶
ImportWalletDat imports an old style BDB wallet.dat file
func (*DB) ListAccountCreditDebit ¶
func (db *DB) ListAccountCreditDebit(string, []*AccountingEntry) (err error)
ListAccountCreditDebit gets the list off accounts and their credit/debits
func (*DB) ReadAccount ¶
ReadAccount returns the data of an Account
func (*DB) ReadBestBlock ¶
ReadBestBlock returns the best block stored in the wallet
func (*DB) RecoverOnlyKeys ¶
RecoverOnlyKeys recovers only the keys from the wallet
func (*DB) ReorderTransactions ¶
ReorderTransactions reorders transactions in the wallet
func (*DB) WriteAccount ¶
WriteAccount writes the data of an Account
func (*DB) WriteAccountingEntry ¶
func (db *DB) WriteAccountingEntry(*AccountingEntry) (err error)
WriteAccountingEntry writes an AccountingEntry to the wallet
func (*DB) WriteBestBlock ¶
WriteBestBlock writes the best block to the wallet
func (*DB) WriteCryptedKey ¶
func (db *DB) WriteCryptedKey(pub *key.Pub, priv []byte, meta *KeyMetadata) (err error)
WriteCryptedKey writes an encrypted key to the wallet
func (*DB) WriteDefaultKey ¶
WriteDefaultKey writes the default key
func (*DB) WriteKey ¶
func (db *DB) WriteKey(key *Key, meta *KeyMetadata) (err error)
WriteKey writes a new key to the wallet
func (*DB) WriteMasterKey ¶
WriteMasterKey writes a MasterKey to the wallet
func (*DB) WriteMinVersion ¶
WriteMinVersion writes the MinVersion
func (*DB) WriteName ¶
func (db *DB) WriteName(n *AddressBook) (err error)
WriteName writes a new name to the database associated with an address
func (*DB) WriteOrderPosNext ¶
WriteOrderPosNext moves the write position to the next
func (*DB) WriteScript ¶
WriteScript writes a script to the wallet
type EncryptedStore ¶
type EncryptedStore struct { *Serializable MasterKey []*MasterKey LastLocked time.Time AddressBook []*AddressBook Metadata []*Metadata Key []*Key Wdata []*Wdata Tx []*Tx Pool []*Pool Script []*Script Account []*Account Setting []*Setting DefaultKey []byte BestBlock []byte OrderPosNext int64 Version uint32 MinVersion uint32 }
A store of all the data related to a wallet with the ability to be encrypted and exported to other data formats
var ES *EncryptedStore
func Import ¶
func Import(pass *memguard.LockedBuffer, filename ...string) (es *EncryptedStore, err error)
Import reads an existing wallet.dat and returns all the keys and address data in it. If a password is given, the private keys in the CKeys array are decrypted and the encrypter/decrypter functions are armed.
type Imports ¶
type Imports struct { *Serializable Names []BName Metadata []BMetadata Keys []BKey WKeys []BWKey CKeys []BCKey DefaultKey BDefaultKey }
A collection of tables from a wallet.dat file with optional en/decryptors
type Key ¶
type Key struct { *Serializable Pub []byte Priv []byte }
A public/private key pair corresponding to a wallet address
type KeyMetadata ¶
Data structure for storing metadata related to a key pair
func NewKeyMetadata ¶
func NewKeyMetadata(createTime int64) (M *KeyMetadata)
NewKeyMetadata makes a new KeyMetadata structure
type MasterKey ¶
type MasterKey struct { MKeyID int64 EncryptedKey []byte Salt []byte Method uint32 Iterations uint32 Other []byte }
Stores the details of an encryption master key for a wallet
func (*MasterKey) Decrypt ¶
func (m *MasterKey) Decrypt(ckey *memguard.LockedBuffer, iv []byte, b ...[]byte) (r []*memguard.LockedBuffer, err error)
Decrypts ciphertext using the masterkey and a password
func (*MasterKey) Encrypt ¶
func (m *MasterKey) Encrypt(ckey *memguard.LockedBuffer, iv []byte, b ...*memguard.LockedBuffer) (r []*memguard.LockedBuffer, err error)
Encrypts plaintext using the masterkey and a password
type MasterKeyMap ¶
type MasterKeyMap map[uint]*KeyMetadata
type Metadata ¶
type Metadata struct { *Serializable Pub []byte Version uint32 CreateTime []byte }
Stores version and create time for keys
type Pool ¶
type Pool struct { *Serializable Index uint64 Version uint32 Time []byte Pub []byte }
Keys in reserve for future change operations
type ReserveKey ¶
type Script ¶
type Script struct { *Serializable ID []byte Data []byte }
A payment script related to key pairs in the wallet
type Serializable ¶
type Serializable struct {
// contains filtered or unexported fields
}
Abstract interface embeddable in other types that you wish to convert to other encodings such as JSON and potentially any type of desired encoding, as well as to enable encryption of sensitive data while it is not being utilised
func (*Serializable) DeriveCipher ¶
func (s *Serializable) DeriveCipher(pass *memguard.LockedBuffer) (mk *MasterKey, k *memguard.LockedBuffer, iv []byte, err error)
Decrypts a ciphertext using the masterkey and password
func (*Serializable) FromJSON ¶
func (s *Serializable) FromJSON(j string) (J string, err error)
Converts a JSON string into the data to fill the parent type
func (*Serializable) Lock ¶
func (s *Serializable) Lock()
Locks the sensitive data that may have been created for an serializable object
type Setting ¶
type Setting struct { *Serializable Name string Value []byte }
Stores settings related to the user's wallet
type Transaction ¶
type Transaction struct { block.MerkleTx Prev []block.MerkleTx OrderForm []Orders TimeReceivedIsTxTime, TimeReceived, TimeSmart uint FromMe byte FromAccount string Spent []byte OrderPos int64 CachedFlags struct { Debit, Credit, ImmatureCredit, AvailableCredit, Change bool } CachedValues struct { Debit, Credit, ImmatureCredit, AvailableCredit, Change int64 } // contains filtered or unexported fields }
type Tx ¶
type Tx struct { *Serializable TxHash []byte TxData []byte }
A raw transaction related to a key pair in the wallet
type TxPair ¶
type TxPair map[*Tx]*AccountingEntry
type Wallet ¶
type Wallet struct { EncryptedStore DB *DB FileBacked bool File string KeyPoolSet []int64 KeyMetadataMap map[*key.ID]*KeyMetadata MasterKeysMap MasterKeyMap MasterKeyMaxID uint WalletMap map[*Uint.U256]*Tx OrderPosNext int64 RequestCountMap map[*Uint.U256]int AddressBookMap map[*key.TxDestination]string DefaultKey *key.Pub LockedCoinsSet []*tx.OutPoint TimeFirstKey int64 // contains filtered or unexported fields }
Wallet controls access to a wallet.db file containing keys and data relating to accounts and addresses
func NewFromFile ¶
NewFromFile makes a new wallet by importing a wallet.dat file
func (*Wallet) AddCryptedKey ¶
func (r *Wallet) AddCryptedKey(*key.Pub, *KeyMetadata) (success bool)
AddCryptedKey -
func (*Wallet) AddKeyPair ¶
AddKeyPair -
func (*Wallet) AddToWalletIfInvolvingMe ¶
func (r *Wallet) AddToWalletIfInvolvingMe(*Uint.U256, *tx.Transaction, *block.Block, bool, bool) (success bool)
AddToWalletIfInvolvingMe -
func (*Wallet) CanSupportFeature ¶
CanSupportFeature -
func (*Wallet) ChangeWalletPassphrase ¶
ChangeWalletPassphrase -
func (*Wallet) CommitTransaction ¶
func (r *Wallet) CommitTransaction(*Tx, *ReserveKey) (success bool)
CommitTransaction -
func (*Wallet) CreateTransaction ¶
func (r *Wallet) CreateTransaction(*key.Script, int64, *Tx, *ReserveKey, int64, string) (success bool)
CreateTransaction -
func (*Wallet) CreateTransactions ¶
func (r *Wallet) CreateTransactions([]map[*key.Script]int64, *Tx, *ReserveKey, int64, string) (success bool)
CreateTransactions -
func (*Wallet) DelAddressBookName ¶
func (r *Wallet) DelAddressBookName(*key.TxDestination) (success bool)
DelAddressBookName -
func (*Wallet) EraseFromWallet ¶
EraseFromWallet -
func (*Wallet) GetAddressBalances ¶
func (r *Wallet) GetAddressBalances() map[*key.TxDestination]int64
GetAddressBalances -
func (*Wallet) GetAddressGroupings ¶
func (r *Wallet) GetAddressGroupings() []key.TxDestination
GetAddressGroupings -
func (*Wallet) GetAllReserveKeys ¶
GetAllReserveKeys -
func (*Wallet) GetImmatureBalance ¶
GetImmatureBalance -
func (*Wallet) GetKeyBirthTimes ¶
GetKeyBirthTimes -
func (*Wallet) GetKeyFromPool ¶
GetKeyFromPool -
func (*Wallet) GetOldestKeyPoolTime ¶
GetOldestKeyPoolTime -
func (*Wallet) GetTransaction ¶
GetTransaction -
func (*Wallet) GetUnconfirmedBalance ¶
GetUnconfirmedBalance -
func (*Wallet) IsLockedCoin ¶
IsLockedCoin -
func (*Wallet) LoadCryptedKey ¶
LoadCryptedKey -
func (*Wallet) LoadKeyMetadata ¶
func (r *Wallet) LoadKeyMetadata(*key.Pub, *KeyMetadata) (success bool)
LoadKeyMetadata -
func (*Wallet) LoadMinVersion ¶
LoadMinVersion -
func (*Wallet) NotifyAddressBookChanged ¶
NotifyAddressBookChanged -
func (*Wallet) NotifyTransactionChanged ¶
NotifyTransactionChanged -
func (*Wallet) OrderedTxItems ¶
func (r *Wallet) OrderedTxItems([]AccountingEntry, string) *TxItems
OrderedTxItems -
func (*Wallet) ReacceptWalletTransactions ¶
func (r *Wallet) ReacceptWalletTransactions()
ReacceptWalletTransactions -
func (*Wallet) ResendWalletTransactions ¶
func (r *Wallet) ResendWalletTransactions()
ResendWalletTransactions -
func (*Wallet) ReserveKeyFromKeyPool ¶
ReserveKeyFromKeyPool -
func (*Wallet) ScanForWalletTransactions ¶
ScanForWalletTransactions -
func (*Wallet) SelectCoinsMinConf ¶
SelectCoinsMinConf -
func (*Wallet) SendMoneyToDestination ¶
func (r *Wallet) SendMoneyToDestination(*key.TxDestination) string
SendMoneyToDestination -
func (*Wallet) SetAddressBookName ¶
func (r *Wallet) SetAddressBookName(*key.TxDestination, string) (success bool)
SetAddressBookName -
func (*Wallet) SetDefaultKey ¶
SetDefaultKey -
func (*Wallet) SetMinVersion ¶
SetMinVersion -
func (*Wallet) UpdatedTransaction ¶
UpdatedTransaction -
func (*Wallet) WalletUpdateSpent ¶
func (r *Wallet) WalletUpdateSpent(*tx.Transaction)
WalletUpdateSpent -