Documentation ¶
Index ¶
- Variables
- func CreateCoinbaseTx(blockHeight int32, blockSubsidy int64) *wire.MsgTx
- func CreateSpendTx(spend *SpendableOut, fee btcutil.Amount) *wire.MsgTx
- func OpReturnScript(data []byte) ([]byte, error)
- func SolveBlock(header *wire.BlockHeader) bool
- func StandardCoinbaseScript(blockHeight int32, extraNonce uint64) ([]byte, error)
- func UniqueOpReturnScript() ([]byte, error)
- type SpendableOut
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func CreateCoinbaseTx ¶
CreateCoinbaseTx returns a coinbase transaction paying an appropriate subsidy based on the passed block height and the block subsidy. The coinbase signature script conforms to the requirements of version 2 blocks.
func CreateSpendTx ¶
func CreateSpendTx(spend *SpendableOut, fee btcutil.Amount) *wire.MsgTx
CreateSpendTx creates a transaction that spends from the provided spendable output and includes an additional unique OP_RETURN output to ensure the transaction ends up with a unique hash. The script is a simple OP_TRUE script which avoids the need to track addresses and signature scripts in the tests.
func OpReturnScript ¶
OpReturnScript returns a provably-pruneable OP_RETURN script with the provided data.
func SolveBlock ¶
func SolveBlock(header *wire.BlockHeader) bool
SolveBlock attempts to find a nonce which makes the passed block header hash to a value less than the target difficulty. When a successful solution is found true is returned and the nonce field of the passed header is updated with the solution. False is returned if no solution exists.
NOTE: This function will never solve blocks with a nonce of 0. This is done so the 'nextBlock' function can properly detect when a nonce was modified by a munge function.
func StandardCoinbaseScript ¶
StandardCoinbaseScript returns a standard script suitable for use as the signature script of the coinbase transaction of a new block. In particular, it starts with the block height that is required by version 2 blocks.
func UniqueOpReturnScript ¶
UniqueOpReturnScript returns a standard provably-pruneable OP_RETURN script with a random uint64 encoded as the data.
Types ¶
type SpendableOut ¶
SpendableOut represents a transaction output that is spendable along with additional metadata such as the block its in and how much it pays.
func MakeSpendableOut ¶
func MakeSpendableOut(block *wire.MsgBlock, txIndex, txOutIndex uint32) SpendableOut
MakeSpendableOut returns a spendable output for the given block, transaction index within the block, and transaction output index within the transaction.
func MakeSpendableOutForTx ¶
func MakeSpendableOutForTx(tx *wire.MsgTx, txOutIndex uint32) SpendableOut
MakeSpendableOutForTx returns a spendable output for the given transaction and transaction output index within the transaction.