Struct bitcoins::builder::BitcoinTxBuilder [−][src]
pub struct BitcoinTxBuilder<T: AddressEncoder> { /* fields omitted */ }
Expand description
This is a generic builder for Bitcoin transactions. It allows you to easily build legacy and witness transactions.
Note: due to Bitcoin consensus rules, the order of inputs and outputs may be semantically
meaningful. E.g. when signing a transaction with the SINGLE
sighash mode.
It is parameterized with an address encoder, so that the same struct and logic can be used on mainnet and testnet.
Implementations
Add a set of witnesses to the transaction, and return a witness builder.
pub fn insert_witness(
self,
index: usize,
witness: <<Self as TxBuilder>::Transaction as Transaction>::TxIn
) -> Self
pub fn insert_witness(
self,
index: usize,
witness: <<Self as TxBuilder>::Transaction as Transaction>::TxIn
) -> Self
Insert a witness at a speicified index
Add an op_return output. Using this twice may render the transaction non-standard.
Set the script sig at a specific input. Do nothing if the vin is not that long.
Consume self, produce a legacy tx. Discard any witness information in the builder
Consume self, produce a witness tx
Add an output paying value
to script_pubkey
Trait Implementations
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
type Encoder = T
type Encoder = T
An AddressEncoder that handles encoding and decoding network addresses. This is used in
the pay
function to decode addresses into associated RecipientIdentifier
s. Read more
type Transaction = BitcoinTx
type Transaction = BitcoinTx
The Transaction type returned by build()
Instantiate a new builder from a transaction by taking ownership of its properties
Instantiate a new builder from a transaction reference by cloning its properties
Spend an outpoint. Adds an unsigned input spending the associated outpoint with the specified sequence number. Read more
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. Read more
Add a set of inputs to the transaction.
fn insert_output(
self,
index: usize,
output: <Self::Transaction as Transaction>::TxOut
) -> Self
fn insert_output(
self,
index: usize,
output: <Self::Transaction as Transaction>::TxOut
) -> Self
Insert an output at the specified index. Outputs after that are shifted to later indices. Read more
Add a set of outputs to the transaction.
Consume the builder and produce a transaction from the builder’s current state.
fn read_from_tx<R>(
reader: &mut R
) -> Result<Self, <Self::Transaction as Transaction>::TxError> where
R: Read,
fn read_from_tx<R>(
reader: &mut R
) -> Result<Self, <Self::Transaction as Transaction>::TxError> where
R: Read,
Instantiate a new builder from a std::io::Read
that contains a serialized tx
Instantiate a new builder from transaction hex
Auto Trait Implementations
impl<T> RefUnwindSafe for BitcoinTxBuilder<T>
impl<T> Send for BitcoinTxBuilder<T>
impl<T> Sync for BitcoinTxBuilder<T>
impl<T> Unpin for BitcoinTxBuilder<T>
impl<T> UnwindSafe for BitcoinTxBuilder<T>
Blanket Implementations
Mutably borrows from an owned value. Read more