Documentation ¶
Index ¶
- Constants
- Variables
- type SavedKey033x
- type SeedFile
- type SiagKeyPair
- type SpendableKeyFile
- type UniqueID
- type Wallet
- func (w *Wallet) AddressTransactions(uh types.UnlockHash) (pts []modules.ProcessedTransaction)
- func (w *Wallet) AddressUnconfirmedTransactions(uh types.UnlockHash) (pts []modules.ProcessedTransaction)
- func (w *Wallet) AllAddresses() []types.UnlockHash
- func (w *Wallet) AllSeeds() ([]modules.Seed, error)
- func (w *Wallet) ConfirmedBalance() (siacoinBalance types.Currency, siafundBalance types.Currency, ...)
- func (w *Wallet) CreateBackup(backupFilepath string) error
- func (w *Wallet) Encrypt(masterKey crypto.TwofishKey) (modules.Seed, error)
- func (w *Wallet) Encrypted() bool
- func (w *Wallet) Load033xWallet(masterKey crypto.TwofishKey, filepath033x string) error
- func (w *Wallet) LoadSeed(masterKey crypto.TwofishKey, seed modules.Seed) error
- func (w *Wallet) LoadSiagKeys(masterKey crypto.TwofishKey, keyfiles []string) error
- func (w *Wallet) Lock() error
- func (w *Wallet) NextAddress() (types.UnlockConditions, error)
- func (w *Wallet) PrimarySeed() (modules.Seed, uint64, error)
- func (w *Wallet) ProcessConsensusChange(cc modules.ConsensusChange)
- func (w *Wallet) ReceiveUpdatedUnconfirmedTransactions(txns []types.Transaction, _ modules.ConsensusChange)
- func (w *Wallet) RegisterTransaction(t types.Transaction, parents []types.Transaction) modules.TransactionBuilder
- func (w *Wallet) SendSiacoins(amount types.Currency, dest types.UnlockHash) ([]types.Transaction, error)
- func (w *Wallet) SendSiafunds(amount types.Currency, dest types.UnlockHash) ([]types.Transaction, error)
- func (w *Wallet) StartTransaction() modules.TransactionBuilder
- func (w *Wallet) Transaction(txid types.TransactionID) (modules.ProcessedTransaction, bool)
- func (w *Wallet) Transactions(startHeight, endHeight types.BlockHeight) (pts []modules.ProcessedTransaction, err error)
- func (w *Wallet) UnconfirmedBalance() (outgoingSiacoins types.Currency, incomingSiacoins types.Currency)
- func (w *Wallet) UnconfirmedTransactions() []modules.ProcessedTransaction
- func (w *Wallet) Unlock(masterKey crypto.TwofishKey) error
- func (w *Wallet) Unlocked() bool
- type WalletPersist
Constants ¶
const ( // The header for all siag files. Do not change. Because siag was created // early in development, compatibility with siag requires manually handling // the headers and version instead of using the persist package. SiagFileHeader = "siag" SiagFileExtension = ".siakey" SiagFileVersion = "1.0" )
const ( // RespendTimeout records the number of blocks that the wallet will wait // before spending an output that has been spent in the past. If the // transaction spending the output has not made it to the transaction pool // after the limit, the assumption is that it never will. RespendTimeout = 40 )
Variables ¶
var ( ErrInconsistentKeys = errors.New("keyfiles provided that are for different addresses") ErrInsufficientKeys = errors.New("not enough keys provided to spend the siafunds") ErrNoKeyfile = errors.New("no keyfile has been presented") ErrUnknownHeader = errors.New("file contains the wrong header") ErrUnknownVersion = errors.New("file has an unknown version number") )
Functions ¶
This section is empty.
Types ¶
type SavedKey033x ¶ added in v1.0.0
type SavedKey033x struct { SecretKey crypto.SecretKey UnlockConditions types.UnlockConditions Visible bool }
SavedKey033x is the persist structure that was used to save and load private keys in versions v0.3.3.x for siad.
type SeedFile ¶ added in v1.0.0
type SeedFile struct { UID UniqueID EncryptionVerification crypto.Ciphertext Seed crypto.Ciphertext }
SeedFile stores an encrypted wallet seed on disk.
type SiagKeyPair ¶ added in v1.0.0
type SiagKeyPair struct { Header string Version string Index int // should be uint64 - too late now SecretKey crypto.SecretKey UnlockConditions types.UnlockConditions }
A SiagKeyPair is the struct representation of the bytes that get saved to disk by siag when a new keyfile is created.
type SpendableKeyFile ¶ added in v1.0.0
type SpendableKeyFile struct { UID UniqueID EncryptionVerification crypto.Ciphertext SpendableKey crypto.Ciphertext }
SpendableKeyFile stores an encrypted spendable key on disk.
type UniqueID ¶ added in v1.0.0
type UniqueID [crypto.EntropySize]byte
UniqueID is a unique id randomly generated and put at the front of every persistence object. It is used to make sure that a different encryption key can be used for every persistence object.
type Wallet ¶
type Wallet struct {
// contains filtered or unexported fields
}
Wallet is an object that tracks balances, creates keys and addresses, manages building and sending transactions.
func New ¶
func New(cs modules.ConsensusSet, tpool modules.TransactionPool, persistDir string) (*Wallet, error)
New creates a new wallet, loading any known addresses from the input file name and then using the file to save in the future. Keys and addresses are not loaded into the wallet during the call to 'new', but rather during the call to 'Unlock'.
func (*Wallet) AddressTransactions ¶ added in v1.0.0
func (w *Wallet) AddressTransactions(uh types.UnlockHash) (pts []modules.ProcessedTransaction)
AddressTransactions returns all of the wallet transactions associated with a single unlock hash.
func (*Wallet) AddressUnconfirmedTransactions ¶ added in v1.0.0
func (w *Wallet) AddressUnconfirmedTransactions(uh types.UnlockHash) (pts []modules.ProcessedTransaction)
AddressUnconfirmedHistory returns all of the unconfirmed wallet transactions related to a specific address.
func (*Wallet) AllAddresses ¶ added in v1.0.0
func (w *Wallet) AllAddresses() []types.UnlockHash
AllAddresses returns all addresses that the wallet is able to spend from, including unseeded addresses. Addresses are returned sorted in byte-order.
func (*Wallet) AllSeeds ¶ added in v1.0.0
AllSeeds returns a list of all seeds known to and used by the wallet.
func (*Wallet) ConfirmedBalance ¶ added in v1.0.0
func (w *Wallet) ConfirmedBalance() (siacoinBalance types.Currency, siafundBalance types.Currency, siafundClaimBalance types.Currency)
ConfirmedBalance returns the balance of the wallet according to all of the confirmed transactions.
func (*Wallet) CreateBackup ¶ added in v1.0.0
CreateBackup creates a backup file at the desired filepath.
func (*Wallet) Encrypt ¶ added in v1.0.0
Encrypt will encrypt the wallet using the input key. Upon encryption, a primary seed will be created for the wallet (no seed exists prior to this point). If the key is blank, then the hash of the seed that is generated will be used as the key. The wallet will still be locked after encryption.
Encrypt can only be called once throughout the life of the wallet, and will return an error on subsequent calls (even after restarting the wallet). To reset the wallet, the wallet files must be moved to a different directory or deleted.
func (*Wallet) Encrypted ¶ added in v1.0.0
Encrypted returns whether or not the wallet has been encrypted.
func (*Wallet) Load033xWallet ¶ added in v1.0.0
func (w *Wallet) Load033xWallet(masterKey crypto.TwofishKey, filepath033x string) error
Load033xWallet loads a v0.3.3.x wallet as an unseeded key, such that the funds become spendable to the current wallet.
func (*Wallet) LoadSeed ¶ added in v1.0.0
LoadSeed will track all of the addresses generated by the input seed, reclaiming any funds that were lost due to a deleted file or lost encryption key. An error will be returned if the seed has already been integrated with the wallet.
func (*Wallet) LoadSiagKeys ¶ added in v1.0.0
func (w *Wallet) LoadSiagKeys(masterKey crypto.TwofishKey, keyfiles []string) error
LoadSiagKeys loads a set of siag-generated keys into the wallet.
func (*Wallet) Lock ¶ added in v1.0.0
Lock will erase all keys from memory and prevent the wallet from spending coins until it is unlocked.
func (*Wallet) NextAddress ¶ added in v1.0.0
func (w *Wallet) NextAddress() (types.UnlockConditions, error)
NextAddress returns an unlock hash that is ready to receive siacoins or siafunds. The address is generated using the primary address seed.
func (*Wallet) PrimarySeed ¶ added in v1.0.0
PrimarySeed returns the decrypted primary seed of the wallet.
func (*Wallet) ProcessConsensusChange ¶ added in v1.0.0
func (w *Wallet) ProcessConsensusChange(cc modules.ConsensusChange)
ProcessConsensusChange parses a consensus change to update the set of confirmed outputs known to the wallet.
func (*Wallet) ReceiveUpdatedUnconfirmedTransactions ¶ added in v1.0.0
func (w *Wallet) ReceiveUpdatedUnconfirmedTransactions(txns []types.Transaction, _ modules.ConsensusChange)
ReceiveUpdatedUnconfirmedTransactions updates the wallet's unconfirmed transaction set.
func (*Wallet) RegisterTransaction ¶
func (w *Wallet) RegisterTransaction(t types.Transaction, parents []types.Transaction) modules.TransactionBuilder
RegisterTransaction takes a transaction and its parents and returns a TransactionBuilder which can be used to expand the transaction. The most typical call is 'RegisterTransaction(types.Transaction{}, nil)', which registers a new transaction without parents.
func (*Wallet) SendSiacoins ¶ added in v1.0.0
func (w *Wallet) SendSiacoins(amount types.Currency, dest types.UnlockHash) ([]types.Transaction, error)
SendSiacoins creates a transaction sending 'amount' to 'dest'. The transaction is submitted to the transaction pool and is also returned.
func (*Wallet) SendSiafunds ¶ added in v1.0.0
func (w *Wallet) SendSiafunds(amount types.Currency, dest types.UnlockHash) ([]types.Transaction, error)
SendSiafunds creates a transaction sending 'amount' to 'dest'. The transaction is submitted to the transaction pool and is also returned.
func (*Wallet) StartTransaction ¶ added in v1.0.0
func (w *Wallet) StartTransaction() modules.TransactionBuilder
StartTransaction is a convenience function that calls RegisterTransaction(types.Transaction{}, nil).
func (*Wallet) Transaction ¶ added in v1.0.0
func (w *Wallet) Transaction(txid types.TransactionID) (modules.ProcessedTransaction, bool)
Transaction returns the transaction with the given id. 'False' is returned if the transaction does not exist.
func (*Wallet) Transactions ¶ added in v1.0.0
func (w *Wallet) Transactions(startHeight, endHeight types.BlockHeight) (pts []modules.ProcessedTransaction, err error)
Transactions returns all transactions relevant to the wallet that were confirmed in the range [startHeight, endHeight].
func (*Wallet) UnconfirmedBalance ¶ added in v1.0.0
func (w *Wallet) UnconfirmedBalance() (outgoingSiacoins types.Currency, incomingSiacoins types.Currency)
UnconfirmedBalance returns the number of outgoing and incoming siacoins in the unconfirmed transaction set. Refund outputs are included in this reporting.
func (*Wallet) UnconfirmedTransactions ¶ added in v1.0.0
func (w *Wallet) UnconfirmedTransactions() []modules.ProcessedTransaction
UnconfirmedTransactions returns the set of unconfirmed transactions that are relevant to the wallet.
type WalletPersist ¶ added in v1.0.0
type WalletPersist struct { // EncryptionVerification is an encrypted string that, when decrypted, is // 32 '0' bytes. The UID is used to prevent leaking information in the // event that the same key gets used for multiple wallets. UID UniqueID EncryptionVerification crypto.Ciphertext // The primary seed is used to generate new addresses as they are required. // All addresses are tracked and spendable. Only modules.PublicKeysPerSeed // keys/addresses can be created per seed, after which a new seed will need // to be generated. PrimarySeedFile SeedFile PrimarySeedProgress uint64 // AuxiliarySeedFiles is a set of seeds that the wallet can spend from, but is // no longer using to generate addresses. The primary use case is loading // backups in the event of lost files or coins. All auxiliary seeds are // encrypted using the primary seed encryption password. AuxiliarySeedFiles []SeedFile // UnseededKeys are list of spendable keys that were not generated by a // random seed. UnseededKeys []SpendableKeyFile }
WalletPersist contains all data that persists on disk during wallet operation.