wtxmgr

package
v0.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2017 License: ISC Imports: 17 Imported by: 0

README

wtxmgr

Package wtxmgr provides storage and spend tracking of wallet transactions and their relevant input and outputs.

Feature overview

  • Storage for relevant wallet transactions
  • Ability to mark outputs as controlled by wallet
  • Unspent transaction output index
  • Balance tracking
  • Automatic spend tracking for transaction inserts and removals
  • Double spend detection and correction after blockchain reorgs
  • Scalable design:
    • Utilizes similar prefixes to allow cursor iteration over relevant transaction inputs and outputs
    • Programmatically detectable errors, including encapsulation of errors from packages it relies on
    • Operates under its own walletdb namespace

Documentation

[GoDoc] (http://godoc.org/github.com/decred/dcrwallet/wtxmgr)

Full go doc style documentation for the project can be viewed online without installing this package by using the GoDoc site here: http://godoc.org/github.com/decred/dcrwallet/wtxmgr

You can also view the documentation locally once the package is installed with the godoc tool by running godoc -http=":6060" and pointing your browser to http://localhost:6060/pkg/github.com/decred/dcrwallet/wtxmgr

Installation

$ go get github.com/decred/dcrwallet/wtxmgr

Package wtxmgr is licensed under the copyfree ISC License.

Documentation

Overview

Package wtxmgr provides an implementation of a transaction database handling spend tracking for a decred wallet. Its primary purpose is to save transactions with outputs spendable with wallet keys and transactions that are signed by wallet keys in memory, handle spend tracking for unspent outputs and newly-inserted transactions, and report the spendable balance from each unspent transaction output. It uses walletdb as the backend for storing the serialized transaction objects in buckets.

Transaction outputs which are spendable by wallet keys are called credits (because they credit to a wallet's total spendable balance). Transaction inputs which spend previously-inserted credits are called debits (because they debit from the wallet's spendable balance).

Spend tracking is mostly automatic. When a new transaction is inserted, if it spends from any unspent credits, they are automatically marked spent by the new transaction, and each input which spent a credit is marked as a debit. However, transaction outputs of inserted transactions must manually marked as credits, as this package has no knowledge of wallet keys or addresses, and therefore cannot determine which outputs may be spent.

Details regarding individual transactions and their credits and debits may be queried either by just a transaction hash, or by hash and block. When querying for just a transaction hash, the most recent transaction with a matching hash will be queried. However, because transaction hashes may collide with other transaction hashes, methods to query for specific transactions in the chain (or unmined) are provided as well.

Index

Constants

View Source
const (

	// LatestVersion is the most recent database version.
	LatestVersion = dbVersion3
)

Database versions. Versions start at 1 and increment for each database change.

Variables

This section is empty.

Functions

func Create

func Create(ns walletdb.ReadWriteBucket, chainParams *chaincfg.Params) error

Create creates a new persistent transaction store in the walletdb namespace. Creating the store when one already exists in this namespace will error with ErrAlreadyExists.

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func DoUpgrades added in v0.5.0

func DoUpgrades(db walletdb.DB, namespaceKey []byte, chainParams *chaincfg.Params) error

DoUpgrades performs any necessary upgrades to the transaction history contained in the wallet database, namespaced by the top level bucket key namespaceKey.

func ExtractBlockHeaderHeight added in v0.6.0

func ExtractBlockHeaderHeight(header []byte) int32

ExtractBlockHeaderHeight returns the height field that is encoded in the header. Must only be called on known good input.

TODO: This really should not be exported by this package.

func ExtractBlockHeaderParentHash added in v0.6.0

func ExtractBlockHeaderParentHash(header []byte) []byte

ExtractBlockHeaderParentHash subslices the header to return the bytes of the parent block's hash. Must only be called on known good input.

TODO: This really should not be exported by this package.

func IsError added in v0.7.0

func IsError(err error, code ErrorCode) bool

IsError returns whether err is an Error with a matching error code.

func IsNoExists

func IsNoExists(err error) bool

IsNoExists returns whether an error is a Error with the ErrNoExists error code.

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

Types

type Balances

type Balances struct {
	Account                 uint32
	ImmatureCoinbaseRewards dcrutil.Amount
	ImmatureStakeGeneration dcrutil.Amount
	LockedByTickets         dcrutil.Amount
	Spendable               dcrutil.Amount
	Total                   dcrutil.Amount
	VotingAuthority         dcrutil.Amount
}

Balances is an convenience type.

type BehaviorFlags

type BehaviorFlags uint32

BehaviorFlags is a bitmask defining tweaks to the normal behavior when performing chain processing and consensus rules checks.

const (
	OP_NONSTAKE = txscript.OP_NOP10

	BFBalanceAll BehaviorFlags = iota
	BFBalanceLockedStake
	BFBalanceSpendable
	BFBalanceFullScan
)

type Block

type Block struct {
	Hash   chainhash.Hash
	Height int32
}

Block contains the minimum amount of data to uniquely identify any block on either the best or side chain.

type BlockHeaderData added in v0.6.0

type BlockHeaderData struct {
	BlockHash        chainhash.Hash
	SerializedHeader RawBlockHeader
}

BlockHeaderData contains the block hashes and serialized blocks headers that are inserted into the database. At time of writing this only supports wire protocol version 0 blocks and changes will need to be made if the block header size changes.

type BlockMeta

type BlockMeta struct {
	Block
	Time     time.Time
	VoteBits uint16
}

BlockMeta contains the unique identification for a block and any metadata pertaining to the block. At the moment, this additional metadata only includes the block time from the block header.

type ByOutpoint

type ByOutpoint []*unspentDebugData

ByOutpoint defines the methods needed to satisify sort.Interface to sort a slice of Utxos by their outpoint.

func (ByOutpoint) Len

func (u ByOutpoint) Len() int

func (ByOutpoint) Less

func (u ByOutpoint) Less(i, j int) bool

func (ByOutpoint) Swap

func (u ByOutpoint) Swap(i, j int)

type ByUtxoAmount

type ByUtxoAmount []*minimalCredit

ByUtxoAmount defines the methods needed to satisify sort.Interface to sort a slice of Utxos by their amount.

func (ByUtxoAmount) Len

func (u ByUtxoAmount) Len() int

func (ByUtxoAmount) Less

func (u ByUtxoAmount) Less(i, j int) bool

func (ByUtxoAmount) Swap

func (u ByUtxoAmount) Swap(i, j int)

type Credit

type Credit struct {
	wire.OutPoint
	BlockMeta
	Amount       dcrutil.Amount
	PkScript     []byte
	Received     time.Time
	FromCoinBase bool
}

Credit is the type representing a transaction output which was spent or is still spendable by wallet. A UTXO is an unspent Credit, but not all Credits are UTXOs.

type CreditRecord

type CreditRecord struct {
	Index      uint32
	Amount     dcrutil.Amount
	Spent      bool
	Change     bool
	OpCode     uint8
	IsCoinbase bool
}

CreditRecord contains metadata regarding a transaction credit for a known transaction. Further details may be looked up by indexing a wire.MsgTx.TxOut with the Index field.

type DebitRecord

type DebitRecord struct {
	Amount dcrutil.Amount
	Index  uint32
}

DebitRecord contains metadata regarding a transaction debit for a known transaction. Further details may be looked up by indexing a wire.MsgTx.TxIn with the Index field.

type Error

type Error struct {
	Code ErrorCode // Describes the kind of error
	Desc string    // Human readable description of the issue
	Err  error     // Underlying error, optional
}

Error provides a single type for errors that can happen during Store operation.

func (Error) Error

func (e Error) Error() string

Error satisfies the error interface and prints human-readable errors.

type ErrorCode

type ErrorCode uint8

ErrorCode identifies a category of error.

const (
	// ErrDatabase indicates an error with the underlying database.  When
	// this error code is set, the Err field of the Error will be
	// set to the underlying error returned from the database.
	ErrDatabase ErrorCode = iota

	// ErrData describes an error where data stored in the transaction
	// database is incorrect.  This may be due to missing values, values of
	// wrong sizes, or data from different buckets that is inconsistent with
	// itself.  Recovering from an ErrData requires rebuilding all
	// transaction history or manual database surgery.  If the failure was
	// not due to data corruption, this error category indicates a
	// programming error in this package.
	ErrData

	// ErrInput describes an error where the variables passed into this
	// function by the caller are obviously incorrect.  Examples include
	// passing transactions which do not serialize, or attempting to insert
	// a credit at an index for which no transaction output exists.
	ErrInput

	// ErrAlreadyExists describes an error where creating the store cannot
	// continue because a store already exists in the namespace.
	ErrAlreadyExists

	// ErrNoExists describes an error where the store cannot be opened due to
	// it not already existing in the namespace.  This error should be
	// handled by creating a new store.
	ErrNoExists

	// ErrValueNoExists describes an error indicating that the value for
	// a given key does not exist in the database queried.
	ErrValueNoExists

	// ErrDoubleSpend indicates that an output was attempted to be spent
	// twice.
	ErrDoubleSpend

	// ErrNeedsUpgrade describes an error during store opening where the
	// database contains an older version of the store.
	ErrNeedsUpgrade

	// ErrUnknownVersion describes an error where the store already exists
	// but the database version is newer than latest version known to this
	// software.  This likely indicates an outdated binary.
	ErrUnknownVersion

	// ErrIsClosed indicates that the transaction manager is closed.
	ErrIsClosed

	// ErrDuplicate describes an error inserting an item into the store due to
	// the data already existing.
	//
	// This error code is a late addition to the API and at the moment only a
	// select number of APIs use it.  Methods that might return this error
	// documents the behavior in a doc comment.
	ErrDuplicate
)

These constants are used to identify a specific Error.

func (ErrorCode) String

func (e ErrorCode) String() string

String returns the ErrorCode as a human-readable name.

type InputSource

type InputSource struct {
	// contains filtered or unexported fields
}

InputSource provides a method (SelectInputs) to incrementally select unspent outputs to use as transaction inputs.

func (*InputSource) SelectInputs

func (s *InputSource) SelectInputs(target dcrutil.Amount) (dcrutil.Amount, []*wire.TxIn, [][]byte, error)

SelectInputs selects transaction inputs to redeem unspent outputs stored in the database. It may be called multiple times with increasing target amounts to return additional inputs for a higher target amount. It returns the total input amount referenced by the previous transaction outputs, a slice of transaction inputs referencing these outputs, and a slice of previous output scripts from each previous output referenced by the corresponding input.

type MultisigCredit

type MultisigCredit struct {
	OutPoint   *wire.OutPoint
	ScriptHash [ripemd160.Size]byte
	MSScript   []byte
	M          uint8
	N          uint8
	Amount     dcrutil.Amount
}

MultisigCredit is a redeemable P2SH multisignature credit.

type MultisigOut

type MultisigOut struct {
	OutPoint     *wire.OutPoint
	Tree         int8
	ScriptHash   [ripemd160.Size]byte
	M            uint8
	N            uint8
	TxHash       chainhash.Hash
	BlockHash    chainhash.Hash
	BlockHeight  uint32
	Amount       dcrutil.Amount
	Spent        bool
	SpentBy      chainhash.Hash
	SpentByIndex uint32
}

MultisigOut represents a spendable multisignature outpoint contain a script hash.

type RawBlockHeader added in v0.6.0

type RawBlockHeader [180]byte

RawBlockHeader is a 180 byte block header (always true for version 0 blocks).

func (*RawBlockHeader) Height added in v0.6.0

func (h *RawBlockHeader) Height() int32

Height extracts the height encoded in a block header.

type SortableTxRecords

type SortableTxRecords []*TxRecord

SortableTxRecords is a list of transaction records that can be sorted.

func (SortableTxRecords) Len

func (p SortableTxRecords) Len() int

func (SortableTxRecords) Less

func (p SortableTxRecords) Less(i, j int) bool

func (SortableTxRecords) Swap

func (p SortableTxRecords) Swap(i, j int)

type Store

type Store struct {

	// Event callbacks.  These execute in the same goroutine as the wtxmgr
	// caller.
	NotifyUnspent func(hash *chainhash.Hash, index uint32)
	// contains filtered or unexported fields
}

Store implements a transaction store for storing and managing wallet transactions.

func Open

func Open(ns walletdb.ReadBucket, chainParams *chaincfg.Params,
	acctLookupFunc func(walletdb.ReadBucket, dcrutil.Address) (uint32, error)) (*Store, error)

Open opens the wallet transaction store from a walletdb namespace. If the store does not exist, ErrNoExist is returned.

func (*Store) AccountBalance added in v0.8.0

func (s *Store) AccountBalance(ns, addrmgrNs walletdb.ReadBucket, minConf int32,
	account uint32) (Balances, error)

AccountBalance returns a Balances struct for some given account at syncHeight block height with all UTXOS that have minConf manyn confirms.

func (*Store) AccountBalances

func (s *Store) AccountBalances(ns, addrmgrNs walletdb.ReadBucket,
	minConf int32) (map[uint32]*Balances, error)

AccountBalances returns a map of all account balances at syncHeight block height with all UTXOs that have minConf many confirms.

func (*Store) AddCredit

func (s *Store) AddCredit(ns walletdb.ReadWriteBucket, rec *TxRecord, block *BlockMeta,
	index uint32, change bool, account uint32) error

AddCredit marks a transaction record as containing a transaction output spendable by wallet. The output is added unspent, and is marked spent when a new transaction spending the output is inserted into the store.

TODO(jrick): This should not be necessary. Instead, pass the indexes that are known to contain credits when a transaction or merkleblock is inserted into the store.

func (*Store) AddMultisigOut

func (s *Store) AddMultisigOut(ns walletdb.ReadWriteBucket, rec *TxRecord, block *BlockMeta,
	index uint32) error

AddMultisigOut adds a P2SH multisignature spendable output into the transaction manager. In the event that the output already existed but was not mined, the output is updated so its value reflects the block it was included in.

func (*Store) BlockLocators added in v0.6.0

func (s *Store) BlockLocators(ns walletdb.ReadBucket) []chainhash.Hash

BlockLocators returns, in reversed order (newest blocks first), hashes of blocks believed to be on the main chain. For memory and lookup efficiency, many older hashes are skipped, with increasing gaps between included hashes. This returns the block locators that should be included in a getheaders wire message or RPC request.

func (*Store) DebugBucketUnspentString

func (s *Store) DebugBucketUnspentString(ns walletdb.ReadBucket, inclUnmined bool) (string, error)

DebugBucketUnspentString is the exported version of debugBuckedUnspentString It returns string versions of unspent outpoints for debug ussage (with a flag for including unmined txes or not).

func (*Store) ExistsTx

func (s *Store) ExistsTx(ns walletdb.ReadBucket, txHash *chainhash.Hash) bool

ExistsTx checks to see if a transaction exists in the database.

func (*Store) ExtendMainChain added in v0.6.0

func (s *Store) ExtendMainChain(ns walletdb.ReadWriteBucket, header *BlockHeaderData) error

ExtendMainChain inserts a block header into the database. It must connect to the existing tip block.

If the block is already inserted and part of the main chain, an error with code ErrDuplicate is returned.

func (*Store) GetBlockHash

func (s *Store) GetBlockHash(ns walletdb.ReadBucket, height int32) (chainhash.Hash, error)

GetBlockHash fetches the block hash for the block at the given height, and returns an error if it's missing.

func (*Store) GetBlockMetaForHash added in v0.6.0

func (s *Store) GetBlockMetaForHash(ns walletdb.ReadBucket, blockHash *chainhash.Hash) (BlockMeta, error)

GetBlockMetaForHash returns the BlockMeta for a block specified by its hash.

TODO: This is legacy code now that headers are saved. BlockMeta can be removed.

func (*Store) GetMainChainBlockHashForHeight added in v0.6.0

func (s *Store) GetMainChainBlockHashForHeight(ns walletdb.ReadBucket, height int32) (chainhash.Hash, error)

GetMainChainBlockHashForHeight returns the block hash of the block on the main chain at a given height.

func (*Store) GetMainChainBlockHashes added in v0.6.0

func (s *Store) GetMainChainBlockHashes(ns walletdb.ReadBucket, startHash *chainhash.Hash,
	inclusive bool, storage []chainhash.Hash) ([]chainhash.Hash, error)

GetMainChainBlockHashes returns block hashes from the main chain, starting at startHash, copying as many as possible into the storage slice and returning a subslice for the total number of results. If the start hash is not in the main chain, this function errors. If inclusive is true, the startHash is included in the results, otherwise only blocks after the startHash are included.

func (*Store) GetMultisigCredit

func (s *Store) GetMultisigCredit(ns walletdb.ReadBucket, op *wire.OutPoint) (*MultisigCredit, error)

GetMultisigCredit takes an outpoint and returns multisignature credit data stored about it.

func (*Store) GetMultisigOutput

func (s *Store) GetMultisigOutput(ns walletdb.ReadBucket, op *wire.OutPoint) (*MultisigOut, error)

GetMultisigOutput takes an outpoint and returns multisignature credit data stored about it.

func (*Store) GetSerializedBlockHeader added in v0.6.0

func (s *Store) GetSerializedBlockHeader(ns walletdb.ReadBucket, blockHash *chainhash.Hash) ([]byte, error)

GetSerializedBlockHeader returns the bytes of the serialized header for the block specified by its hash. These bytes are a copy of the value returned from the DB and are usable outside of the transaction.

func (*Store) GetTxScript

func (s *Store) GetTxScript(ns walletdb.ReadBucket, hash []byte) ([]byte, error)

GetTxScript is the exported version of getTxScript.

func (*Store) InsertMainChainHeaders added in v0.6.0

func (s *Store) InsertMainChainHeaders(ns walletdb.ReadWriteBucket, addrmgrNs walletdb.ReadBucket,
	headers []BlockHeaderData) error

InsertMainChainHeaders permanently saves block headers. Headers should be in order of increasing heights and there should not be any gaps between blocks. After inserting headers, if the existing recorded tip block is behind the last main chain block header that was inserted, a chain switch occurs and the new tip block is recorded.

func (*Store) InsertMemPoolTx added in v0.6.0

func (s *Store) InsertMemPoolTx(ns walletdb.ReadWriteBucket, rec *TxRecord) error

InsertMemPoolTx inserts a memory pool transaction record. It also marks previous outputs referenced by its inputs as spent.

func (*Store) InsertMinedTx added in v0.6.0

func (s *Store) InsertMinedTx(ns walletdb.ReadWriteBucket, addrmgrNs walletdb.ReadBucket, rec *TxRecord,
	blockHash *chainhash.Hash) error

InsertMinedTx inserts a new transaction record for a mined transaction into the database. The block header must have been previously saved. It is expected that the exact transation does not already exist in the unmined buckets, but unmined double spends (including mutations) are removed.

func (*Store) InsertTxScript

func (s *Store) InsertTxScript(ns walletdb.ReadWriteBucket, script []byte) error

InsertTxScript is the exported version of insertTxScript.

func (*Store) MainChainTip added in v0.6.0

func (s *Store) MainChainTip(ns walletdb.ReadBucket) (chainhash.Hash, int32)

MainChainTip returns the hash and height of the currently marked tip-most block of the main chain.

func (*Store) MakeInputSource

func (s *Store) MakeInputSource(ns, addrmgrNs walletdb.ReadBucket, account uint32, minConf, syncHeight int32) InputSource

MakeInputSource creates an InputSource to redeem unspent outputs from an account. The minConf and syncHeight parameters are used to filter outputs based on some spendable policy.

func (*Store) PreviousPkScripts

func (s *Store) PreviousPkScripts(ns walletdb.ReadBucket, rec *TxRecord, block *Block) ([][]byte, error)

PreviousPkScripts returns a slice of previous output scripts for each credit output this transaction record debits from.

func (*Store) PruneOldTickets added in v0.5.0

func (s *Store) PruneOldTickets(ns walletdb.ReadWriteBucket) error

PruneOldTickets prunes old stake tickets from before ticketCutoff from the database.

func (*Store) PruneUnconfirmed

func (s *Store) PruneUnconfirmed(ns walletdb.ReadWriteBucket, height int32, stakeDiff int64) error

PruneUnconfirmed prunes old stake tickets that are below the current stake difficulty or any unconfirmed transaction which is expired.

func (*Store) RangeTransactions

func (s *Store) RangeTransactions(ns walletdb.ReadBucket, begin, end int32,
	f func([]TxDetails) (bool, error)) error

RangeTransactions runs the function f on all transaction details between blocks on the best chain over the height range [begin,end]. The special height -1 may be used to also include unmined transactions. If the end height comes before the begin height, blocks are iterated in reverse order and unmined transactions (if any) are processed first.

The function f may return an error which, if non-nil, is propagated to the caller. Additionally, a boolean return value allows exiting the function early without reading any additional transactions early when true.

All calls to f are guaranteed to be passed a slice with more than zero elements. The slice may be reused for multiple blocks, so it is not safe to use it after the loop iteration it was acquired.

func (*Store) Rollback

func (s *Store) Rollback(ns walletdb.ReadWriteBucket, addrmgrNs walletdb.ReadBucket, height int32) error

Rollback removes all blocks at height onwards, moving any transactions within each block to the unconfirmed pool.

func (*Store) SpendMultisigOut

func (s *Store) SpendMultisigOut(ns walletdb.ReadWriteBucket, op *wire.OutPoint,
	spendHash chainhash.Hash, spendIndex uint32) error

SpendMultisigOut spends a multisignature output by making it spent in the general bucket and removing it from the unspent bucket.

func (*Store) StoredTxScripts

func (s *Store) StoredTxScripts(ns walletdb.ReadBucket) ([][]byte, error)

StoredTxScripts is the exported version of storedTxScripts.

func (*Store) Tx

func (s *Store) Tx(ns walletdb.ReadBucket, txHash *chainhash.Hash) (*wire.MsgTx, error)

Tx looks up all the stored wire.MsgTx for a transaction with some hash. In case of a hash collision, the most recent transaction with a matching hash is returned.

Not finding a transaction with this hash is not an error. In this case, a nil TxDetails is returned.

func (*Store) TxDetails

func (s *Store) TxDetails(ns walletdb.ReadBucket, txHash *chainhash.Hash) (*TxDetails, error)

TxDetails looks up all recorded details regarding a transaction with some hash. In case of a hash collision, the most recent transaction with a matching hash is returned.

Not finding a transaction with this hash is not an error. In this case, a nil TxDetails is returned.

func (*Store) UniqueTxDetails

func (s *Store) UniqueTxDetails(ns walletdb.ReadBucket, txHash *chainhash.Hash,
	block *Block) (*TxDetails, error)

UniqueTxDetails looks up all recorded details for a transaction recorded mined in some particular block, or an unmined transaction if block is nil.

Not finding a transaction with this hash from this block is not an error. In this case, a nil TxDetails is returned.

func (*Store) UnminedTxHashes

func (s *Store) UnminedTxHashes(ns walletdb.ReadBucket) ([]*chainhash.Hash, error)

UnminedTxHashes returns the hashes of all transactions not known to have been mined in a block.

func (*Store) UnminedTxs

func (s *Store) UnminedTxs(ns walletdb.ReadBucket) ([]*wire.MsgTx, error)

UnminedTxs returns the underlying transactions for all unmined transactions which are not known to have been mined in a block. Transactions are guaranteed to be sorted by their dependency order.

func (*Store) UnspentMultisigCredits

func (s *Store) UnspentMultisigCredits(ns walletdb.ReadBucket) ([]*MultisigCredit, error)

UnspentMultisigCredits returns all unspent multisignature P2SH credits in the wallet.

func (*Store) UnspentMultisigCreditsForAddress

func (s *Store) UnspentMultisigCreditsForAddress(ns walletdb.ReadBucket,
	addr dcrutil.Address) ([]*MultisigCredit, error)

UnspentMultisigCreditsForAddress returns all unspent multisignature P2SH credits in the wallet for some specified address.

func (*Store) UnspentOutpoints

func (s *Store) UnspentOutpoints(ns walletdb.ReadBucket) ([]wire.OutPoint, error)

UnspentOutpoints returns all unspent received transaction outpoints. The order is undefined.

func (*Store) UnspentOutputs

func (s *Store) UnspentOutputs(ns walletdb.ReadBucket) ([]*Credit, error)

UnspentOutputs returns all unspent received transaction outputs. The order is undefined.

func (*Store) UnspentOutputsForAmount

func (s *Store) UnspentOutputsForAmount(ns, addrmgrNs walletdb.ReadBucket,
	amt dcrutil.Amount, height int32, minConf int32, all bool,
	account uint32) ([]*Credit, error)

UnspentOutputsForAmount returns all non-stake outputs that sum up to the amount passed. If not enough funds are found, a nil pointer is returned without error.

func (*Store) UnspentTickets

func (s *Store) UnspentTickets(ns walletdb.ReadBucket, syncHeight int32,
	includeImmature bool) ([]chainhash.Hash, error)

UnspentTickets returns all unspent tickets that are known for this wallet. The order is undefined.

type TxDetails

type TxDetails struct {
	TxRecord
	Block   BlockMeta
	Credits []CreditRecord
	Debits  []DebitRecord
}

TxDetails is intended to provide callers with access to rich details regarding a relevant transaction and which inputs and outputs are credit or debits.

func (*TxDetails) Height

func (t *TxDetails) Height() int32

Height returns the height of a transaction according to the BlockMeta.

type TxRecord

type TxRecord struct {
	MsgTx        wire.MsgTx
	Hash         chainhash.Hash
	Received     time.Time
	SerializedTx []byte // Optional: may be nil
	TxType       stake.TxType
}

TxRecord represents a transaction managed by the Store.

func NewTxRecord

func NewTxRecord(serializedTx []byte, received time.Time) (*TxRecord, error)

NewTxRecord creates a new transaction record that may be inserted into the store. It uses memoization to save the transaction hash and the serialized transaction.

func NewTxRecordFromMsgTx

func NewTxRecordFromMsgTx(msgTx *wire.MsgTx, received time.Time) (*TxRecord,
	error)

NewTxRecordFromMsgTx creates a new transaction record that may be inserted into the store.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL