Documentation
¶
Index ¶
- Constants
- Variables
- func ExplicitCoveredFields(txn types.Transaction) (cf types.CoveredFields)
- func KeyFromPhrase(phrase string) (types.PrivateKey, error)
- func NewSeedPhrase() string
- func StandardAddress(pk types.PublicKey) types.Address
- func StandardTransactionSignature(id types.Hash256) types.TransactionSignature
- func StandardUnlockConditions(pk types.PublicKey) types.UnlockConditions
- func SumOutputs(outputs []SiacoinElement) (sum types.Currency)
- type SiacoinElement
- type SingleAddressStore
- type SingleAddressWallet
- func (w *SingleAddressWallet) Address() types.Address
- func (w *SingleAddressWallet) Balance() (spendable, confirmed, unconfirmed types.Currency, _ error)
- func (w *SingleAddressWallet) FundTransaction(cs consensus.State, txn *types.Transaction, amount types.Currency, ...) ([]types.Hash256, error)
- func (w *SingleAddressWallet) Height() uint64
- func (w *SingleAddressWallet) PrivateKey() types.PrivateKey
- func (w *SingleAddressWallet) ProcessConsensusChange(cc modules.ConsensusChange)
- func (w *SingleAddressWallet) ReceiveUpdatedUnconfirmedTransactions(diff *modules.TransactionPoolDiff)
- func (w *SingleAddressWallet) Redistribute(cs consensus.State, outputs int, amount, feePerByte types.Currency, ...) ([]types.Transaction, []types.Hash256, error)
- func (w *SingleAddressWallet) ReleaseInputs(txns ...types.Transaction)
- func (w *SingleAddressWallet) SignTransaction(cs consensus.State, txn *types.Transaction, toSign []types.Hash256, ...) error
- func (w *SingleAddressWallet) Transactions(before, since time.Time, offset, limit int) ([]Transaction, error)
- func (w *SingleAddressWallet) UnspentOutputs() ([]SiacoinElement, error)
- type Transaction
- type TransactionPool
Constants ¶
const ( // BytesPerInput is the encoded size of a SiacoinInput and corresponding // TransactionSignature, assuming standard UnlockConditions. BytesPerInput = 241 )
Variables ¶
var ErrInsufficientBalance = errors.New("insufficient balance")
ErrInsufficientBalance is returned when there aren't enough unused outputs to cover the requested amount.
Functions ¶
func ExplicitCoveredFields ¶
func ExplicitCoveredFields(txn types.Transaction) (cf types.CoveredFields)
ExplicitCoveredFields returns a CoveredFields that covers all elements present in txn.
func KeyFromPhrase ¶
func KeyFromPhrase(phrase string) (types.PrivateKey, error)
KeyFromPhrase returns the Ed25519 key derived from the supplied seed phrase.
func StandardAddress ¶
StandardAddress returns the standard address for an Ed25519 key.
func StandardTransactionSignature ¶
func StandardTransactionSignature(id types.Hash256) types.TransactionSignature
StandardTransactionSignature returns the standard signature object for a siacoin or siafund input.
func StandardUnlockConditions ¶
func StandardUnlockConditions(pk types.PublicKey) types.UnlockConditions
StandardUnlockConditions returns the standard unlock conditions for a single Ed25519 key.
func SumOutputs ¶
func SumOutputs(outputs []SiacoinElement) (sum types.Currency)
SumOutputs returns the total value of the supplied outputs.
Types ¶
type SiacoinElement ¶
type SiacoinElement struct { types.SiacoinOutput ID types.Hash256 `json:"id"` MaturityHeight uint64 `json:"maturityHeight"` }
A SiacoinElement is a SiacoinOutput along with its ID.
type SingleAddressStore ¶
type SingleAddressStore interface { Height() uint64 UnspentSiacoinElements(matured bool) ([]SiacoinElement, error) Transactions(before, since time.Time, offset, limit int) ([]Transaction, error) RecordWalletMetric(ctx context.Context, metrics ...api.WalletMetric) error }
A SingleAddressStore stores the state of a single-address wallet. Implementations are assumed to be thread safe.
type SingleAddressWallet ¶
type SingleAddressWallet struct {
// contains filtered or unexported fields
}
A SingleAddressWallet is a hot wallet that manages the outputs controlled by a single address.
func NewSingleAddressWallet ¶
func NewSingleAddressWallet(priv types.PrivateKey, store SingleAddressStore, usedUTXOExpiry time.Duration, log *zap.SugaredLogger) *SingleAddressWallet
NewSingleAddressWallet returns a new SingleAddressWallet using the provided private key and store.
func (*SingleAddressWallet) Address ¶
func (w *SingleAddressWallet) Address() types.Address
Address returns the address of the wallet.
func (*SingleAddressWallet) Balance ¶
func (w *SingleAddressWallet) Balance() (spendable, confirmed, unconfirmed types.Currency, _ error)
Balance returns the balance of the wallet.
func (*SingleAddressWallet) FundTransaction ¶
func (w *SingleAddressWallet) FundTransaction(cs consensus.State, txn *types.Transaction, amount types.Currency, useUnconfirmedTxns bool) ([]types.Hash256, error)
FundTransaction adds siacoin inputs worth at least the requested amount to the provided transaction. A change output is also added, if necessary. The inputs will not be available to future calls to FundTransaction unless ReleaseInputs is called or enough time has passed.
func (*SingleAddressWallet) Height ¶
func (w *SingleAddressWallet) Height() uint64
func (*SingleAddressWallet) PrivateKey ¶
func (w *SingleAddressWallet) PrivateKey() types.PrivateKey
PrivateKey returns the private key of the wallet.
func (*SingleAddressWallet) ProcessConsensusChange ¶ added in v0.7.0
func (w *SingleAddressWallet) ProcessConsensusChange(cc modules.ConsensusChange)
ProcessConsensusChange implements modules.ConsensusSetSubscriber.
func (*SingleAddressWallet) ReceiveUpdatedUnconfirmedTransactions ¶
func (w *SingleAddressWallet) ReceiveUpdatedUnconfirmedTransactions(diff *modules.TransactionPoolDiff)
ReceiveUpdatedUnconfirmedTransactions implements modules.TransactionPoolSubscriber.
func (*SingleAddressWallet) Redistribute ¶
func (w *SingleAddressWallet) Redistribute(cs consensus.State, outputs int, amount, feePerByte types.Currency, pool []types.Transaction) ([]types.Transaction, []types.Hash256, error)
Redistribute returns a transaction that redistributes money in the wallet by selecting a minimal set of inputs to cover the creation of the requested outputs. It also returns a list of output IDs that need to be signed.
func (*SingleAddressWallet) ReleaseInputs ¶
func (w *SingleAddressWallet) ReleaseInputs(txns ...types.Transaction)
ReleaseInputs is a helper function that releases the inputs of txn for use in other transactions. It should only be called on transactions that are invalid or will never be broadcast.
func (*SingleAddressWallet) SignTransaction ¶
func (w *SingleAddressWallet) SignTransaction(cs consensus.State, txn *types.Transaction, toSign []types.Hash256, cf types.CoveredFields) error
SignTransaction adds a signature to each of the specified inputs.
func (*SingleAddressWallet) Transactions ¶
func (w *SingleAddressWallet) Transactions(before, since time.Time, offset, limit int) ([]Transaction, error)
Transactions returns up to max transactions relevant to the wallet that have a timestamp later than since.
func (*SingleAddressWallet) UnspentOutputs ¶
func (w *SingleAddressWallet) UnspentOutputs() ([]SiacoinElement, error)
UnspentOutputs returns the set of unspent Siacoin outputs controlled by the wallet.
type Transaction ¶
type Transaction struct { Raw types.Transaction `json:"raw,omitempty"` Index types.ChainIndex `json:"index"` ID types.TransactionID `json:"id"` Inflow types.Currency `json:"inflow"` Outflow types.Currency `json:"outflow"` Timestamp time.Time `json:"timestamp"` }
A Transaction is an on-chain transaction relevant to a particular wallet, paired with useful metadata.
type TransactionPool ¶
A TransactionPool contains transactions that have not yet been included in a block.