Block
Block
Bases: KernelOpaquePtr
A deserialized Bitcoin block.
Source code in pbk/block.py
block_hash
property
The hash of this block.
Computes the double-SHA256 hash of the block header.
| RETURNS | DESCRIPTION |
|---|---|
BlockHash
|
The block hash. |
transactions
property
All transactions in this block.
| RETURNS | DESCRIPTION |
|---|---|
TransactionSequence
|
A lazy sequence of transactions, including the coinbase. |
__bytes__
Serialize the block to bytes.
| RETURNS | DESCRIPTION |
|---|---|
bytes
|
The serialized block data in consensus format, suitable for |
bytes
|
P2P network transmission. |
__init__
Create a block from serialized data.
| PARAMETER | DESCRIPTION |
|---|---|
raw_block
|
The serialized block data in consensus format.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
RuntimeError
|
If parsing the block data fails (propagated from base class). |
Source code in pbk/block.py
BlockHash
Bases: KernelOpaquePtr
Identifier for a block.
Source code in pbk/block.py
__bytes__
Serialize the block hash to bytes.
| RETURNS | DESCRIPTION |
|---|---|
bytes
|
The 32-byte block hash in little-endian byte order. |
__eq__
Check equality with another block hash.
| PARAMETER | DESCRIPTION |
|---|---|
other
|
Object to compare with.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if both are BlockHash instances with equal values. |
Source code in pbk/block.py
__hash__
__init__
Create a block hash from raw bytes.
| PARAMETER | DESCRIPTION |
|---|---|
block_hash
|
The 32-byte block hash in little-endian byte order.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the block hash is not exactly 32 bytes. |
RuntimeError
|
If the C constructor fails (propagated from base class). |
Source code in pbk/block.py
__repr__
__str__
Get the hexadecimal representation of the block hash.
| RETURNS | DESCRIPTION |
|---|---|
str
|
The block hash as a 64-character hex string in big-endian |
str
|
byte order (standard Bitcoin display format). |
Source code in pbk/block.py
BlockTreeEntry
Bases: KernelOpaquePtr
Entry in the block tree.
A block tree entry represents a single block in the block tree maintained by the chainstate manager. Each entry (except genesis) points to a single parent, and multiple entries may share a parent, forming a tree structure. Each entry corresponds to a single block and may be used to retrieve its data and validation status.
Source code in pbk/block.py
block_hash
property
The hash of the block this entry represents.
| RETURNS | DESCRIPTION |
|---|---|
BlockHash
|
The block hash associated with this entry. |
height
property
The height of this block in the chain.
| RETURNS | DESCRIPTION |
|---|---|
int
|
The block height. Genesis block is at height 0. |
previous
property
The parent block tree entry.
| RETURNS | DESCRIPTION |
|---|---|
BlockTreeEntry
|
The previous block tree entry in the tree. |
| RAISES | DESCRIPTION |
|---|---|
RuntimeError
|
If the C constructor fails (propagated from base class). |
__eq__
Check equality with another block tree entry.
| PARAMETER | DESCRIPTION |
|---|---|
other
|
Object to compare with.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if both are BlockTreeEntry instances with equal height and hash. |
Source code in pbk/block.py
__hash__
Get hash value for use in sets and dictionaries.
| RETURNS | DESCRIPTION |
|---|---|
int
|
Hash combining height and block hash. |
TransactionSequence
Bases: LazySequence[Transaction]
Lazily-evaluated sequence of transactions in a block.
This sequence provides indexed access to transactions within a block. The sequence is a view into the block and caches its length on first access.
Source code in pbk/block.py
__init__
Create a sequence view of transactions.
| PARAMETER | DESCRIPTION |
|---|---|
block
|
The block to create a sequence view for.
TYPE:
|
__len__
Number of transactions in the block.
| RETURNS | DESCRIPTION |
|---|---|
int
|
The transaction count (cached after first call). |
Source code in pbk/block.py
TransactionSpentOutputsSequence
Bases: LazySequence[TransactionSpentOutputs]
Lazily-evaluated sequence of spent outputs for transactions in a block.
This sequence provides indexed access to the spent outputs (undo data) for each transaction in a block. The sequence excludes the coinbase transaction, which has no spent outputs.
Source code in pbk/block.py
__init__
Create a sequence view of transaction spent outputs.
| PARAMETER | DESCRIPTION |
|---|---|
block_spent_outputs
|
The block spent outputs to create a sequence view for.
TYPE:
|
Source code in pbk/block.py
__len__
Number of transaction spent outputs in the block. Equals the number of transactions in the block, minus 1 because the coinbase transaction is excluded as it has no spent outputs.
| RETURNS | DESCRIPTION |
|---|---|
int
|
The count of transaction spent outputs (cached after first call). |
Source code in pbk/block.py
BlockSpentOutputs
Bases: KernelOpaquePtr
Spent outputs (undo data) for all transactions in a block.
Block spent outputs contain all the previous outputs consumed by all transactions in a specific block. This data is also known as "undo data" because it's necessary for reverting blocks during chain reorganizations. The data is stored as a nested structure: a sequence of transaction spent outputs, each containing the coins consumed by that transaction's inputs.
Source code in pbk/block.py
transactions
property
Spent outputs for each transaction in the block.
| RETURNS | DESCRIPTION |
|---|---|
TransactionSpentOutputsSequence
|
A sequence of transaction spent outputs, excluding the coinbase. |