wallet

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: 13 Imported by: 0

Documentation

Overview

Package wallet is a library for working with a duo blockchain client wallet

Index

Constants

View Source
const (
	// CurrentVersion is the version number from this source repository
	CurrentVersion = 1
	// 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
)

Variables

View Source
var (
	// AccountingEntryNumber is
	AccountingEntryNumber = 0
)

Functions

This section is empty.

Types

type AddressBook

type AddressBook map[core.Address]*rec.Account

AddressBook is a collection of correspondent addresses

type KeyMetadata

type KeyMetadata struct {
	Pub        *key.Pub
	Version    uint32
	CreateTime int64
}

KeyMetadata is a structure for storing metadata related to a key pair

func NewKeyMetadata

func NewKeyMetadata(createTime int64) (M *KeyMetadata)

NewKeyMetadata makes a new KeyMetadata structure

type KeyPool

type KeyPool struct {
	Pool     PoolMap
	High     int
	Low      int
	Lifespan time.Duration
	Size     int
}

KeyPool is a collection of available addresses for constructing transactions

type MasterKeyMap

type MasterKeyMap map[uint64]*KeyMetadata

MasterKeyMap is the collection of masterkeys in the wallet

type MasterKeys

type MasterKeys map[uint64]bc.BlockCrypt

MasterKeys is a map storing BC's

type Orders

type Orders struct {
	Key, Value string
}

Orders are a key value pair

type PoolMap

type PoolMap map[int]*rec.Pool

PoolMap is a collection of KeyPool entries

type ReserveKey

type ReserveKey struct {
	Index  int64
	PubKey key.Pub
	// contains filtered or unexported fields
}

ReserveKey is

type ScanState

type ScanState struct {
	Keys, CKeys, KeyMeta      uint
	IsEncrypted, AnyUnordered bool
	FileVersion               int
	WalletUpgrade             []*core.Hash
}

ScanState is

type Transactions

type Transactions map[core.Hash]*rec.Tx

Transactions is a map of transactions in the wallet

type ValueMap

type ValueMap map[string]string

ValueMap is

type Wallet

type Wallet struct {
	KeyStore key.Store
	DB       *db.DB

	FileBacked      bool
	File            string
	KeyPool         *KeyPool
	KeyMetadata     map[core.Address]*KeyMetadata
	MasterKeys      MasterKeys
	Transactions    Transactions
	OrderPosNext    int
	RequestCountMap map[core.Hash]int
	AddressBook     AddressBook
	DefaultKey      *key.Pub
	LockedCoinsSet  []*tx.OutPoint
	TimeFirstKey    int64
	core.State
	// contains filtered or unexported fields
}

Wallet controls access to a wallet.db file containing keys and data relating to accounts and addresses

func New

func New(newWDB *db.DB) *Wallet

New returns a new Wallet

func (*Wallet) AddAccount

func (r *Wallet) AddAccount(account *rec.Account) *Wallet

AddAccount adds a new account (correspondent address and optionally public key)

func (*Wallet) AddKeyPair

func (r *Wallet) AddKeyPair(k *key.Priv) *Wallet

AddKeyPair -

func (*Wallet) AddScript

func (r *Wallet) AddScript(script *rec.Script) *Wallet

AddScript -

func (*Wallet) AddToWalletIfInvolvingMe

func (r *Wallet) AddToWalletIfInvolvingMe(id core.Address, tx *tx.Transaction, block *block.Block, update bool, findblock bool) *Wallet

AddToWalletIfInvolvingMe -

func (*Wallet) AddTx

func (r *Wallet) AddTx(tx *tx.Transaction) *Wallet

AddTx -

func (*Wallet) AvailableCoins

func (r *Wallet) AvailableCoins([]tx.Output, bool)

AvailableCoins -

func (*Wallet) ChangeWalletPassphrase

func (r *Wallet) ChangeWalletPassphrase(oldp, newp *buf.Secure) *Wallet

ChangeWalletPassphrase removes any old master keys and creates a new one based on a given password. If the crypt is not locked the old password is required to change it, and if it's not encrypted we just return an error

func (*Wallet) CommitTransaction

func (r *Wallet) CommitTransaction(*tx.Transaction, *ReserveKey) *Wallet

CommitTransaction -

func (*Wallet) CreateTransaction

func (r *Wallet) CreateTransaction(*rec.Script, int64, *tx.Transaction, *ReserveKey, int64, string) *Wallet

CreateTransaction -

func (*Wallet) CreateTransactions

func (r *Wallet) CreateTransactions([]map[*rec.Script]int64, *tx.Transaction, *ReserveKey, int64, string) *Wallet

CreateTransactions -

func (*Wallet) DelAddressBookName

