Skip to content

Transactions

Transaction

Construction Examples:

  • tx(0x0200000001…)
  • tx[ "inputs": …, "outputs": ]

→ See the Transactions guide for more options.

Coerces from:

  • Bytes – raw transaction serialization
  • Array – transaction construction fields (see tx())
  • Psbt – as the unsigned_tx

Underlying Type: bitcoin::Transaction

tx()

txid Hash

wtxid Hash

version Int

locktime Int

inputs Array<TxIn>

outputs Array<TxOut>

weight Int

vsize Int

size Int

txid()

txid(Transaction) -> Hash

Aliased as: tx::id()

Rust source code: src/stdlib/btc.rs:N/A

tx::sighash()

tx::sighash(
  tx: Transaction,
  input_index: Int,
  utxos: Array<TxOut>,
  sighash_ty: Int|Bytes|String = SIGHASH_ALL,
  tap_leaf: Script|Policy|TapLeafHash = None
) -> Bytes

Minsc source code: src/stdlib/btc.minsc:N/A

tx::sign()

tx::sign(tx: Transaction, utxos: Array<TxOut>, keys: PsbtSigningKeys) -> Int

Sign all tx inputs using the provided keys.

Also see: psbt::sign()

Minsc source code: src/stdlib/btc.minsc:N/A

tx::fee()

tx::fee(tx: Transaction, utxos: Array<TxOut>) -> Int

Calculate the tx fee given the utxos spent by it.

Throws:

  • If the number of utxos doesn't match the number of tx inputs
  • 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:N/A

tx::with_witness()

tx::with_witness(tx: Transaction, witnesses: Array<Witness|Int:Witness>) -> Transaction

Rust source code: src/stdlib/btc.rs:N/A

tx::strip_witness()

tx::strip_witness(Transaction) -> Transaction

Minsc source code: src/stdlib/btc.minsc:N/A

SIGHASH_ALL Bytes

SIGHASH_ALL = 0x01

SIGHASH_NONE Bytes

SIGHASH_NONE = 0x02

SIGHASH_SINGLE Bytes

SIGHASH_SINGLE = 0x03

SIGHASH_DEFAULT Bytes

SIGHASH_DEFAULT = 0x00

ENABLE_RBF Bytes

ENABLE_RBF = 0xFFFFFFFD

DUST_AMOUNT Int

DUST_AMOUNT = 330

DUST_TR Int

DUST_TR = 330

DUST_WSH Int

DUST_WSH = 330

DUST_WPKH Int

DUST_WPKH = 294

DUST_PRE_SW Int

DUST_PRE_SW = 546

DUST_P2A Int

DUST_P2A = 240

Txid

TxIn

TxOut

OutPoint

Witness