Transaction
Txid
Bases: KernelOpaquePtr
Transaction identifier.
Note
Txid instances cannot be directly constructed. They are obtained from Transaction objects or TransactionOutPoint objects.
Source code in pbk/transaction.py
__bytes__
Serialize the txid to bytes.
| RETURNS | DESCRIPTION |
|---|---|
bytes
|
The 32-byte txid in little-endian byte order. |
__eq__
Check equality with another txid.
| PARAMETER | DESCRIPTION |
|---|---|
other
|
Object to compare with.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if both are Txid instances with equal values. |
Source code in pbk/transaction.py
__hash__
__repr__
__str__
Get the hexadecimal representation of the txid.
| RETURNS | DESCRIPTION |
|---|---|
str
|
The txid as a 64-character hex string in big-endian |
str
|
byte order (standard Bitcoin display format). |
Source code in pbk/transaction.py
TransactionOutPoint
Bases: KernelOpaquePtr
Reference to a specific output of a transaction.
A transaction outpoint identifies a specific output by combining a transaction ID with an output index. This is used in transaction inputs to specify which previous output is being spent.
Note
TransactionOutPoint instances cannot be directly constructed. They are obtained from TransactionInput objects.
Source code in pbk/transaction.py
index
property
The output index within the transaction.
| RETURNS | DESCRIPTION |
|---|---|
int
|
The zero-based output position. |
txid
property
The transaction ID being referenced.
| RETURNS | DESCRIPTION |
|---|---|
Txid
|
The txid of the transaction containing the output. |
TransactionInput
Bases: KernelOpaquePtr
Input to a transaction that spends a previous output.
Note
TransactionInput instances cannot be directly constructed. They are obtained from Transaction objects.
Source code in pbk/transaction.py
out_point
property
The outpoint being spent by this input.
| RETURNS | DESCRIPTION |
|---|---|
TransactionOutPoint
|
The transaction outpoint referencing the previous output. |
TransactionOutput
Bases: KernelOpaquePtr
Output from a transaction that can be spent.
A transaction output specifies an amount of bitcoin and the conditions (script pubkey) required to spend it. Outputs can be created directly or obtained from existing transactions.
Source code in pbk/transaction.py
amount
property
The value of this output in satoshis.
| RETURNS | DESCRIPTION |
|---|---|
int
|
The amount in satoshis. |
script_pubkey
property
The spending conditions for this output.
| RETURNS | DESCRIPTION |
|---|---|
ScriptPubkey
|
The script pubkey defining how this output can be spent. |
__init__
Create a transaction output.
| PARAMETER | DESCRIPTION |
|---|---|
script_pubkey
|
The script pubkey defining spending conditions.
TYPE:
|
amount
|
The amount in satoshis.
TYPE:
|
Source code in pbk/transaction.py
__repr__
TransactionInputSequence
Bases: LazySequence[TransactionInput]
Lazily-evaluated sequence of transaction inputs.
This sequence provides indexed access to the inputs of a transaction. The sequence is a view into the transaction and caches its length on first access.
Source code in pbk/transaction.py
__init__
Create a sequence view of transaction inputs.
| PARAMETER | DESCRIPTION |
|---|---|
transaction
|
The transaction to create a sequence view for.
TYPE:
|
__len__
Number of inputs in the transaction.
| RETURNS | DESCRIPTION |
|---|---|
int
|
The input count (cached after first call). |
Source code in pbk/transaction.py
TransactionOutputSequence
Bases: LazySequence[TransactionOutput]
Lazily-evaluated sequence of transaction outputs.
This sequence provides indexed access to the outputs of a transaction. The sequence is a view into the transaction and caches its length on first access.
Source code in pbk/transaction.py
__init__
Create a sequence view of transaction outputs.
| PARAMETER | DESCRIPTION |
|---|---|
transaction
|
The transaction to create a sequence view for.
TYPE:
|
__len__
Number of outputs in the transaction.
| RETURNS | DESCRIPTION |
|---|---|
int
|
The output count (cached after first call). |
Source code in pbk/transaction.py
Transaction
Bases: KernelOpaquePtr
A Bitcoin transaction.
Source code in pbk/transaction.py
inputs
property
All inputs of this transaction.
| RETURNS | DESCRIPTION |
|---|---|
TransactionInputSequence
|
A lazy sequence of transaction inputs. |
outputs
property
All outputs of this transaction.
| RETURNS | DESCRIPTION |
|---|---|
TransactionOutputSequence
|
A lazy sequence of transaction outputs. |
txid
property
The transaction identifier.
| RETURNS | DESCRIPTION |
|---|---|
Txid
|
The txid of this transaction. |
__bytes__
Serialize the transaction to bytes.
| RETURNS | DESCRIPTION |
|---|---|
bytes
|
The serialized transaction data in consensus format, suitable |
bytes
|
for P2P network transmission. |
Source code in pbk/transaction.py
__init__
Create a transaction from serialized data.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
The serialized transaction data in consensus format.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
RuntimeError
|
If parsing the transaction data fails (propagated from base class). |
Source code in pbk/transaction.py
__repr__
Coin
Bases: KernelOpaquePtr
A coin representing a spendable transaction output.
A coin holds information about a transaction output including the output itself, the height at which it was created, and whether it came from a coinbase transaction. Coins are typically obtained from spent output data.
Note
Coin instances cannot be directly constructed. They are obtained from TransactionSpentOutputs objects.
Source code in pbk/transaction.py
confirmation_height
property
The block height where this coin was created.
| RETURNS | DESCRIPTION |
|---|---|
int
|
The height of the block containing the transaction that |
int
|
created this coin. |
is_coinbase
property
Whether this coin came from a coinbase transaction.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the transaction that created this coin was a coinbase |
bool
|
transaction, False otherwise. |
output
property
The transaction output for this coin.
| RETURNS | DESCRIPTION |
|---|---|
TransactionOutput
|
The transaction output containing the amount and script pubkey. |
CoinSequence
Bases: LazySequence[Coin]
Lazily-evaluated sequence of coins spent by a transaction.
This sequence provides indexed access to the coins (previous outputs) consumed by a transaction's inputs. The sequence is a view and caches its length on first access.
Source code in pbk/transaction.py
__init__
Create a sequence view of coins.
| PARAMETER | DESCRIPTION |
|---|---|
spent_outputs
|
The transaction spent outputs to create a sequence view for.
TYPE:
|
__len__
Number of coins spent by the transaction.
| RETURNS | DESCRIPTION |
|---|---|
int
|
The coin count, equal to the number of inputs (cached after first call). |
Source code in pbk/transaction.py
TransactionSpentOutputs
Bases: KernelOpaquePtr
Coins consumed by a transaction's inputs.
This holds the previous outputs (coins) consumed by a transaction. Each coin corresponds to one of the transaction's inputs, in the same order. This data is part of the block's undo data and is necessary for validation and chain reorganizations.
Note
TransactionSpentOutputs instances cannot be directly constructed. They are obtained from BlockSpentOutputs objects.
Source code in pbk/transaction.py
coins
property
All coins spent by this transaction.
| RETURNS | DESCRIPTION |
|---|---|
CoinSequence
|
A sequence of coins, one for each input, in input order. |