MsgBlock class

MsgBlock implements the Message interface and represents a bitcoin block message. It is used to deliver block and transaction information in response to a getdata message (MsgGetData) for a given block hash.

Inheritance

Constructors

MsgBlock({required BlockHeader header, required List<MsgTx> transactions})
Creates a new MsgBlock message.
MsgBlock.deserialize(Uint8List data)
Deserializes a MsgBlock from byte data.
factory
MsgBlock.empty({BlockHeader? header})
Creates an empty MsgBlock with a genesis header.
MsgBlock.headerOnly({required BlockHeader header})
Creates a MsgBlock with header and no transactions.

Properties

blockHash Hash
Computes the block hash from the header.
no setter
command String
Get the command string for this message type
no setteroverride
hashCode int
The hash code for this object.
no setteroverride
The block header containing metadata about the block.
final
isEmpty bool
Checks if this block has no transactions.
no setter
isNotEmpty bool
Checks if this block has transactions.
no setter
maxPayloadLength int
Get maximum payload length for this message type
no setteroverride
merkleRoot Hash
Gets the merkle root calculated from all transactions. Note: This is a simplified implementation that doesn't actually calculate the merkle tree - it just returns the header's merkle root.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size int
Returns the size of the block in bytes.
no setter
transactions List<MsgTx>
List of transactions in this block.
final
txCount int
Returns the number of transactions in this block.
no setter

Methods

addTransaction(MsgTx tx) → void
Adds a transaction to the message.
clearTransactions() → void
Removes all transactions from the message.
decode(Uint8List data, int protocolVersion, MessageEncoding encoding) → void
Decode message from bytes
override
encode(int protocolVersion, MessageEncoding encoding) Uint8List
Encode message to bytes
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
serialize(int protocolVersion, BitcoinNetwork network) Uint8List
Serialize complete message with header
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override

Static Methods

registerWithFactory() → void
Register this message type with the factory.