Struct bitcoins::types::witness::WitnessTx [−][src]
pub struct WitnessTx { /* fields omitted */ }
Expand description
A witness transaction. Any transaction that contains 1 or more witnesses.
Implementations
Consumes a LegacyTx
and instantiates a new WitnessTx
with empty witnesses
Trait Implementations
Consume the tx and convert it to a legacy tx. Useful for when you have
dyn BitcoinTransaction
or impl BitcoinTransaction
types. Read more
Consume the tx and convert it to a legacy tx. Useful for when you have
dyn BitcoinTransaction
or impl BitcoinTransaction
types, but into_witness
should be
preferred, as it will never drop information. Read more
Return a reference to a slice of witnesses. For legacy txins this will ALWAYS be length 0. For witness txns, this will ALWAYS be the same length as the input vector. Read more
Get a reference to the output by
Returns the byte-length of the serialized data structure.
Deserializes an instance of Self
from a std::io::Read
.
The limit
argument is used only when deserializing collections, and specifies a maximum
number of instances of the underlying type to read. Read more
Serializes self
to a std::io::Write
. Following Write
trait conventions, its Ok
type must be a usize
denoting the number of bytes written. Read more
fn read_seq_from<R>(
reader: &mut R,
mode: ReadSeqMode
) -> Result<Vec<Self, Global>, Self::Error> where
R: Read,
fn read_seq_from<R>(
reader: &mut R,
mode: ReadSeqMode
) -> Result<Vec<Self, Global>, Self::Error> where
R: Read,
Read a sequence of exactly limit
objects from the reader.
Write a sequence of ByteFormat
objects to a writer. The iter
argument may be any object that implements
IntoIterator<Item = &Item>
. This means we can seamlessly use vectors,
slices, etc. Read more
Decodes a hex string to a Vec<u8>
, deserializes an instance of Self
from that vector.
Serialize self
to a base64 string, using standard RFC4648 non-url safe characters
Serializes self
to a vector, returns the hex-encoded vector
Serialize self
to a base64 string, using standard RFC4648 non-url safe characters
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
type TxIn = BitcoinTxIn
type TxIn = BitcoinTxIn
The Input type for the transaction
type SighashArgs = WitnessSighashArgs
type SighashArgs = WitnessSighashArgs
A type describing arguments for the sighash function for this transaction.
type HashWriter = Hash256
type HashWriter = Hash256
A type that implements HashWriter
. Used to generate the TXID
and Sighash
.
Instantiate a new Transaction by specifying inputs and outputs.
Calculates and returns the transaction’s ID. The default TXID is simply the digest of the serialized transaction. Read more
fn write_sighash_preimage<W: Write>(
&self,
writer: &mut W,
args: &Self::SighashArgs
) -> TxResult<()>
fn write_sighash_preimage<W: Write>(
&self,
writer: &mut W,
args: &Self::SighashArgs
) -> TxResult<()>
Generate the digest that must be signed to authorize inputs. For Bitcoin transactions this is a function of the transaction, and the input’s prevout. Read more
fn sighash(
&self,
args: &Self::SighashArgs
) -> Result<GenericArray<u8, <Self::HashWriter as Digest>::OutputSize>, Self::TxError>
fn sighash(
&self,
args: &Self::SighashArgs
) -> Result<GenericArray<u8, <Self::HashWriter as Digest>::OutputSize>, Self::TxError>
Calls write_sighash_preimage
with the provided arguments and a new HashWriter.
Returns the sighash digest which should be signed. Read more
Create a new WitnessTx. Since witnesses correspond to inputs, ensure that there are the same number of witnesses as inputs. The number of witnesses will be trimmed if there are too many and will be filled with empty witnesses if too few.
The BIP143 sighash args needed to sign an input
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>(
&self,
writer: &mut W,
args: &WitnessSighashArgs
) -> TxResult<()> where
W: Write,
fn write_witness_sighash_preimage<W>(
&self,
writer: &mut W,
args: &WitnessSighashArgs
) -> TxResult<()> where
W: Write,
Writes the BIP143 sighash preimage to the provided writer
. See the
WitnessSighashArgsSigh
documentation for more in-depth discussion of sighash. Read more
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. Read more
Auto Trait Implementations
impl RefUnwindSafe for WitnessTx
impl UnwindSafe for WitnessTx
Blanket Implementations
Mutably borrows from an owned value. Read more