Documentation ¶
Index ¶
- Constants
- type Block
- func (b *Block) Bytes() ([]byte, error)
- func (b *Block) BytesNoWitness() ([]byte, error)
- func (b *Block) Hash() *chainhash.Hash
- func (b *Block) Height() int32
- func (b *Block) SetBlockBytes(buf []byte)
- func (b *Block) SetHeight(height int32)
- func (b *Block) Transactions() []*util.Tx
- func (b *Block) Tx(txNum int) (*util.Tx, error)
- func (b *Block) TxHash(txNum int) (*chainhash.Hash, error)
- func (b *Block) TxLoc() ([]wire.TxLoc, error)
- func (b *Block) WireBlock() *wire.Block
- type OutOfRangeError
Constants ¶
const BlockHeightUnknown = int32(-1)
BlockHeightUnknown is the value returned for a block height that is unknown. This is typically because the block has not been inserted into the main chain yet.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block defines a bitcoin block that provides easier and more efficient manipulation of raw blocks. It also memorizes hashes for the block and its transactions on their first access so subsequent accesses don't have to repeat the relatively expensive hashing operations.
func NewBlock ¶
NewBlock returns a new instance of a bitcoin block given an underlying wire.Block. See Block.
func NewFromBlockAndBytes ¶
NewFromBlockAndBytes returns a new instance of a bitcoin block given an underlying wire.Block and the serialized bytes for it. See Block.
func NewFromBytes ¶
NewFromBytes returns a new instance of a bitcoin block given the serialized bytes. See Block.
func NewFromReader ¶
NewFromReader returns a new instance of a bitcoin block given a Reader to deserialize the block. See Block.
func (*Block) Bytes ¶
Bytes returns the serialized bytes for the Block. This is equivalent to calling Serialize on the underlying wire.Block, however it caches the result so subsequent calls are more efficient.
func (*Block) BytesNoWitness ¶
BytesNoWitness returns the serialized bytes for the block with transactions encoded without any witness data.
func (*Block) Hash ¶
Hash returns the block identifier hash for the Block. This is equivalent to calling BlockHash on the underlying wire.Block, however it caches the result so subsequent calls are more efficient.
func (*Block) Height ¶
Height returns the saved height of the block in the block chain. This value will be BlockHeightUnknown if it hasn't already explicitly been set.
func (*Block) SetBlockBytes ¶
SetBlockBytes sets the internal serialized block byte buffer to the passed buffer. It is used to inject errors and is only available to the test package.
func (*Block) Transactions ¶
Transactions returns a slice of wrapped transactions (util.Tx) for all transactions in the Block. This is nearly equivalent to accessing the raw transactions (wire.MsgTx) in the underlying wire.Block, however it instead provides easy access to wrapped versions (util.Tx) of them.
func (*Block) Tx ¶
Tx returns a wrapped transaction (util.Tx) for the transaction at the specified index in the Block. The supplied index is 0 based. That is to say, the first transaction in the block is txNum 0. This is nearly equivalent to accessing the raw transaction (wire.MsgTx) from the underlying wire.Block, however the wrapped transaction has some helpful properties such as caching the hash so subsequent calls are more efficient.
func (*Block) TxHash ¶
TxHash returns the hash for the requested transaction number in the Block. The supplied index is 0 based. That is to say, the first transaction in the block is txNum 0. This is equivalent to calling TxHash on the underlying wire.MsgTx, however it caches the result so subsequent calls are more efficient.
type OutOfRangeError ¶
type OutOfRangeError string
OutOfRangeError describes an error due to accessing an element that is out of range.
func (OutOfRangeError) Error ¶
func (e OutOfRangeError) Error() string
Error satisfies the error interface and prints human-readable errors.