Trait handshakes::prelude::TxBuilder[][src]

pub trait TxBuilder {
    type Transaction: Transaction;
    type Encoder: AddressEncoder;
Show methods fn new() -> Self;
fn from_tx_ref(tx: &Self::Transaction) -> Self;
fn from_tx(tx: Self::Transaction) -> Self;
fn version(self, version: u32) -> Self;
fn spend<I>(self, prevout: I, sequence: u32) -> Self
    where
        I: Into<<<Self::Transaction as Transaction>::TxIn as Input>::TxoIdentifier>
;
fn pay(
        self,
        value: <<Self::Transaction as Transaction>::TxOut as Output>::Value,
        address: &<Self::Encoder as AddressEncoder>::Address
    ) -> Self;
fn insert_input(
        self,
        index: usize,
        input: <Self::Transaction as Transaction>::TxIn
    ) -> Self;
fn extend_inputs<I>(self, inputs: I) -> Self
    where
        I: IntoIterator<Item = <Self::Transaction as Transaction>::TxIn>
;
fn insert_output(
        self,
        index: usize,
        output: <Self::Transaction as Transaction>::TxOut
    ) -> Self;
fn extend_outputs<I>(self, outputs: I) -> Self
    where
        I: IntoIterator<Item = <Self::Transaction as Transaction>::TxOut>
;
fn locktime(self, locktime: u32) -> Self;
fn build(
        self
    ) -> Result<Self::Transaction, <Self::Transaction as Transaction>::TxError>; fn read_from_tx<R>(
        reader: &mut R
    ) -> Result<Self, <Self::Transaction as Transaction>::TxError>
    where
        R: Read
, { ... }
fn from_hex_tx(
        hex_str: &str
    ) -> Result<Self, <Self::Transaction as Transaction>::TxError> { ... }
}
Expand description

A builder-pattern interface for constructing transactions. Implementations should accumulate inputs, outputs, witnesses, and other TX data, and then build() a Transaction object from the accumulated data.

Associated Types

The Transaction type returned by build()

An AddressEncoder that handles encoding and decoding network addresses. This is used in the pay function to decode addresses into associated RecipientIdentifiers.

Required methods

Instantiate a new builder

Instantiate a new builder from a transaction reference by cloning its properties

Instantiate a new builder from a transaction by taking ownership of its properties

Set or overwrite the transaction version.

If implementing a network without a version field, feel free to leave this as a NOP

Spend an outpoint. Adds an unsigned input spending the associated outpoint with the specified sequence number.

Pay an Address. Adds an output paying value to address.

Insert an input at the specified index. Inputs after that are shifted to later indices.

Note

This may invalidate signatures made using ANYONECANPAY.

Add a set of inputs to the transaction.

Insert an output at the specified index. Outputs after that are shifted to later indices.

Note

This may invalidate signatures made using SINGLE.

Add a set of outputs to the transaction.

Set or overwrite the transaction locktime.

If implementing a network without a locktime field, feel free to leave this as a NOP

Consume the builder and produce a transaction from the builder’s current state.

Provided methods

Instantiate a new builder from a std::io::Read that contains a serialized tx

Instantiate a new builder from transaction hex

Implementors