func (r *Wallet) DelAddressBookName(*tx.Destination) *Wallet

DelAddressBookName -

func (*Wallet) EmptyKeyPool

func (r *Wallet) EmptyKeyPool() *Wallet

EmptyKeyPool deletes an entire keypool

func (*Wallet) EncryptWallet

func (r *Wallet) EncryptWallet(string)

EncryptWallet -

func (*Wallet) EraseFromWallet

func (r *Wallet) EraseFromWallet(core.Hash) *Wallet

EraseFromWallet -

func (*Wallet) GenerateNewKey

func (r *Wallet) GenerateNewKey() *key.Pub

GenerateNewKey -

func (*Wallet) GetAddressBalances

func (r *Wallet) GetAddressBalances() map[*tx.Destination]int64

GetAddressBalances -

func (*Wallet) GetAddressGroupings

func (r *Wallet) GetAddressGroupings() []tx.Destination

GetAddressGroupings -

func (*Wallet) GetAllReserveKeys

func (r *Wallet) GetAllReserveKeys() []core.Address

GetAllReserveKeys -

func (*Wallet) GetBalance

func (r *Wallet) GetBalance() int64

GetBalance -

func (*Wallet) GetChange

func (r *Wallet) GetChange(*tx.Out) int64

GetChange -

func (*Wallet) GetCredit

func (r *Wallet) GetCredit(*tx.Out) int64

GetCredit -

func (*Wallet) GetDebit

func (r *Wallet) GetDebit(*tx.In) int64

GetDebit -

func (*Wallet) GetImmatureBalance

func (r *Wallet) GetImmatureBalance() int64

GetImmatureBalance -

func (*Wallet) GetKeyBirthTimes

func (r *Wallet) GetKeyBirthTimes(map[*core.Address]int64)

GetKeyBirthTimes -

func (*Wallet) GetKeyFromPool

func (r *Wallet) GetKeyFromPool(allowReuse bool) (out *key.Priv)

GetKeyFromPool gets the oldest key form the keypool, if it is not allowed to be reused it is taken out of the pool and stored as a main wallet private/public key pair

func (*Wallet) GetKeyPoolSize

func (r *Wallet) GetKeyPoolSize() int

GetKeyPoolSize returns the number of keys in the keypool

func (*Wallet) GetOldestKeyPoolTime

func (r *Wallet) GetOldestKeyPoolTime() int64

GetOldestKeyPoolTime -

func (*Wallet) GetTransaction

func (r *Wallet) GetTransaction(*core.Hash, *tx.Transaction) *Wallet

GetTransaction -

func (*Wallet) GetTxChange

func (r *Wallet) GetTxChange(*tx.Transaction) int64

GetTxChange -

func (*Wallet) GetTxCredit

func (r *Wallet) GetTxCredit(*tx.Transaction) int64

GetTxCredit -

func (*Wallet) GetTxDebit

func (r *Wallet) GetTxDebit(*tx.Transaction) int64

GetTxDebit -

func (*Wallet) GetUnconfirmedBalance

func (r *Wallet) GetUnconfirmedBalance() int64

GetUnconfirmedBalance -

func (*Wallet) GetVersion

func (r *Wallet) GetVersion() int

GetVersion -

func (*Wallet) IncOrderPosNext

func (r *Wallet) IncOrderPosNext(*db.DB) int64

IncOrderPosNext -

func (*Wallet) Inventory

func (r *Wallet) Inventory(*core.Hash)

Inventory -

func (*Wallet) IsChange

func (r *Wallet) IsChange(*tx.Out) *Wallet

IsChange -

func (*Wallet) IsFromMe

func (r *Wallet) IsFromMe(*tx.Transaction) *Wallet

IsFromMe -

func (*Wallet) IsLockedCoin

func (r *Wallet) IsLockedCoin(*core.Hash, uint) *Wallet

IsLockedCoin -

func (*Wallet) IsMyTX

func (r *Wallet) IsMyTX(*tx.Transaction) *Wallet

IsMyTX -

func (*Wallet) IsMyTxIn

func (r *Wallet) IsMyTxIn(*tx.In) *Wallet

IsMyTxIn -

func (*Wallet) IsMyTxOut

func (r *Wallet) IsMyTxOut(*tx.Out) *Wallet

IsMyTxOut -

func (*Wallet) KeepKey

func (r *Wallet) KeepKey(int64)

KeepKey -

func (*Wallet) ListLockedCoins

func (r *Wallet) ListLockedCoins([]tx.OutPoint)

ListLockedCoins -

func (*Wallet) LoadCryptedKey

func (r *Wallet) LoadCryptedKey(*key.Pub, []byte) *Wallet

LoadCryptedKey -

func (*Wallet) LoadKey

