pyrxd.transaction — Transaction building¶
Transaction building, signing, and serialization for Radiant.
- exception pyrxd.transaction.InsufficientFunds[source]¶
Bases:
ValueError
- class pyrxd.transaction.Transaction[source]¶
Bases:
object- __init__(tx_inputs=None, tx_outputs=None, version=1, locktime=0, merkle_path=None, **kwargs)[source]¶
- Parameters:
tx_inputs (list[TransactionInput] | None)
tx_outputs (list[TransactionOutput] | None)
version (int)
locktime (int)
merkle_path (MerklePath | None)
- add_input(tx_input)[source]¶
- Parameters:
tx_input (TransactionInput)
- Return type:
- add_inputs(tx_inputs)[source]¶
- Parameters:
tx_inputs (list[TransactionInput])
- Return type:
- add_output(tx_output)[source]¶
- Parameters:
tx_output (TransactionOutput)
- Return type:
- add_outputs(tx_outputs)[source]¶
- Parameters:
tx_outputs (list[TransactionOutput])
- Return type:
- byte_length()[source]¶
- Returns:
actual byte length of this transaction under the current state
- Return type:
- estimated_byte_length()[source]¶
- Returns:
estimated byte length of this transaction after signing
- Return type:
if transaction has already signed, it will return the same value as function byte_length
- estimated_size()¶
- Returns:
estimated byte length of this transaction after signing
- Return type:
if transaction has already signed, it will return the same value as function byte_length
- fee(model_or_fee=None, change_distribution='equal')[source]¶
Computes the fee for the transaction and adjusts the change outputs accordingly.
- Parameters:
model_or_fee – Fee model or fee amount. Defaults to SatoshisPerKilobyte with value 10 if not provided.
change_distribution – Method of change distribution (‘equal’ or ‘random’). Defaults to ‘equal’.
- classmethod from_hex(stream)[source]¶
- Parameters:
- Return type:
Transaction | None
- get_fee()[source]¶
- Returns:
actual fee paid of this transaction under the current state
- Return type:
- classmethod parse_script_offsets(octets)[source]¶
Since the validation of blockchain data is atomically transaction data validation, any application seeking to validate data in output scripts must store the entire transaction as well. Since the transaction data includes the output script data, saving a second copy of potentially large scripts can bloat application storage requirements.
This function efficiently parses binary transaction data to determine the offsets and lengths of each script. This supports the efficient retrieval of script data from transaction data.
@param octets: binary transaction data or hex string @returns: {
inputs: { vin: number, offset: number, length: number }[] outputs: { vout: number, offset: number, length: number }[]
}
- class pyrxd.transaction.TransactionInput[source]¶
Bases:
object- __init__(source_transaction=None, source_txid=None, source_output_index=0, unlocking_script=None, unlocking_script_template=None, sequence=4294967295, sighash=SIGHASH.ALL_FORKID)[source]¶
- classmethod from_hex(stream)[source]¶
- Parameters:
- Return type:
TransactionInput | None