pub trait WitnessTransaction: BitcoinTransaction {
type WTXID: MarkedDigestOutput;
type WitnessSighashArgs;
type Witness;
fn new<I, O, W>(
version: u32,
vin: I,
vout: O,
witnesses: W,
locktime: u32
) -> Result<Self, Self::TxError>
where
I: Into<Vec<Self::TxIn>>,
O: Into<Vec<Self::TxOut>>,
W: Into<Vec<Self::Witness>>,
Self: Sized;
fn wtxid(&self) -> Self::WTXID;
fn write_legacy_sighash_preimage<W: Write>(
&self,
writer: &mut W,
args: &LegacySighashArgs
) -> Result<(), Self::TxError>;
fn write_witness_sighash_preimage<W: Write>(
&self,
writer: &mut W,
args: &Self::WitnessSighashArgs
) -> Result<(), Self::TxError>;
fn legacy_sighash(
&self,
args: &LegacySighashArgs
) -> Result<DigestOutput<Self::HashWriter>, Self::TxError> { ... }
fn witness_sighash(
&self,
args: &Self::WitnessSighashArgs
) -> Result<DigestOutput<Self::HashWriter>, Self::TxError> { ... }
}
Expand description
Basic functionality for a Witness Transaction
This trait has been generalized to support transactions from Non-Bitcoin networks. The transaction specificies which types it considers to be inputs and outputs, and a struct that contains its Sighash arguments. This allows others to define custom transaction types with unique functionality.
Required Associated Types
The MarkedDigest type for the Transaction’s Witness TXID
The BIP143 sighash args needed to sign an input
Required Methods
Instantiate a new WitnessTx from the arguments.
fn write_legacy_sighash_preimage<W: Write>(
&self,
writer: &mut W,
args: &LegacySighashArgs
) -> Result<(), Self::TxError>
fn write_legacy_sighash_preimage<W: Write>(
&self,
writer: &mut W,
args: &LegacySighashArgs
) -> Result<(), Self::TxError>
Writes the Legacy sighash preimage to the provider writer.
fn write_witness_sighash_preimage<W: Write>(
&self,
writer: &mut W,
args: &Self::WitnessSighashArgs
) -> Result<(), Self::TxError>
fn write_witness_sighash_preimage<W: Write>(
&self,
writer: &mut W,
args: &Self::WitnessSighashArgs
) -> Result<(), Self::TxError>
Writes the BIP143 sighash preimage to the provided writer
. See the
WitnessSighashArgsSigh
documentation for more in-depth discussion of sighash.
Provided Methods
fn legacy_sighash(
&self,
args: &LegacySighashArgs
) -> Result<DigestOutput<Self::HashWriter>, Self::TxError>
fn legacy_sighash(
&self,
args: &LegacySighashArgs
) -> Result<DigestOutput<Self::HashWriter>, Self::TxError>
Calculates the Legacy sighash preimage given the sighash args.
fn witness_sighash(
&self,
args: &Self::WitnessSighashArgs
) -> Result<DigestOutput<Self::HashWriter>, Self::TxError>
fn witness_sighash(
&self,
args: &Self::WitnessSighashArgs
) -> Result<DigestOutput<Self::HashWriter>, Self::TxError>
Calculates the BIP143 sighash given the sighash args. See the
WitnessSighashArgsSigh
documentation for more in-depth discussion of sighash.