Transaction API Reference¶
Transaction
¶
Construction Examples:
→ See the Transactions guide for more options.
Coerces from:
Bytes– raw transaction serializationArray– transaction construction fields (seetx())Psbt– as theunsigned_tx
Underlying Type: bitcoin::Transaction
tx()
¶
tx(Array<Tagged>|Bytes|Psbt|Transaction) -> Transaction
Rust source code: src/stdlib/btc.rs:223
tx::sighash()
¶
tx::sighash(
tx: Transaction,
input_index: Int,
utxos: Array<TxOut>,
sighash_ty: Bytes<1>|Int|String = SIGHASH_ALL,
tap_leaf: Script|Miniscript<Tap>|Policy|TapLeafHash = None
) -> Bytes
Minsc source code: src/stdlib/btc.minsc:59
tx::sign()
¶
tx::sign(
tx: Transaction,
utxos: Array<TxOut>,
keys: SecKey|Array<SecKey>,
sighash_ty: Bytes<1>|Int|String = SIGHASH_ALL,
inputs_fields: Array = None,
) -> Transaction
Sign all tx inputs using the provided keys.
Also see: psbt::sign()
Minsc source code: src/stdlib/btc.minsc:70
tx::fee()
¶
tx::fee(tx: Transaction, utxos: Array<TxOut>) -> Int
Calculate the tx fee given the utxos spent by it.
Errors:
- If the number of
utxosdoesn't match the number oftxinputs - If
output amount > input amount - If integer overflow occurs when adding UTXO amounts
(uses signed
i64, can represent up to ~92 billion BTC)
Also see: psbt::fee()
Minsc source code: src/stdlib/btc.minsc:77
tx::with_witness()
¶
tx::with_witness(tx: Transaction, witnesses: Array<Array<Bytes>>) -> Transaction
tx::with_witness(tx: Transaction, witnesses: Array<Int:Array<Bytes>>) -> Transaction
Rust source code: src/stdlib/btc.rs:234
tx::strip_witness()
¶
tx::strip_witness(Transaction) -> Transaction
Minsc source code: src/stdlib/btc.minsc:82