Documentation ¶
Index ¶
- Constants
- func AppendTransactionSignature(txn *types.Transaction, txnSig types.TransactionSignature, ...)
- func CalculateUnlockHash(uc types.UnlockConditions) types.UnlockHash
- func ExitOnError(err error)
- 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(addr types.UnlockHash, info []byte)
- func (s *BoltDBStore) AddToLimbo(txn types.Transaction)
- func (s *BoltDBStore) AddressInfo(addr types.UnlockHash) (info []byte)
- 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 types.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 ChainScanner
- type ChainStore
- type EphemeralSeedStore
- type EphemeralStore
- func (s *EphemeralStore) AddToLimbo(txn types.Transaction)
- 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) RemoveFromLimbo(id types.TransactionID)
- func (s *EphemeralStore) SetMemo(txid types.TransactionID, memo []byte)
- func (s *EphemeralStore) Transaction(id types.TransactionID) (types.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 EphemeralWatchOnlyStore
- func (s *EphemeralWatchOnlyStore) AddAddress(addr types.UnlockHash, info []byte)
- func (s *EphemeralWatchOnlyStore) AddressInfo(addr types.UnlockHash) (info []byte)
- func (s *EphemeralWatchOnlyStore) Addresses() []types.UnlockHash
- func (s *EphemeralWatchOnlyStore) OwnsAddress(addr types.UnlockHash) bool
- func (s *EphemeralWatchOnlyStore) RemoveAddress(addr types.UnlockHash)
- type FileContract
- type LimboTransaction
- type ProcessedConsensusChange
- type Seed
- type SeedAddressInfo
- type SeedManager
- func (sm *SeedManager) AddressIndex(addr types.UnlockHash) (uint64, bool)
- func (sm *SeedManager) Addresses() []types.UnlockHash
- func (sm *SeedManager) CurrentIndex() uint64
- func (sm *SeedManager) NextAddress() types.UnlockHash
- func (sm *SeedManager) OwnsAddress(addr types.UnlockHash) bool
- func (sm *SeedManager) SecretKey(addr types.UnlockHash) (ed25519.PrivateKey, bool)
- func (sm *SeedManager) SignTransaction(txn *types.Transaction, toSign []int) error
- func (sm *SeedManager) UnlockConditions(addr types.UnlockHash) (types.UnlockConditions, bool)
- type SeedStore
- type SeedWallet
- 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) 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) NextAddress() types.UnlockHash
- func (w *SeedWallet) OwnsAddress(addr types.UnlockHash) bool
- func (w *SeedWallet) ProcessConsensusChange(cc modules.ConsensusChange)
- func (w *SeedWallet) RemoveFromLimbo(txid types.TransactionID)
- func (w *SeedWallet) SeedIndex() uint64
- func (w *SeedWallet) SetMemo(txid types.TransactionID, memo []byte)
- func (w *SeedWallet) SignTransaction(txn *types.Transaction, toSign []int) error
- func (w *SeedWallet) Transaction(id types.TransactionID) (types.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 UnspentOutput
- type ValuedInput
- type WatchOnlyStore
- type WatchOnlyWallet
- func (w *WatchOnlyWallet) AddAddress(addr types.UnlockHash, info []byte)
- func (w *WatchOnlyWallet) AddToLimbo(txn types.Transaction)
- func (w *WatchOnlyWallet) AddressInfo(addr types.UnlockHash) (info []byte)
- func (w *WatchOnlyWallet) Addresses() []types.UnlockHash
- func (w *WatchOnlyWallet) Balance(limbo bool) types.Currency
- func (w *WatchOnlyWallet) BlockRewards(n int) []BlockReward
- func (w *WatchOnlyWallet) ChainHeight() types.BlockHeight
- func (w *WatchOnlyWallet) ConsensusChangeID() modules.ConsensusChangeID
- func (w *WatchOnlyWallet) FileContractHistory(id types.FileContractID) []FileContract
- func (w *WatchOnlyWallet) FileContracts(n int) []FileContract
- func (w *WatchOnlyWallet) LimboTransactions() []LimboTransaction
- func (w *WatchOnlyWallet) Memo(txid types.TransactionID) []byte
- func (w *WatchOnlyWallet) OwnsAddress(addr types.UnlockHash) bool
- func (w *WatchOnlyWallet) ProcessConsensusChange(cc modules.ConsensusChange)
- func (w *WatchOnlyWallet) RemoveAddress(addr types.UnlockHash)
- func (w *WatchOnlyWallet) RemoveFromLimbo(txid types.TransactionID)
- func (w *WatchOnlyWallet) SetMemo(txid types.TransactionID, memo []byte)
- func (w *WatchOnlyWallet) Transaction(id types.TransactionID) (types.Transaction, bool)
- func (w *WatchOnlyWallet) Transactions(n int) []types.TransactionID
- func (w *WatchOnlyWallet) TransactionsByAddress(addr types.UnlockHash, n int) []types.TransactionID
- func (w *WatchOnlyWallet) UnspentOutputs(limbo bool) []UnspentOutput
Constants ¶
const BytesPerInput = 241
BytesPerInput is the encoded size of a SiacoinInput and corresponding TransactionSignature, assuming standard UnlockConditions.
Variables ¶
This section is empty.
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 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 SeedStore and WatchOnlyStore 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(addr types.UnlockHash, info []byte)
AddAddress implements WatchOnlyStore.
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 []byte)
AddressInfo implements WatchOnlyStore.
func (*BoltDBStore) Addresses ¶
func (s *BoltDBStore) Addresses() []types.UnlockHash
Addresses implements WatchOnlyStore.
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 WatchOnlyStore.
func (*BoltDBStore) RemoveAddress ¶
func (s *BoltDBStore) RemoveAddress(addr types.UnlockHash)
RemoveAddress implements WatchOnlyStore.
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 SeedStore.
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 SeedStore.
func (*BoltDBStore) Transaction ¶
func (s *BoltDBStore) Transaction(id types.TransactionID) (txn types.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 ChainScanner ¶
type ChainScanner struct { Owner AddressOwner Store ChainStore }
A ChainScanner scans the blockchain for outputs and transactions relevant to Owner and stores them in Store. 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.
func (ChainScanner) ProcessConsensusChange ¶
func (cs ChainScanner) ProcessConsensusChange(cc modules.ConsensusChange)
ProcessConsensusChange implements modules.ConsensusSetSubscriber.
type ChainStore ¶
type ChainStore interface {
ApplyConsensusChange(reverted, applied ProcessedConsensusChange, id modules.ConsensusChangeID)
}
A ChainStore stores ProcessedConsensusChanges.
type EphemeralSeedStore ¶
type EphemeralSeedStore struct { EphemeralStore // contains filtered or unexported fields }
EphemeralSeedStore implements SeedStore in-memory.
func NewEphemeralSeedStore ¶
func NewEphemeralSeedStore() *EphemeralSeedStore
NewEphemeralSeedStore returns a new EphemeralSeedStore.
func (*EphemeralSeedStore) SeedIndex ¶
func (s *EphemeralSeedStore) SeedIndex() uint64
SeedIndex implements SeedStore.
func (*EphemeralSeedStore) SetSeedIndex ¶
func (s *EphemeralSeedStore) SetSeedIndex(index uint64)
SetSeedIndex implements SeedStore.
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) AddToLimbo ¶ added in v0.3.0
func (s *EphemeralStore) AddToLimbo(txn types.Transaction)
AddToLimbo implements Store.
func (*EphemeralStore) ApplyConsensusChange ¶
func (s *EphemeralStore) ApplyConsensusChange(reverted, applied ProcessedConsensusChange, ccid modules.ConsensusChangeID)
ApplyConsensusChange implements Store.
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) RemoveFromLimbo ¶ added in v0.3.0
func (s *EphemeralStore) RemoveFromLimbo(id types.TransactionID)
RemoveFromLimbo implements Store.
func (*EphemeralStore) SetMemo ¶
func (s *EphemeralStore) SetMemo(txid types.TransactionID, memo []byte)
SetMemo implements Store.
func (*EphemeralStore) Transaction ¶
func (s *EphemeralStore) Transaction(id types.TransactionID) (types.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 EphemeralWatchOnlyStore ¶
type EphemeralWatchOnlyStore struct { EphemeralStore // contains filtered or unexported fields }
EphemeralWatchOnlyStore implements WatchOnlyStore in-memory.
func NewEphemeralWatchOnlyStore ¶
func NewEphemeralWatchOnlyStore() *EphemeralWatchOnlyStore
NewEphemeralWatchOnlyStore returns a new EphemeralWatchOnlyStore.
func (*EphemeralWatchOnlyStore) AddAddress ¶
func (s *EphemeralWatchOnlyStore) AddAddress(addr types.UnlockHash, info []byte)
AddAddress implements WatchOnlyStore.
func (*EphemeralWatchOnlyStore) AddressInfo ¶
func (s *EphemeralWatchOnlyStore) AddressInfo(addr types.UnlockHash) (info []byte)
AddressInfo implements WatchOnlyStore.
func (*EphemeralWatchOnlyStore) Addresses ¶
func (s *EphemeralWatchOnlyStore) Addresses() []types.UnlockHash
Addresses implements WatchOnlyStore.
func (*EphemeralWatchOnlyStore) OwnsAddress ¶
func (s *EphemeralWatchOnlyStore) OwnsAddress(addr types.UnlockHash) bool
OwnsAddress implements WatchOnlyStore.
func (*EphemeralWatchOnlyStore) RemoveAddress ¶
func (s *EphemeralWatchOnlyStore) RemoveAddress(addr types.UnlockHash)
RemoveAddress implements WatchOnlyStore.
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 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 []types.Transaction AddressTransactions map[types.UnlockHash][]types.TransactionID BlockRewards []BlockReward FileContracts []FileContract BlockCount int CCID modules.ConsensusChangeID }
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.
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.
type SeedManager ¶
type SeedManager struct {
// contains filtered or unexported fields
}
A SeedManager tracks the addresses derived from a Seed, and provides the UnlockConditions for the addresses it has generated.
func NewSeedManager ¶
func NewSeedManager(seed Seed, maxUseIndex uint64) *SeedManager
NewSeedManager initializes a SeedManager using the provided seed and maxUseIndex, which is the number of keys previously derived from the Seed. Those keys must be re-derived before NewSeedManager returns, so NewSeedManager may take a while for large values of maxUseIndex.
func (*SeedManager) AddressIndex ¶
func (sm *SeedManager) AddressIndex(addr types.UnlockHash) (uint64, bool)
AddressIndex returns the key index, or false if the address is not known to the SeedManager.
func (*SeedManager) Addresses ¶
func (sm *SeedManager) Addresses() []types.UnlockHash
Addresses returns all addresses generated by the SeedManager.
func (*SeedManager) CurrentIndex ¶
func (sm *SeedManager) CurrentIndex() uint64
CurrentIndex returns the index that will be used to derive the next address.
func (*SeedManager) NextAddress ¶
func (sm *SeedManager) NextAddress() types.UnlockHash
NextAddress returns a new address derived from the SeedManager's Seed.
func (*SeedManager) OwnsAddress ¶
func (sm *SeedManager) OwnsAddress(addr types.UnlockHash) bool
OwnsAddress implements AddressOwner.
func (*SeedManager) SecretKey ¶
func (sm *SeedManager) SecretKey(addr types.UnlockHash) (ed25519.PrivateKey, bool)
SecretKey returns the ed25519 private key associated with the specified address, or false if the address is not known to the SeedManager.
func (*SeedManager) SignTransaction ¶
func (sm *SeedManager) SignTransaction(txn *types.Transaction, toSign []int) error
SignTransaction signs the specified transaction using keys owned by the SeedManager. If toSign is nil, SignTransaction will automatically add TransactionSignatures for each input owned by the SeedManager. 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.
func (*SeedManager) UnlockConditions ¶
func (sm *SeedManager) UnlockConditions(addr types.UnlockHash) (types.UnlockConditions, bool)
UnlockConditions returns the UnlockConditions associated with the specified address, or false if the address is not known to the SeedManager.
type SeedWallet ¶
type SeedWallet struct {
// contains filtered or unexported fields
}
A SeedWallet is a seed-based wallet that can track spendable outputs and sign transactions. It is safe for concurrent use.
SeedWallets can only handle siacoins, not siafunds.
func NewSeedWallet ¶
func NewSeedWallet(sm *SeedManager, store SeedStore) *SeedWallet
NewSeedWallet intializes a SeedWallet using the provided seed and store.
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 all addresses generated by the SeedManager.
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) 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) NextAddress ¶
func (w *SeedWallet) NextAddress() types.UnlockHash
NextAddress returns a new address derived from the wallet's Seed and updates the wallet's SeedIndex.
func (*SeedWallet) OwnsAddress ¶
func (w *SeedWallet) OwnsAddress(addr types.UnlockHash) bool
OwnsAddress reports whether addr was generated from the wallet's seed.
func (*SeedWallet) ProcessConsensusChange ¶
func (w *SeedWallet) ProcessConsensusChange(cc modules.ConsensusChange)
ProcessConsensusChange implements modules.ConsensusSetSubscriber.
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 index that will be used to derive the next address.
func (*SeedWallet) SetMemo ¶
func (w *SeedWallet) SetMemo(txid types.TransactionID, memo []byte)
SetMemo sets the memo associated with the specified transaction.
func (*SeedWallet) SignTransaction ¶
func (w *SeedWallet) SignTransaction(txn *types.Transaction, toSign []int) error
SignTransaction signs the specified transaction using keys owned by the wallet. If toSign is nil, SignTransaction will automatically add TransactionSignatures for each input owned by the SeedManager. 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.
func (*SeedWallet) Transaction ¶
func (w *SeedWallet) Transaction(id types.TransactionID) (types.Transaction, bool)
Transaction returns the transaction with the specified id. The transaction must be relevant to the SeedWallet.
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 SeedWallet, 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 { ChainStore 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) Transaction(id types.TransactionID) (types.Transaction, bool) Transactions(n int) []types.TransactionID TransactionsByAddress(addr types.UnlockHash, n int) []types.TransactionID UnspentOutputs() []UnspentOutput }
A Store stores information needed by a generic wallet.
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 (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.
type WatchOnlyStore ¶
type WatchOnlyStore interface { Store AddressOwner Addresses() []types.UnlockHash AddAddress(addr types.UnlockHash, info []byte) AddressInfo(addr types.UnlockHash) []byte RemoveAddress(addr types.UnlockHash) }
A WatchOnlyStore stores information needed by a WatchOnlyWallet. For convenience, it also implements AddressOwner.
type WatchOnlyWallet ¶
type WatchOnlyWallet struct {
// contains filtered or unexported fields
}
A WatchOnlyWallet is an unprivileged wallet that can track spendable outputs, but cannot sign transactions. It is safe for concurrent use.
func NewWatchOnlyWallet ¶
func NewWatchOnlyWallet(store WatchOnlyStore) *WatchOnlyWallet
NewWatchOnlyWallet intializes a WatchOnlyWallet using the provided store.
func (*WatchOnlyWallet) AddAddress ¶
func (w *WatchOnlyWallet) AddAddress(addr types.UnlockHash, info []byte)
AddAddress adds an address to the wallet.
func (*WatchOnlyWallet) AddToLimbo ¶ added in v0.3.0
func (w *WatchOnlyWallet) AddToLimbo(txn types.Transaction)
AddToLimbo stores a transaction in Limbo. If the transaction is already in Limbo, its LimboSince timestamp is not updated.
func (*WatchOnlyWallet) AddressInfo ¶
func (w *WatchOnlyWallet) AddressInfo(addr types.UnlockHash) (info []byte)
AddressInfo returns the metadata associated with the specified address.
func (*WatchOnlyWallet) Addresses ¶
func (w *WatchOnlyWallet) Addresses() []types.UnlockHash
Addresses returns the set of addresses tracked by the wallet.
func (*WatchOnlyWallet) Balance ¶
func (w *WatchOnlyWallet) 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 (*WatchOnlyWallet) BlockRewards ¶ added in v0.3.0
func (w *WatchOnlyWallet) BlockRewards(n int) []BlockReward
BlockRewards returns the block rewards tracked by the wallet.
func (*WatchOnlyWallet) ChainHeight ¶
func (w *WatchOnlyWallet) ChainHeight() types.BlockHeight
ChainHeight returns the number of blocks processed by the wallet.
func (*WatchOnlyWallet) ConsensusChangeID ¶
func (w *WatchOnlyWallet) ConsensusChangeID() modules.ConsensusChangeID
ConsensusChangeID returns the ConsensusChangeID most recently processed by the wallet.
func (*WatchOnlyWallet) FileContractHistory ¶ added in v0.3.0
func (w *WatchOnlyWallet) FileContractHistory(id types.FileContractID) []FileContract
FileContractHistory returns the set of revisions made to the specified contract.
func (*WatchOnlyWallet) FileContracts ¶ added in v0.3.0
func (w *WatchOnlyWallet) FileContracts(n int) []FileContract
FileContracts returns the file contracts tracked by the wallet.
func (*WatchOnlyWallet) LimboTransactions ¶ added in v0.3.0
func (w *WatchOnlyWallet) LimboTransactions() []LimboTransaction
LimboTransactions returns the transactions that have been broadcast, but have not appeared in the blockchain.
func (*WatchOnlyWallet) Memo ¶
func (w *WatchOnlyWallet) Memo(txid types.TransactionID) []byte
Memo returns the memo associated with the specified transaction.
func (*WatchOnlyWallet) OwnsAddress ¶
func (w *WatchOnlyWallet) OwnsAddress(addr types.UnlockHash) bool
OwnsAddress reports whether addr is being tracked by the wallet.
func (*WatchOnlyWallet) ProcessConsensusChange ¶
func (w *WatchOnlyWallet) ProcessConsensusChange(cc modules.ConsensusChange)
ProcessConsensusChange implements modules.ConsensusSetSubscriber.
func (*WatchOnlyWallet) RemoveAddress ¶
func (w *WatchOnlyWallet) RemoveAddress(addr types.UnlockHash)
RemoveAddress removes an address from the wallet.
func (*WatchOnlyWallet) RemoveFromLimbo ¶ added in v0.3.0
func (w *WatchOnlyWallet) RemoveFromLimbo(txid types.TransactionID)
RemoveFromLimbo removes a transaction from Limbo.
func (*WatchOnlyWallet) SetMemo ¶
func (w *WatchOnlyWallet) SetMemo(txid types.TransactionID, memo []byte)
SetMemo sets the memo associated with the specified transaction.
func (*WatchOnlyWallet) Transaction ¶
func (w *WatchOnlyWallet) Transaction(id types.TransactionID) (types.Transaction, bool)
Transaction returns the transaction with the specified id. The transaction must be relevant to the wallet.
func (*WatchOnlyWallet) Transactions ¶
func (w *WatchOnlyWallet) 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 (*WatchOnlyWallet) TransactionsByAddress ¶
func (w *WatchOnlyWallet) 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 (*WatchOnlyWallet) UnspentOutputs ¶
func (w *WatchOnlyWallet) 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.