func (r *Wallet) LoadKey(*key.Priv, *key.Pub) *Wallet

LoadKey -

func (*Wallet) LoadKeyMetadata

func (r *Wallet) LoadKeyMetadata(*key.Pub, *KeyMetadata) *Wallet

LoadKeyMetadata -

func (*Wallet) LoadKeyPool

func (r *Wallet) LoadKeyPool() *Wallet

LoadKeyPool loads the keypool into memory from the database. Note that this does not load the public and private keys, the keys of pool entries contain everything needed to decide which one to use

func (*Wallet) LoadMinVersion

func (r *Wallet) LoadMinVersion(int) *Wallet

LoadMinVersion -

func (*Wallet) LoadScript

func (r *Wallet) LoadScript(*rec.Script) *Wallet

LoadScript -

func (*Wallet) LoadWallet

func (r *Wallet) LoadWallet(bool) error

LoadWallet -

func (*Wallet) LockCoin

func (r *Wallet) LockCoin(*tx.OutPoint) *Wallet

LockCoin -

func (*Wallet) MarkDirty

func (r *Wallet) MarkDirty() *Wallet

MarkDirty -

func (*Wallet) NewKeyPool

func (r *Wallet) NewKeyPool() *Wallet

NewKeyPool creates a new pool of keys in reserve for generating transactions

func (*Wallet) NotifyAddressBookChanged

func (r *Wallet) NotifyAddressBookChanged(*Wallet, *tx.Destination, string, bool, int)

NotifyAddressBookChanged -

func (*Wallet) NotifyTransactionChanged

func (r *Wallet) NotifyTransactionChanged(*Wallet, *core.Hash, int)

NotifyTransactionChanged -

func (*Wallet) OrderedTxItems

func (r *Wallet) OrderedTxItems([]rec.Accounting, string) *tx.Items

OrderedTxItems -

func (*Wallet) PrintWallet

func (r *Wallet) PrintWallet(*block.Block)

PrintWallet -

func (*Wallet) ReacceptWalletTransactions

func (r *Wallet) ReacceptWalletTransactions()

ReacceptWalletTransactions -

func (*Wallet) ResendWalletTransactions

func (r *Wallet) ResendWalletTransactions()

ResendWalletTransactions -

func (*Wallet) ReturnKey

func (r *Wallet) ReturnKey(int64)

ReturnKey -

func (*Wallet) ScanForWalletTransactions

func (r *Wallet) ScanForWalletTransactions(*block.Index, bool) int

ScanForWalletTransactions -

func (*Wallet) SelectCoinsMinConf

func (r *Wallet) SelectCoinsMinConf(int64, int, int, []tx.Output) (err error)

SelectCoinsMinConf -

func (*Wallet) SendMoney

func (r *Wallet) SendMoney(*rec.Script, int64, *tx.Transaction, bool) string

SendMoney -

func (*Wallet) SendMoneyToDestination

func (r *Wallet) SendMoneyToDestination(*tx.Destination) string

SendMoneyToDestination -

func (*Wallet) SetAddressBookName

func (r *Wallet) SetAddressBookName(*tx.Destination, string) *Wallet

SetAddressBookName -

func (*Wallet) SetBestChain

func (r *Wallet) SetBestChain(*block.Locator)

SetBestChain -

func (*Wallet) SetDefaultKey

func (r *Wallet) SetDefaultKey(*key.Pub) *Wallet

SetDefaultKey -

func (*Wallet) SetMaxVersion

func (r *Wallet) SetMaxVersion(int) *Wallet

SetMaxVersion -

func (*Wallet) SetMinVersion

func (r *Wallet) SetMinVersion(int, *db.DB, bool) *Wallet

SetMinVersion -

func (*Wallet) TopUpKeyPool

func (r *Wallet) TopUpKeyPool() *Wallet

TopUpKeyPool -

func (*Wallet) Unlock

func (r *Wallet) Unlock(string) *Wallet

Unlock -

func (*Wallet) UnlockAllCoins

func (r *Wallet) UnlockAllCoins()

UnlockAllCoins -

func (*Wallet) UnlockCoin

func (r *Wallet) UnlockCoin(*tx.OutPoint)

UnlockCoin -

func (*Wallet) UpdatedTransaction

func (r *Wallet) UpdatedTransaction(*core.Hash)

UpdatedTransaction -

func (*Wallet) WalletUpdateSpent

func (r *Wallet) WalletUpdateSpent(*tx.Transaction)

WalletUpdateSpent -

Directories

Path Synopsis
db
Package db is the collection of types required to run a wallet service and store the data securely on disk in a Badger database.
Package db is the collection of types required to run a wallet service and store the data securely on disk in a Badger database.
rec
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