Skip to main content

Module spend

Module spend 

Source
Expand description

Bitcoin Script interpreter for spend validation.

This module implements the full Bitcoin Script interpreter for BSV, enabling validation of transaction spends by executing unlocking and locking scripts.

§Example

use bsv_rs::script::{Spend, LockingScript, UnlockingScript};

let spend = Spend::new(SpendParams {
    source_txid: [0u8; 32],
    source_output_index: 0,
    source_satoshis: 100_000,
    locking_script: LockingScript::from_asm("OP_DUP OP_HASH160 ... OP_CHECKSIG")?,
    transaction_version: 1,
    other_inputs: vec![],
    outputs: vec![],
    input_index: 0,
    unlocking_script: UnlockingScript::from_asm("<sig> <pubkey>")?,
    input_sequence: 0xffffffff,
    lock_time: 0,
    memory_limit: None,
});

let valid = spend.validate()?;

Structs§

Spend
The Spend struct represents a spend action and validates it by executing the unlocking and locking scripts.
SpendParams
Parameters for constructing a Spend validator.