Split Transaction impl block
Split the `Transaction` impl block into three parts: - The bits going to `primitives` - The bits staying in a public extension trait - The bits staying in a private extension trait Internal change only.
This commit is contained in:
parent
693000d09c
commit
7196992d58
|
@ -302,13 +302,6 @@ impl Transaction {
|
||||||
/// Maximum transaction weight for Bitcoin Core 25.0.
|
/// Maximum transaction weight for Bitcoin Core 25.0.
|
||||||
pub const MAX_STANDARD_WEIGHT: Weight = Weight::from_wu(400_000);
|
pub const MAX_STANDARD_WEIGHT: Weight = Weight::from_wu(400_000);
|
||||||
|
|
||||||
/// Computes a "normalized TXID" which does not include any signatures.
|
|
||||||
///
|
|
||||||
/// This method is deprecated. `ntxid` has been renamed to `compute_ntxid` to note that it's
|
|
||||||
/// computationally expensive. Use `compute_ntxid` instead.
|
|
||||||
#[deprecated(since = "0.31.0", note = "use `compute_ntxid()` instead")]
|
|
||||||
pub fn ntxid(&self) -> sha256d::Hash { self.compute_ntxid() }
|
|
||||||
|
|
||||||
/// Computes a "normalized TXID" which does not include any signatures.
|
/// Computes a "normalized TXID" which does not include any signatures.
|
||||||
///
|
///
|
||||||
/// This gives a way to identify a transaction that is "the same" as
|
/// This gives a way to identify a transaction that is "the same" as
|
||||||
|
@ -332,13 +325,6 @@ impl Transaction {
|
||||||
cloned_tx.compute_txid().into()
|
cloned_tx.compute_txid().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Computes the [`Txid`].
|
|
||||||
///
|
|
||||||
/// This method is deprecated. `txid` has been renamed to `compute_txid` to note that it's
|
|
||||||
/// computationally expensive. Use `compute_txid` instead.
|
|
||||||
#[deprecated(since = "0.31.0", note = "use `compute_txid()` instead")]
|
|
||||||
pub fn txid(&self) -> Txid { self.compute_txid() }
|
|
||||||
|
|
||||||
/// Computes the [`Txid`].
|
/// Computes the [`Txid`].
|
||||||
///
|
///
|
||||||
/// Hashes the transaction **excluding** the segwit data (i.e. the marker, flag bytes, and the
|
/// Hashes the transaction **excluding** the segwit data (i.e. the marker, flag bytes, and the
|
||||||
|
@ -350,13 +336,6 @@ impl Transaction {
|
||||||
Txid::from_byte_array(hash.to_byte_array())
|
Txid::from_byte_array(hash.to_byte_array())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Computes the segwit version of the transaction id.
|
|
||||||
///
|
|
||||||
/// This method is deprecated. `wtxid` has been renamed to `compute_wtxid` to note that it's
|
|
||||||
/// computationally expensive. Use `compute_wtxid` instead.
|
|
||||||
#[deprecated(since = "0.31.0", note = "use `compute_wtxid()` instead")]
|
|
||||||
pub fn wtxid(&self) -> Wtxid { self.compute_wtxid() }
|
|
||||||
|
|
||||||
/// Computes the segwit version of the transaction id.
|
/// Computes the segwit version of the transaction id.
|
||||||
///
|
///
|
||||||
/// Hashes the transaction **including** all segwit data (i.e. the marker, flag bytes, and the
|
/// Hashes the transaction **including** all segwit data (i.e. the marker, flag bytes, and the
|
||||||
|
@ -367,6 +346,29 @@ impl Transaction {
|
||||||
let hash = hash_transaction(self, self.uses_segwit_serialization());
|
let hash = hash_transaction(self, self.uses_segwit_serialization());
|
||||||
Wtxid::from_byte_array(hash.to_byte_array())
|
Wtxid::from_byte_array(hash.to_byte_array())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Transaction {
|
||||||
|
/// Computes a "normalized TXID" which does not include any signatures.
|
||||||
|
///
|
||||||
|
/// This method is deprecated. `ntxid` has been renamed to `compute_ntxid` to note that it's
|
||||||
|
/// computationally expensive. Use `compute_ntxid` instead.
|
||||||
|
#[deprecated(since = "0.31.0", note = "use `compute_ntxid()` instead")]
|
||||||
|
pub fn ntxid(&self) -> sha256d::Hash { self.compute_ntxid() }
|
||||||
|
|
||||||
|
/// Computes the [`Txid`].
|
||||||
|
///
|
||||||
|
/// This method is deprecated. `txid` has been renamed to `compute_txid` to note that it's
|
||||||
|
/// computationally expensive. Use `compute_txid` instead.
|
||||||
|
#[deprecated(since = "0.31.0", note = "use `compute_txid()` instead")]
|
||||||
|
pub fn txid(&self) -> Txid { self.compute_txid() }
|
||||||
|
|
||||||
|
/// Computes the segwit version of the transaction id.
|
||||||
|
///
|
||||||
|
/// This method is deprecated. `wtxid` has been renamed to `compute_wtxid` to note that it's
|
||||||
|
/// computationally expensive. Use `compute_wtxid` instead.
|
||||||
|
#[deprecated(since = "0.31.0", note = "use `compute_wtxid()` instead")]
|
||||||
|
pub fn wtxid(&self) -> Wtxid { self.compute_wtxid() }
|
||||||
|
|
||||||
/// Returns the weight of this transaction, as defined by BIP-141.
|
/// Returns the weight of this transaction, as defined by BIP-141.
|
||||||
///
|
///
|
||||||
|
@ -526,6 +528,24 @@ impl Transaction {
|
||||||
cost.saturating_add(self.count_witness_sigops(&mut spent))
|
cost.saturating_add(self.count_witness_sigops(&mut spent))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a reference to the input at `input_index` if it exists.
|
||||||
|
#[inline]
|
||||||
|
pub fn tx_in(&self, input_index: usize) -> Result<&TxIn, InputsIndexError> {
|
||||||
|
self.input
|
||||||
|
.get(input_index)
|
||||||
|
.ok_or(IndexOutOfBoundsError { index: input_index, length: self.input.len() }.into())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a reference to the output at `output_index` if it exists.
|
||||||
|
#[inline]
|
||||||
|
pub fn tx_out(&self, output_index: usize) -> Result<&TxOut, OutputsIndexError> {
|
||||||
|
self.output
|
||||||
|
.get(output_index)
|
||||||
|
.ok_or(IndexOutOfBoundsError { index: output_index, length: self.output.len() }.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Transaction {
|
||||||
/// Gets the sigop count.
|
/// Gets the sigop count.
|
||||||
///
|
///
|
||||||
/// Counts sigops for this transaction's input scriptSigs and output scriptPubkeys i.e., doesn't
|
/// Counts sigops for this transaction's input scriptSigs and output scriptPubkeys i.e., doesn't
|
||||||
|
@ -628,22 +648,6 @@ impl Transaction {
|
||||||
// `Transaction` docs for full explanation).
|
// `Transaction` docs for full explanation).
|
||||||
self.input.is_empty()
|
self.input.is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a reference to the input at `input_index` if it exists.
|
|
||||||
#[inline]
|
|
||||||
pub fn tx_in(&self, input_index: usize) -> Result<&TxIn, InputsIndexError> {
|
|
||||||
self.input
|
|
||||||
.get(input_index)
|
|
||||||
.ok_or(IndexOutOfBoundsError { index: input_index, length: self.input.len() }.into())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns a reference to the output at `output_index` if it exists.
|
|
||||||
#[inline]
|
|
||||||
pub fn tx_out(&self, output_index: usize) -> Result<&TxOut, OutputsIndexError> {
|
|
||||||
self.output
|
|
||||||
.get(output_index)
|
|
||||||
.ok_or(IndexOutOfBoundsError { index: output_index, length: self.output.len() }.into())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is equivalent to consensus encoding but hashes the fields manually.
|
// This is equivalent to consensus encoding but hashes the fields manually.
|
||||||
|
|
Loading…
Reference in New Issue