Documentation ¶
Index ¶
- Constants
- Variables
- type SeedFile
- type SpendableKeyFile
- type UniqueID
- type Wallet
- func (w *Wallet) AddressTransactions(uh types.UnlockHash) (pts []modules.ProcessedTransaction, err error)
- func (w *Wallet) AddressUnconfirmedTransactions(uh types.UnlockHash) (pts []modules.ProcessedTransaction, err error)
- func (w *Wallet) AllAddresses() ([]types.UnlockHash, error)
- func (w *Wallet) AllSeeds() ([]modules.Seed, error)
- func (w *Wallet) BlockStakeStats() (BCcountLast1000 uint64, BCfeeLast1000 types.Currency, BlockCount uint64, ...)
- func (w *Wallet) Close() error
- func (w *Wallet) ConfirmedBalance() (coinBalance types.Currency, blockstakeBalance types.Currency, err error)
- func (w *Wallet) ConfirmedLockedBalance() (coinBalance types.Currency, blockstakeBalance types.Currency, err error)
- func (w *Wallet) CreateBackup(backupFilepath string) error
- func (w *Wallet) CreateRawTransaction(coids []types.CoinOutputID, bsoids []types.BlockStakeOutputID, ...) (types.Transaction, error)
- func (w *Wallet) Encrypt(masterKey crypto.TwofishKey, primarySeed modules.Seed) (modules.Seed, error)
- func (w *Wallet) Encrypted() bool
- func (w *Wallet) GetKey(address types.UnlockHash) (pk types.PublicKey, sk types.ByteSlice, err error)
- func (w *Wallet) GetUnspentBlockStakeOutputs() (unspent []types.UnspentBlockStakeOutput, err error)
- func (w *Wallet) GreedySign(txn types.Transaction) (types.Transaction, error)
- func (w *Wallet) Init(primarySeed modules.Seed) (modules.Seed, error)
- func (w *Wallet) LoadPlainSeed(seed modules.Seed) error
- func (w *Wallet) LoadSeed(masterKey crypto.TwofishKey, seed modules.Seed) error
- func (w *Wallet) Lock() error
- func (w *Wallet) LockedUnspendOutputs() (map[types.CoinOutputID]types.CoinOutput, ...)
- func (w *Wallet) MultiSigWallets() ([]modules.MultiSigWallet, error)
- func (w *Wallet) NextAddress() (types.UnlockHash, 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) error
- func (w *Wallet) RegisterTransaction(t types.Transaction, parents []types.Transaction) modules.TransactionBuilder
- func (w *Wallet) SendBlockStakes(amount types.Currency, cond types.UnlockConditionProxy) (types.Transaction, error)
- func (w *Wallet) SendCoins(amount types.Currency, cond types.UnlockConditionProxy, data []byte) (types.Transaction, error)
- func (w *Wallet) SendOutputs(coinOutputs []types.CoinOutput, blockstakeOutputs []types.BlockStakeOutput, ...) (types.Transaction, error)
- func (w *Wallet) StartTransaction() modules.TransactionBuilder
- func (w *Wallet) StartTransactionWithVersion(version types.TransactionVersion) modules.TransactionBuilder
- func (w *Wallet) Transaction(txid types.TransactionID) (modules.ProcessedTransaction, bool, error)
- func (w *Wallet) Transactions(startHeight, endHeight types.BlockHeight) (pts []modules.ProcessedTransaction, err error)
- func (w *Wallet) UnconfirmedBalance() (outgoingCoins types.Currency, incomingCoins types.Currency, err error)
- func (w *Wallet) UnconfirmedTransactions() ([]modules.ProcessedTransaction, error)
- func (w *Wallet) Unlock(masterKey crypto.TwofishKey) error
- func (w *Wallet) Unlocked() bool
- func (w *Wallet) UnlockedUnspendOutputs() (map[types.CoinOutputID]types.CoinOutput, ...)
- func (w *Wallet) UnspentBlockStakeOutputs() (map[types.BlockStakeOutputID]types.BlockStakeOutput, error)
Constants ¶
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 (
ErrNilOutputs = errors.New("nil outputs cannot be send")
)
various errors returned by the wallet
Functions ¶
This section is empty.
Types ¶
type SeedFile ¶
type SeedFile struct { UID UniqueID EncryptionVerification crypto.Ciphertext Seed crypto.Ciphertext }
SeedFile stores an encrypted wallet seed on disk.
type SpendableKeyFile ¶
type SpendableKeyFile struct { UID UniqueID EncryptionVerification crypto.Ciphertext SpendableKey crypto.Ciphertext }
SpendableKeyFile stores an encrypted spendable key on disk.
type UniqueID ¶
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, bcInfo types.BlockchainInfo, chainCts types.ChainConstants, verboseLogging bool) (*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 ¶
func (w *Wallet) AddressTransactions(uh types.UnlockHash) (pts []modules.ProcessedTransaction, err error)
AddressTransactions returns all of the wallet transactions associated with a single unlock hash.
func (*Wallet) AddressUnconfirmedTransactions ¶
func (w *Wallet) AddressUnconfirmedTransactions(uh types.UnlockHash) (pts []modules.ProcessedTransaction, err error)
AddressUnconfirmedTransactions returns all of the unconfirmed wallet transactions related to a specific address.
func (*Wallet) AllAddresses ¶
func (w *Wallet) AllAddresses() ([]types.UnlockHash, error)
AllAddresses returns all addresses that the wallet is able to spend from. Addresses are returned sorted in byte-order.
func (*Wallet) BlockStakeStats ¶ added in v0.1.0
func (w *Wallet) BlockStakeStats() (BCcountLast1000 uint64, BCfeeLast1000 types.Currency, BlockCount uint64, err error)
BlockStakeStats returns the blockstake statistical information of this wallet
func (*Wallet) Close ¶
Close terminates all ongoing processes involving the wallet, enabling garbage collection.
func (*Wallet) ConfirmedBalance ¶
func (w *Wallet) ConfirmedBalance() (coinBalance types.Currency, blockstakeBalance types.Currency, err error)
ConfirmedBalance returns the balance of the wallet according to all of the confirmed transactions.
func (*Wallet) ConfirmedLockedBalance ¶ added in v1.0.5
func (w *Wallet) ConfirmedLockedBalance() (coinBalance types.Currency, blockstakeBalance types.Currency, err error)
ConfirmedLockedBalance returns the locked balance of the wallet according to all of the confirmed transactions, which have locked outputs.
func (*Wallet) CreateBackup ¶
CreateBackup creates a backup file at the desired filepath.
func (*Wallet) CreateRawTransaction ¶ added in v1.0.6
func (w *Wallet) CreateRawTransaction(coids []types.CoinOutputID, bsoids []types.BlockStakeOutputID, cos []types.CoinOutput, bsos []types.BlockStakeOutput, arb []byte) (types.Transaction, error)
CreateRawTransaction with the given inputs and outputs
func (*Wallet) Encrypt ¶
func (w *Wallet) Encrypt(masterKey crypto.TwofishKey, primarySeed modules.Seed) (modules.Seed, error)
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.
If no primary seed is given (which is possible if a nil seed is passed as primary seed), a random one will be generated for you.
func (*Wallet) GetKey ¶ added in v0.6.0
func (w *Wallet) GetKey(address types.UnlockHash) (pk types.PublicKey, sk types.ByteSlice, err error)
GetKey gets the pub/priv key pair, which is linked to the given unlock hash (address).
func (*Wallet) GetUnspentBlockStakeOutputs ¶ added in v0.1.0
func (w *Wallet) GetUnspentBlockStakeOutputs() (unspent []types.UnspentBlockStakeOutput, err error)
GetUnspentBlockStakeOutputs returns the blockstake outputs where the beneficiary is an address this wallet has an unlockhash for.
func (*Wallet) GreedySign ¶ added in v1.0.6
func (w *Wallet) GreedySign(txn types.Transaction) (types.Transaction, error)
GreedySign attempts to sign every input in the transaction that can be signed using the keys loaded in this wallet. The transaction is assumed to be valid
func (*Wallet) Init ¶ added in v1.2.0
Init will create the PLAIN wallet using the primary seed, or creating a seed for you if none is given.
Init 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.
NOTE: the seed is stored in a plain text file on the local FS. This is not recommended, unless you are working in an isolated and controlled environment. Please use the Encrypt method instead, in order to create the wallet using a master key, the generated adddresses will be the same either way, but the seed will be encrypted prior to being stored on the local FS.
func (*Wallet) LoadPlainSeed ¶ added in v1.2.0
LoadPlainSeed will track all of the addresses generated by the input seed, reclaiming any funds that were lost due to a deleted/lost file. An error will be returned if the seed has already been integrated with the wallet.
func (*Wallet) LoadSeed ¶
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) Lock ¶
Lock will erase all keys from memory and prevent the wallet from spending coins until it is unlocked.
func (*Wallet) LockedUnspendOutputs ¶ added in v1.0.6
func (w *Wallet) LockedUnspendOutputs() (map[types.CoinOutputID]types.CoinOutput, map[types.BlockStakeOutputID]types.BlockStakeOutput, error)
LockedUnspendOutputs returns all locked coinoutput and blockstakeoutputs
func (*Wallet) MultiSigWallets ¶ added in v1.0.6
func (w *Wallet) MultiSigWallets() ([]modules.MultiSigWallet, error)
MultiSigWallets returns all multisig wallets which contain at least one unlock hash owned by this wallet.
func (*Wallet) NextAddress ¶
func (w *Wallet) NextAddress() (types.UnlockHash, 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 ¶
PrimarySeed returns the decrypted primary seed of the wallet.
func (*Wallet) ProcessConsensusChange ¶
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 ¶
func (w *Wallet) ReceiveUpdatedUnconfirmedTransactions(txns []types.Transaction, _ modules.ConsensusChange) error
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) SendBlockStakes ¶
func (w *Wallet) SendBlockStakes(amount types.Currency, cond types.UnlockConditionProxy) (types.Transaction, error)
SendBlockStakes creates a transaction sending 'amount' to whoever can fulfill the condition. The transaction is submitted to the transaction pool and is also returned.
func (*Wallet) SendCoins ¶ added in v0.1.0
func (w *Wallet) SendCoins(amount types.Currency, cond types.UnlockConditionProxy, data []byte) (types.Transaction, error)
SendCoins creates a transaction sending 'amount' to whoever can fulfill the condition. If data is provided, it is added as arbitrary data to the transaction. The transaction is submitted to the transaction pool and is also returned.
func (*Wallet) SendOutputs ¶ added in v1.0.0
func (w *Wallet) SendOutputs(coinOutputs []types.CoinOutput, blockstakeOutputs []types.BlockStakeOutput, data []byte, refundAddress *types.UnlockHash, reuseRefundAddress bool) (types.Transaction, error)
SendOutputs is a tool for sending coins and block stakes from the wallet, to one or multiple addreses. The transaction is automatically given to the transaction pool, and is also returned to the caller.
func (*Wallet) StartTransaction ¶
func (w *Wallet) StartTransaction() modules.TransactionBuilder
StartTransaction is a convenience function that calls StartTransactionWithVersion with the DefaultTransactionVersion constant.
func (*Wallet) StartTransactionWithVersion ¶ added in v1.0.5
func (w *Wallet) StartTransactionWithVersion(version types.TransactionVersion) modules.TransactionBuilder
StartTransactionWithVersion is a convenience function that calls RegisterTransaction(types.Transaction{Version: version}, nil).
func (*Wallet) Transaction ¶
func (w *Wallet) Transaction(txid types.TransactionID) (modules.ProcessedTransaction, bool, error)
Transaction returns the transaction with the given id. 'False' is returned if the transaction does not exist.
func (*Wallet) Transactions ¶
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 ¶
func (w *Wallet) UnconfirmedBalance() (outgoingCoins types.Currency, incomingCoins types.Currency, err error)
UnconfirmedBalance returns the number of outgoing and incoming coins in the unconfirmed transaction set. Refund outputs are included in this reporting.
func (*Wallet) UnconfirmedTransactions ¶
func (w *Wallet) UnconfirmedTransactions() ([]modules.ProcessedTransaction, error)
UnconfirmedTransactions returns the set of unconfirmed transactions that are relevant to the wallet.
func (*Wallet) Unlock ¶
func (w *Wallet) Unlock(masterKey crypto.TwofishKey) error
Unlock will decrypt the wallet seed and load all of the addresses into memory.
func (*Wallet) UnlockedUnspendOutputs ¶ added in v1.0.6
func (w *Wallet) UnlockedUnspendOutputs() (map[types.CoinOutputID]types.CoinOutput, map[types.BlockStakeOutputID]types.BlockStakeOutput, error)
UnlockedUnspendOutputs returns all unlocked coinoutput and blockstakeoutputs
func (*Wallet) UnspentBlockStakeOutputs ¶ added in v0.1.0
func (w *Wallet) UnspentBlockStakeOutputs() (map[types.BlockStakeOutputID]types.BlockStakeOutput, error)
UnspentBlockStakeOutputs returns the blockstake outputs where the beneficiary is an address this wallet has an unlockhash for.