Documentation ¶
Overview ¶
Package wallet contains types and functions relevant to operating a Sia wallet.
Index ¶
- Constants
- Variables
- func AppendTransactionSignature(txn *types.Transaction, txnSig types.TransactionSignature, ...)
- func CalculateUnlockHash(uc types.UnlockConditions) types.UnlockHash
- func ExitOnError(err error)
- func RelevantTransaction(owner AddressOwner, txn types.Transaction) bool
- func StandardAddress(pk types.SiaPublicKey) types.UnlockHash
- func StandardTransactionSignature(id crypto.Hash) types.TransactionSignature
- func StandardUnlockConditions(pk types.SiaPublicKey) types.UnlockConditions
- func SumOutputs(outputs []UnspentOutput) types.Currency
- type AddressOwner
- type BlockReward
- type BoltDBStore
- func (s *BoltDBStore) AddAddress(info SeedAddressInfo)
- func (s *BoltDBStore) AddToLimbo(txn types.Transaction)
- func (s *BoltDBStore) AddressInfo(addr types.UnlockHash) (info SeedAddressInfo, exists bool)
- func (s *BoltDBStore) Addresses() []types.UnlockHash
- func (s *BoltDBStore) ApplyConsensusChange(reverted, applied ProcessedConsensusChange, ccid modules.ConsensusChangeID)
- func (s *BoltDBStore) BlockRewards(n int) (brs []BlockReward)
- func (s *BoltDBStore) ChainHeight() (height types.BlockHeight)
- func (s *BoltDBStore) Close() error
- func (s *BoltDBStore) ConsensusChangeID() (ccid modules.ConsensusChangeID)
- func (s *BoltDBStore) FileContractHistory(id types.FileContractID) (history []FileContract)
- func (s *BoltDBStore) FileContracts(n int) (fcs []FileContract)
- func (s *BoltDBStore) LimboTransactions() (txns []LimboTransaction)
- func (s *BoltDBStore) Memo(txid types.TransactionID) (memo []byte)
- func (s *BoltDBStore) OwnsAddress(addr types.UnlockHash) (owned bool)
- func (s *BoltDBStore) RemoveAddress(addr types.UnlockHash)
- func (s *BoltDBStore) RemoveFromLimbo(id types.TransactionID)
- func (s *BoltDBStore) Reset() error
- func (s *BoltDBStore) SeedIndex() (index uint64)
- func (s *BoltDBStore) SetMemo(txid types.TransactionID, memo []byte)
- func (s *BoltDBStore) SetSeedIndex(index uint64)
- func (s *BoltDBStore) Transaction(id types.TransactionID) (txn Transaction, exists bool)
- func (s *BoltDBStore) Transactions(n int) (txids []types.TransactionID)
- func (s *BoltDBStore) TransactionsByAddress(addr types.UnlockHash, n int) (txids []types.TransactionID)
- func (s *BoltDBStore) UnspentOutputs() (outputs []UnspentOutput)
- type ChainStore
- type EphemeralStore
- func (s *EphemeralStore) AddAddress(info SeedAddressInfo)
- func (s *EphemeralStore) AddToLimbo(txn types.Transaction)
- func (s *EphemeralStore) AddressInfo(addr types.UnlockHash) (SeedAddressInfo, bool)
- func (s *EphemeralStore) Addresses() []types.UnlockHash
- func (s *EphemeralStore) ApplyConsensusChange(reverted, applied ProcessedConsensusChange, ccid modules.ConsensusChangeID)
- func (s *EphemeralStore) BlockRewards(n int) []BlockReward
- func (s *EphemeralStore) ChainHeight() types.BlockHeight
- func (s *EphemeralStore) ConsensusChangeID() modules.ConsensusChangeID
- func (s *EphemeralStore) FileContractHistory(id types.FileContractID) []FileContract
- func (s *EphemeralStore) FileContracts(n int) []FileContract
- func (s *EphemeralStore) LimboTransactions() []LimboTransaction
- func (s *EphemeralStore) Memo(txid types.TransactionID) []byte
- func (s *EphemeralStore) OwnsAddress(addr types.UnlockHash) bool
- func (s *EphemeralStore) RemoveAddress(addr types.UnlockHash)
- func (s *EphemeralStore) RemoveFromLimbo(id types.TransactionID)
- func (s *EphemeralStore) SeedIndex() uint64
- func (s *EphemeralStore) SetMemo(txid types.TransactionID, memo []byte)
- func (s *EphemeralStore) SetSeedIndex(index uint64)
- func (s *EphemeralStore) Transaction(id types.TransactionID) (Transaction, bool)
- func (s *EphemeralStore) Transactions(n int) []types.TransactionID
- func (s *EphemeralStore) TransactionsByAddress(addr types.UnlockHash, n int) []types.TransactionID
- func (s *EphemeralStore) UnspentOutputs() []UnspentOutput
- type FileContract
- type HotWallet
- type LimboTransaction
- type ProcessedConsensusChange
- type Seed
- type SeedAddressInfo
- type SeedWallet
- func (w *SeedWallet) AddAddress(info SeedAddressInfo)
- func (w *SeedWallet) AddToLimbo(txn types.Transaction)
- func (w *SeedWallet) AddressInfo(addr types.UnlockHash) (SeedAddressInfo, bool)
- func (w *SeedWallet) Addresses() []types.UnlockHash
- func (w *SeedWallet) Balance(limbo bool) types.Currency
- func (w *SeedWallet) BlockRewards(n int) []BlockReward
- func (w *SeedWallet) ChainHeight() types.BlockHeight
- func (w *SeedWallet) ConsensusChangeID() modules.ConsensusChangeID
- func (w *SeedWallet) ConsensusSetSubscriber(store ChainStore) modules.ConsensusSetSubscriber
- func (w *SeedWallet) FileContractHistory(id types.FileContractID) []FileContract
- func (w *SeedWallet) FileContracts(n int) []FileContract
- func (w *SeedWallet) LimboTransactions() []LimboTransaction
- func (w *SeedWallet) Memo(txid types.TransactionID) []byte
- func (w *SeedWallet) OwnsAddress(addr types.UnlockHash) bool
- func (w *SeedWallet) RemoveAddress(addr types.UnlockHash)
- func (w *SeedWallet) RemoveFromLimbo(txid types.TransactionID)
- func (w *SeedWallet) SeedIndex() uint64
- func (w *SeedWallet) SetMemo(txid types.TransactionID, memo []byte)
- func (w *SeedWallet) Transaction(id types.TransactionID) (Transaction, bool)
- func (w *SeedWallet) Transactions(n int) []types.TransactionID
- func (w *SeedWallet) TransactionsByAddress(addr types.UnlockHash, n int) []types.TransactionID
- func (w *SeedWallet) UnspentOutputs(limbo bool) []UnspentOutput
- func (w *SeedWallet) ValuedInputs() []ValuedInput
- type Store
- type Transaction
- type UnspentOutput
- type ValuedInput
Constants ¶
const BytesPerInput = 241
BytesPerInput is the encoded size of a SiacoinInput and corresponding TransactionSignature, assuming standard UnlockConditions.
Variables ¶
var ErrInsufficientFunds = errors.New("insufficient funds")
ErrInsufficientFunds is returned when the wallet does not control enough outputs to fund a transaction.
Functions ¶
func AppendTransactionSignature ¶
func AppendTransactionSignature(txn *types.Transaction, txnSig types.TransactionSignature, key ed25519.PrivateKey)
AppendTransactionSignature appends a TransactionSignature to txn and signs it with key.
func CalculateUnlockHash ¶ added in v0.3.0
func CalculateUnlockHash(uc types.UnlockConditions) types.UnlockHash
CalculateUnlockHash calculates the UnlockHash of a set of UnlockConditions. It calls StandardAddress on "standard" UnlockConditions, falling back to the UnlockHash method otherwise. Since the vast majority of UnlockConditions are standard, this results in faster average computation.
func ExitOnError ¶
func ExitOnError(err error)
ExitOnError prints err to stderr and exits with code 1.
func RelevantTransaction ¶ added in v0.16.2
func RelevantTransaction(owner AddressOwner, txn types.Transaction) bool
RelevantTransaction returns true if txn is relevant to owner.
func StandardAddress ¶
func StandardAddress(pk types.SiaPublicKey) types.UnlockHash
StandardAddress returns the UnlockHash of a set of StandardUnlockConditions.
func StandardTransactionSignature ¶
func StandardTransactionSignature(id crypto.Hash) types.TransactionSignature
StandardTransactionSignature is the most common form of TransactionSignature. It covers the entire transaction and references the first (typically the only) public key.
func StandardUnlockConditions ¶
func StandardUnlockConditions(pk types.SiaPublicKey) types.UnlockConditions
StandardUnlockConditions are the unlock conditions for a standard address: one public key, no timelock.
func SumOutputs ¶
func SumOutputs(outputs []UnspentOutput) types.Currency
SumOutputs returns the total value of the supplied outputs.
Types ¶
type AddressOwner ¶
type AddressOwner interface {
OwnsAddress(addr types.UnlockHash) bool
}
An AddressOwner claims ownership of addresses.
type BlockReward ¶ added in v0.3.0
type BlockReward struct { UnspentOutput Timelock types.BlockHeight }
A BlockReward is a timelocked output awarded to the miner of a block.
func (BlockReward) MarshalSia ¶ added in v0.3.0
func (br BlockReward) MarshalSia(w io.Writer) error
MarshalSia implements encoding.SiaMarshaler.
func (*BlockReward) UnmarshalSia ¶ added in v0.3.0
func (br *BlockReward) UnmarshalSia(r io.Reader) error
UnmarshalSia implements encoding.SiaUnmarshaler.
type BoltDBStore ¶
type BoltDBStore struct {
// contains filtered or unexported fields
}
BoltDBStore implements Store with a Bolt key-value database.
func NewBoltDBStore ¶
func NewBoltDBStore(filename string, onErr func(error)) (*BoltDBStore, error)
NewBoltDBStore returns a new BoltDBStore. If onErr is nil, ExitOnError will be used.
func (*BoltDBStore) AddAddress ¶
func (s *BoltDBStore) AddAddress(info SeedAddressInfo)
AddAddress implements Store.
func (*BoltDBStore) AddToLimbo ¶ added in v0.3.0
func (s *BoltDBStore) AddToLimbo(txn types.Transaction)
AddToLimbo implements Store.
func (*BoltDBStore) AddressInfo ¶
func (s *BoltDBStore) AddressInfo(addr types.UnlockHash) (info SeedAddressInfo, exists bool)
AddressInfo implements Store.
func (*BoltDBStore) Addresses ¶
func (s *BoltDBStore) Addresses() []types.UnlockHash
Addresses implements Store.
func (*BoltDBStore) ApplyConsensusChange ¶
func (s *BoltDBStore) ApplyConsensusChange(reverted, applied ProcessedConsensusChange, ccid modules.ConsensusChangeID)
ApplyConsensusChange implements Store.
func (*BoltDBStore) BlockRewards ¶ added in v0.3.0
func (s *BoltDBStore) BlockRewards(n int) (brs []BlockReward)
BlockRewards implements Store.
func (*BoltDBStore) ChainHeight ¶
func (s *BoltDBStore) ChainHeight() (height types.BlockHeight)
ChainHeight implements Store.
func (*BoltDBStore) ConsensusChangeID ¶
func (s *BoltDBStore) ConsensusChangeID() (ccid modules.ConsensusChangeID)
ConsensusChangeID implements Store.
func (*BoltDBStore) FileContractHistory ¶ added in v0.3.0
func (s *BoltDBStore) FileContractHistory(id types.FileContractID) (history []FileContract)
FileContractHistory implements Store.
func (*BoltDBStore) FileContracts ¶ added in v0.3.0
func (s *BoltDBStore) FileContracts(n int) (fcs []FileContract)
FileContracts implements Store.
func (*BoltDBStore) LimboTransactions ¶ added in v0.3.0
func (s *BoltDBStore) LimboTransactions() (txns []LimboTransaction)
LimboTransactions implements Store.
func (*BoltDBStore) Memo ¶
func (s *BoltDBStore) Memo(txid types.TransactionID) (memo []byte)
Memo implements Store.
func (*BoltDBStore) OwnsAddress ¶
func (s *BoltDBStore) OwnsAddress(addr types.UnlockHash) (owned bool)
OwnsAddress implements Store.
func (*BoltDBStore) RemoveAddress ¶
func (s *BoltDBStore) RemoveAddress(addr types.UnlockHash)
RemoveAddress implements Store.
func (*BoltDBStore) RemoveFromLimbo ¶ added in v0.3.0
func (s *BoltDBStore) RemoveFromLimbo(id types.TransactionID)
RemoveFromLimbo implements Store.
func (*BoltDBStore) Reset ¶
func (s *BoltDBStore) Reset() error
Reset wipes the store's knowledge of the blockchain, including transactions, outputs, height, and consensus change ID. Addresses, memos, and the current seed index are preserved.
func (*BoltDBStore) SeedIndex ¶
func (s *BoltDBStore) SeedIndex() (index uint64)
SeedIndex implements Store.
func (*BoltDBStore) SetMemo ¶
func (s *BoltDBStore) SetMemo(txid types.TransactionID, memo []byte)
SetMemo implements Store.
func (*BoltDBStore) SetSeedIndex ¶
func (s *BoltDBStore) SetSeedIndex(index uint64)
SetSeedIndex implements Store.
func (*BoltDBStore) Transaction ¶
func (s *BoltDBStore) Transaction(id types.TransactionID) (txn Transaction, exists bool)
Transaction implements Store.
func (*BoltDBStore) Transactions ¶
func (s *BoltDBStore) Transactions(n int) (txids []types.TransactionID)
Transactions implements Store.
func (*BoltDBStore) TransactionsByAddress ¶
func (s *BoltDBStore) TransactionsByAddress(addr types.UnlockHash, n int) (txids []types.TransactionID)
TransactionsByAddress implements Store.
func (*BoltDBStore) UnspentOutputs ¶
func (s *BoltDBStore) UnspentOutputs() (outputs []UnspentOutput)
UnspentOutputs implements Store.
type ChainStore ¶
type ChainStore interface {
ApplyConsensusChange(reverted, applied ProcessedConsensusChange, id modules.ConsensusChangeID)
}
A ChainStore stores ProcessedConsensusChanges.
type EphemeralStore ¶
type EphemeralStore struct {
// contains filtered or unexported fields
}
EphemeralStore implements Store in-memory.
func NewEphemeralStore ¶
func NewEphemeralStore() *EphemeralStore
NewEphemeralStore returns a new EphemeralStore.
func (*EphemeralStore) AddAddress ¶ added in v0.7.0
func (s *EphemeralStore) AddAddress(info SeedAddressInfo)
AddAddress implements Store.
func (*EphemeralStore) AddToLimbo ¶ added in v0.3.0
func (s *EphemeralStore) AddToLimbo(txn types.Transaction)
AddToLimbo implements Store.
func (*EphemeralStore) AddressInfo ¶ added in v0.7.0
func (s *EphemeralStore) AddressInfo(addr types.UnlockHash) (SeedAddressInfo, bool)
AddressInfo implements Store.
func (*EphemeralStore) Addresses ¶ added in v0.7.0
func (s *EphemeralStore) Addresses() []types.UnlockHash
Addresses implements Store.
func (*EphemeralStore) ApplyConsensusChange ¶
func (s *EphemeralStore) ApplyConsensusChange(reverted, applied ProcessedConsensusChange, ccid modules.ConsensusChangeID)
ApplyConsensusChange implements ChainStore.
func (*EphemeralStore) BlockRewards ¶ added in v0.3.0
func (s *EphemeralStore) BlockRewards(n int) []BlockReward
BlockRewards implements Store.
func (*EphemeralStore) ChainHeight ¶
func (s *EphemeralStore) ChainHeight() types.BlockHeight
ChainHeight implements Store.
func (*EphemeralStore) ConsensusChangeID ¶
func (s *EphemeralStore) ConsensusChangeID() modules.ConsensusChangeID
ConsensusChangeID implements Store.
func (*EphemeralStore) FileContractHistory ¶ added in v0.3.0
func (s *EphemeralStore) FileContractHistory(id types.FileContractID) []FileContract
FileContractHistory implements Store.
func (*EphemeralStore) FileContracts ¶ added in v0.3.0
func (s *EphemeralStore) FileContracts(n int) []FileContract
FileContracts implements Store.
func (*EphemeralStore) LimboTransactions ¶ added in v0.3.0
func (s *EphemeralStore) LimboTransactions() []LimboTransaction
LimboTransactions implements Store.
func (*EphemeralStore) Memo ¶
func (s *EphemeralStore) Memo(txid types.TransactionID) []byte
Memo implements Store.
func (*EphemeralStore) OwnsAddress ¶ added in v0.7.0
func (s *EphemeralStore) OwnsAddress(addr types.UnlockHash) bool
OwnsAddress implements Store.
func (*EphemeralStore) RemoveAddress ¶ added in v0.7.0
func (s *EphemeralStore) RemoveAddress(addr types.UnlockHash)
RemoveAddress implements Store.
func (*EphemeralStore) RemoveFromLimbo ¶ added in v0.3.0
func (s *EphemeralStore) RemoveFromLimbo(id types.TransactionID)
RemoveFromLimbo implements Store.
func (*EphemeralStore) SeedIndex ¶ added in v0.7.0
func (s *EphemeralStore) SeedIndex() uint64
SeedIndex implements Store.
func (*EphemeralStore) SetMemo ¶
func (s *EphemeralStore) SetMemo(txid types.TransactionID, memo []byte)
SetMemo implements Store.
func (*EphemeralStore) SetSeedIndex ¶ added in v0.7.0
func (s *EphemeralStore) SetSeedIndex(index uint64)
SetSeedIndex implements Store.
func (*EphemeralStore) Transaction ¶
func (s *EphemeralStore) Transaction(id types.TransactionID) (Transaction, bool)
Transaction implements Store.
func (*EphemeralStore) Transactions ¶
func (s *EphemeralStore) Transactions(n int) []types.TransactionID
Transactions implements Store.
func (*EphemeralStore) TransactionsByAddress ¶
func (s *EphemeralStore) TransactionsByAddress(addr types.UnlockHash, n int) []types.TransactionID
TransactionsByAddress implements Store.
func (*EphemeralStore) UnspentOutputs ¶
func (s *EphemeralStore) UnspentOutputs() []UnspentOutput
UnspentOutputs implements Store.
type FileContract ¶ added in v0.3.0
type FileContract struct { types.FileContract UnlockConditions types.UnlockConditions ID types.FileContractID }
A FileContract is an initial or revised file contract.
func (FileContract) MarshalSia ¶ added in v0.3.0
func (fc FileContract) MarshalSia(w io.Writer) error
MarshalSia implements encoding.SiaMarshaler.
func (*FileContract) UnmarshalSia ¶ added in v0.3.0
func (fc *FileContract) UnmarshalSia(r io.Reader) error
UnmarshalSia implements encoding.SiaUnmarshaler.
type HotWallet ¶ added in v0.7.0
type HotWallet struct { *SeedWallet // contains filtered or unexported fields }
A HotWallet pairs a SeedWallet with a Seed, providing a more convenient API for generating addresses and signing transactions.
func NewHotWallet ¶ added in v0.7.0
func NewHotWallet(sw *SeedWallet, seed Seed) *HotWallet
NewHotWallet intializes a HotWallet using the provided wallet and seed.
func (*HotWallet) Address ¶ added in v0.18.1
func (w *HotWallet) Address() (types.UnlockHash, error)
Address returns a new (unused) address derived from the wallet's seed.
func (*HotWallet) FundTransaction ¶ added in v0.18.1
func (w *HotWallet) FundTransaction(txn *types.Transaction, amount types.Currency) ([]crypto.Hash, func(), error)
FundTransaction adds inputs to txn worth at least amount, adding a change output if needed. It returns the added input IDs, for use with SignTransaction. It also returns a function that will "unclaim" the inputs; this function must be called once the transaction has been broadcast or discarded.
func (*HotWallet) SignTransaction ¶ added in v0.7.0
SignTransaction signs the specified transaction using keys derived from the wallet seed. If toSign is nil, SignTransaction will automatically add TransactionSignatures for each input owned by the seed. If toSign is not nil, it a list of indices of TransactionSignatures already present in txn; SignTransaction will fill in the Signature field of each.
type LimboTransaction ¶ added in v0.3.0
type LimboTransaction struct { types.Transaction LimboSince time.Time }
A LimboTransaction is a transaction that has been broadcast, but has not appeared in a block.
func UnconfirmedParents ¶
func UnconfirmedParents(txn types.Transaction, limbo []LimboTransaction) []LimboTransaction
UnconfirmedParents returns the parents of txn that are in limbo.
func (LimboTransaction) MarshalSia ¶ added in v0.3.0
func (txn LimboTransaction) MarshalSia(w io.Writer) error
MarshalSia implements encoding.SiaMarshaler.
func (*LimboTransaction) UnmarshalSia ¶ added in v0.3.0
func (txn *LimboTransaction) UnmarshalSia(r io.Reader) error
UnmarshalSia implements encoding.SiaUnmarshaler.
type ProcessedConsensusChange ¶
type ProcessedConsensusChange struct { Outputs []UnspentOutput Transactions []Transaction AddressTransactions map[types.UnlockHash][]types.TransactionID BlockRewards []BlockReward FileContracts []FileContract BlockCount int }
A ProcessedConsensusChange is a condensation of a modules.ConsensusChange, containing only the data relevant to certain addresses, and intended to be processed by an atomic unit.
func FilterConsensusChange ¶ added in v0.7.0
func FilterConsensusChange(cc modules.ConsensusChange, owner AddressOwner, currentHeight types.BlockHeight) (reverted, applied ProcessedConsensusChange, ccid modules.ConsensusChangeID)
FilterConsensusChange extracts the information in cc relevant to the specified AddressOwner. Relevance is determined as follows: an output is relevant if its UnlockHash is owned by the AddressOwner; a transaction is relevant if any of the UnlockHashes or UnlockConditions appearing in it are owned by the AddressOwner.
type Seed ¶
type Seed struct {
// contains filtered or unexported fields
}
A Seed generates addresses deterministically from some initial entropy.
Seeds consist of 128 bits of entropy, and are represented to the user as a 12-word BIP39 mnemonic seed phrase. Internally, this entropy is hashed into a siad-compatible seed before it is used to derive keys. This means that Seeds can be imported into a siad wallet. (The reverse, however, is not possible.)
func SeedFromEntropy ¶
SeedFromEntropy returns the Seed derived from the supplied entropy.
func SeedFromPhrase ¶
SeedFromPhrase returns the Seed derived from the supplied phrase.
func (Seed) PublicKey ¶
func (s Seed) PublicKey(index uint64) types.SiaPublicKey
PublicKey derives the types.SiaPublicKey for the specified index.
func (Seed) SecretKey ¶
func (s Seed) SecretKey(index uint64) ed25519.PrivateKey
SecretKey derives the ed25519 private key for the specified index.
type SeedAddressInfo ¶
type SeedAddressInfo struct { UnlockConditions types.UnlockConditions `json:"unlockConditions"` KeyIndex uint64 `json:"keyIndex"` }
A SeedAddressInfo contains the unlock conditions and key index for an address derived from a seed.
func (SeedAddressInfo) MarshalJSON ¶
func (info SeedAddressInfo) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (SeedAddressInfo) UnlockHash ¶ added in v0.7.0
func (info SeedAddressInfo) UnlockHash() types.UnlockHash
UnlockHash is a convenience method that returns the address derived from info's UnlockConditions.
type SeedWallet ¶
type SeedWallet struct {
// contains filtered or unexported fields
}
A SeedWallet tracks outputs and transactions relevant to a set of seed-derived addresses. It does not control the seed itself (or any private keys), and therefore cannot sign transactions.
func New ¶ added in v0.7.0
func New(store Store) *SeedWallet
New intializes a SeedWallet using the provided store.
func (*SeedWallet) AddAddress ¶ added in v0.7.0
func (w *SeedWallet) AddAddress(info SeedAddressInfo)
AddAddress adds an address to the wallet.
func (*SeedWallet) AddToLimbo ¶ added in v0.3.0
func (w *SeedWallet) AddToLimbo(txn types.Transaction)
AddToLimbo stores a transaction in Limbo. If the transaction is already in Limbo, its LimboSince timestamp is not updated.
func (*SeedWallet) AddressInfo ¶
func (w *SeedWallet) AddressInfo(addr types.UnlockHash) (SeedAddressInfo, bool)
AddressInfo returns the metadata associated with the specified address.
func (*SeedWallet) Addresses ¶
func (w *SeedWallet) Addresses() []types.UnlockHash
Addresses returns the set of addresses tracked by the wallet.
func (*SeedWallet) Balance ¶
func (w *SeedWallet) Balance(limbo bool) types.Currency
Balance returns the siacoin balance of the wallet. If the limbo flag is true, the balance reflects any transactions currently in Limbo.
func (*SeedWallet) BlockRewards ¶ added in v0.3.0
func (w *SeedWallet) BlockRewards(n int) []BlockReward
BlockRewards returns the block rewards tracked by the wallet.
func (*SeedWallet) ChainHeight ¶
func (w *SeedWallet) ChainHeight() types.BlockHeight
ChainHeight returns the number of blocks processed by the wallet.
func (*SeedWallet) ConsensusChangeID ¶
func (w *SeedWallet) ConsensusChangeID() modules.ConsensusChangeID
ConsensusChangeID returns the ConsensusChangeID most recently processed by the wallet.
func (*SeedWallet) ConsensusSetSubscriber ¶ added in v0.6.0
func (w *SeedWallet) ConsensusSetSubscriber(store ChainStore) modules.ConsensusSetSubscriber
ConsensusSetSubscriber returns a modules.ConsensusSetSubscriber for w using the provided ChainStore.
func (*SeedWallet) FileContractHistory ¶ added in v0.3.0
func (w *SeedWallet) FileContractHistory(id types.FileContractID) []FileContract
FileContractHistory returns the set of revisions made to the specified contract.
func (*SeedWallet) FileContracts ¶ added in v0.3.0
func (w *SeedWallet) FileContracts(n int) []FileContract
FileContracts returns the file contracts tracked by the wallet.
func (*SeedWallet) LimboTransactions ¶ added in v0.3.0
func (w *SeedWallet) LimboTransactions() []LimboTransaction
LimboTransactions returns the transactions that have been broadcast, but have not appeared in the blockchain.
func (*SeedWallet) Memo ¶
func (w *SeedWallet) Memo(txid types.TransactionID) []byte
Memo returns the memo associated with the specified transaction.
func (*SeedWallet) OwnsAddress ¶
func (w *SeedWallet) OwnsAddress(addr types.UnlockHash) bool
OwnsAddress reports whether addr is being tracked by the wallet.
func (*SeedWallet) RemoveAddress ¶ added in v0.7.0
func (w *SeedWallet) RemoveAddress(addr types.UnlockHash)
RemoveAddress removes an address from the wallet.
func (*SeedWallet) RemoveFromLimbo ¶ added in v0.3.0
func (w *SeedWallet) RemoveFromLimbo(txid types.TransactionID)
RemoveFromLimbo removes a transaction from Limbo.
func (*SeedWallet) SeedIndex ¶
func (w *SeedWallet) SeedIndex() uint64
SeedIndex returns the lowest seed index whose associated address is not tracked by the wallet; in other words, the index that should be used to generate a new address.
func (*SeedWallet) SetMemo ¶
func (w *SeedWallet) SetMemo(txid types.TransactionID, memo []byte)
SetMemo sets the memo associated with the specified transaction.
func (*SeedWallet) Transaction ¶
func (w *SeedWallet) Transaction(id types.TransactionID) (Transaction, bool)
Transaction returns the transaction with the specified id. The transaction must be relevant to the wallet.
func (*SeedWallet) Transactions ¶
func (w *SeedWallet) Transactions(n int) []types.TransactionID
Transactions returns the IDs of the n most recent transactions in the blockchain that are relevant to the wallet, or fewer if less than n such transactions exist. If n < 0, all such transactions are returned. The IDs are ordered from oldest to newest.
func (*SeedWallet) TransactionsByAddress ¶
func (w *SeedWallet) TransactionsByAddress(addr types.UnlockHash, n int) []types.TransactionID
TransactionsByAddress returns the IDs of the n most recent transactions in the blockchain that are relevant to the specified wallet-owned address, or fewer if less than n such transactions exist. If n < 0, all such transactions are returned. The IDs are ordered from oldest to newest.
func (*SeedWallet) UnspentOutputs ¶ added in v0.3.0
func (w *SeedWallet) UnspentOutputs(limbo bool) []UnspentOutput
UnspentOutputs returns the spendable outputs tracked by the wallet. If the limbo flag is true, the outputs reflect any transactions currently in Limbo.
func (*SeedWallet) ValuedInputs ¶
func (w *SeedWallet) ValuedInputs() []ValuedInput
ValuedInputs returns the spendable outputs tracked by the wallet along with their UnlockConditions, for immediate use as inputs.
type Store ¶
type Store interface { AddressOwner Addresses() []types.UnlockHash AddAddress(info SeedAddressInfo) AddressInfo(addr types.UnlockHash) (SeedAddressInfo, bool) RemoveAddress(addr types.UnlockHash) BlockRewards(n int) []BlockReward ConsensusChangeID() modules.ConsensusChangeID ChainHeight() types.BlockHeight FileContracts(n int) []FileContract FileContractHistory(id types.FileContractID) []FileContract LimboTransactions() []LimboTransaction AddToLimbo(txn types.Transaction) RemoveFromLimbo(id types.TransactionID) Memo(txid types.TransactionID) []byte SetMemo(txid types.TransactionID, memo []byte) SeedIndex() uint64 SetSeedIndex(index uint64) Transaction(id types.TransactionID) (Transaction, bool) Transactions(n int) []types.TransactionID TransactionsByAddress(addr types.UnlockHash, n int) []types.TransactionID UnspentOutputs() []UnspentOutput }
A Store stores information needed by a wallet.
type Transaction ¶ added in v0.8.0
type Transaction struct { types.Transaction BlockID types.BlockID BlockHeight types.BlockHeight Timestamp time.Time FeePerByte types.Currency InputValues []types.Currency }
A Transaction is an on-chain transaction with additional metadata.
func (Transaction) MarshalSia ¶ added in v0.8.0
func (txn Transaction) MarshalSia(w io.Writer) error
MarshalSia implements encoding.SiaMarshaler.
func (*Transaction) UnmarshalSia ¶ added in v0.8.0
func (txn *Transaction) UnmarshalSia(r io.Reader) error
UnmarshalSia implements encoding.SiaUnmarshaler.
type UnspentOutput ¶
type UnspentOutput struct { types.SiacoinOutput ID types.SiacoinOutputID }
An UnspentOutput is a SiacoinOutput along with its ID.
func CalculateLimboOutputs ¶ added in v0.3.0
func CalculateLimboOutputs(owner AddressOwner, limbo []LimboTransaction, outputs []UnspentOutput) []UnspentOutput
CalculateLimboOutputs returns the outputs the owner would control if all transactions in limbo were applied.
func DistributeFunds ¶ added in v0.16.1
func DistributeFunds(inputs []UnspentOutput, n int, per, feePerByte types.Currency) (ins []UnspentOutput, fee, change types.Currency)
DistributeFunds is a helper function for distributing the value in a set of inputs among n outputs, each containing per siacoins. It returns the minimal set of inputs that will fund such a transaction, along with the resulting fee and change. Inputs with value equal to per are ignored. If the inputs are not sufficient to fund n outputs, DistributeFunds returns nil.
func (UnspentOutput) MarshalSia ¶
func (o UnspentOutput) MarshalSia(w io.Writer) error
MarshalSia implements encoding.SiaMarshaler.
func (*UnspentOutput) UnmarshalSia ¶
func (o *UnspentOutput) UnmarshalSia(r io.Reader) error
UnmarshalSia implements encoding.SiaUnmarshaler.
type ValuedInput ¶
type ValuedInput struct { types.SiacoinInput Value types.Currency }
A ValuedInput is a SiacoinInput along with its value. Seen another way, it is an UnspentOutput that knows its UnlockConditions.
func FundAtLeast ¶
func FundAtLeast(amount types.Currency, inputs []ValuedInput) (used []ValuedInput, change types.Currency, ok bool)
FundAtLeast selects a set of inputs whose total value is at least amount, returning the selected inputs and the resulting change, or false if the sum of all inputs is less than amount.
func FundTransaction ¶
func FundTransaction(amount, feePerByte types.Currency, inputs []ValuedInput) (used []ValuedInput, fee, change types.Currency, ok bool)
FundTransaction selects a set of inputs whose total value is amount+fee, where fee is the estimated fee required to pay for the inputs and their signatures.
func (ValuedInput) MarshalSia ¶
func (i ValuedInput) MarshalSia(w io.Writer) error
MarshalSia implements encoding.SiaMarshaler.
func (*ValuedInput) UnmarshalSia ¶
func (i *ValuedInput) UnmarshalSia(r io.Reader) error
UnmarshalSia implements encoding.SiaUnmarshaler.