pub struct CircuitTransaction(pub Transaction);
Tuple Fields§
§0: Transaction
Implementations§
Source§impl CircuitTransaction
impl CircuitTransaction
pub fn from(transaction: Transaction) -> Self
pub fn inner(&self) -> &Transaction
Sourcepub fn txid(&self) -> [u8; 32]
pub fn txid(&self) -> [u8; 32]
Returns the transaction id, in big-endian byte order. One must be careful when dealing with Bitcoin transaction ids, as they are little-endian in the Bitcoin protocol.
Sourcepub fn mid_state_txid(&self) -> [u8; 32]
pub fn mid_state_txid(&self) -> [u8; 32]
Returns the first digest of the transaction to be used in SPV
Methods from Deref<Target = Transaction>§
pub const MAX_STANDARD_WEIGHT: Weight
pub fn ntxid(&self) -> Hash
👎Deprecated since 0.31.0: ntxid has been renamed to compute_ntxid to note that it’s computationally expensive. use compute_ntxid() instead.
pub fn ntxid(&self) -> Hash
Computes a “normalized TXID” which does not include any signatures.
This method is deprecated. Use compute_ntxid
instead.
pub fn compute_ntxid(&self) -> Hash
pub fn compute_ntxid(&self) -> Hash
Computes a “normalized TXID” which does not include any signatures.
This gives a way to identify a transaction that is “the same” as another in the sense of having same inputs and outputs.
pub fn txid(&self) -> Txid
👎Deprecated since 0.31.0: txid has been renamed to compute_txid to note that it’s computationally expensive. use compute_txid() instead.
pub fn txid(&self) -> Txid
Computes the [Txid
].
This method is deprecated. Use compute_txid
instead.
pub fn compute_txid(&self) -> Txid
pub fn compute_txid(&self) -> Txid
Computes the [Txid
].
Hashes the transaction excluding the segwit data (i.e. the marker, flag bytes, and the
witness fields themselves). For non-segwit transactions which do not have any segwit data,
this will be equal to [Transaction::compute_wtxid()
].
pub fn wtxid(&self) -> Wtxid
👎Deprecated since 0.31.0: wtxid has been renamed to compute_wtxid to note that it’s computationally expensive. use compute_wtxid() instead.
pub fn wtxid(&self) -> Wtxid
Computes the segwit version of the transaction id.
This method is deprecated. Use compute_wtxid
instead.
pub fn compute_wtxid(&self) -> Wtxid
pub fn compute_wtxid(&self) -> Wtxid
Computes the segwit version of the transaction id.
Hashes the transaction including all segwit data (i.e. the marker, flag bytes, and the
witness fields themselves). For non-segwit transactions which do not have any segwit data,
this will be equal to [Transaction::txid()
].
pub fn weight(&self) -> Weight
pub fn weight(&self) -> Weight
Returns the weight of this transaction, as defined by BIP-141.
Transaction weight is defined as Base transaction size * 3 + Total transaction size (ie. the same method as calculating Block weight from Base size and Total size).
For transactions with an empty witness, this is simply the consensus-serialized size times four. For transactions with a witness, this is the non-witness consensus-serialized size multiplied by three plus the with-witness consensus-serialized size.
For transactions with no inputs, this function will return a value 2 less than the actual
weight of the serialized transaction. The reason is that zero-input transactions, post-segwit,
cannot be unambiguously serialized; we make a choice that adds two extra bytes. For more
details see BIP 141
which uses a “input count” of 0x00
as a marker
for a Segwit-encoded transaction.
If you need to use 0-input transactions, we strongly recommend you do so using the PSBT API. The unsigned transaction encoded within PSBT is always a non-segwit transaction and can therefore avoid this ambiguity.
pub fn base_size(&self) -> usize
pub fn base_size(&self) -> usize
Returns the base transaction size.
Base transaction size is the size of the transaction serialised with the witness data stripped.
pub fn total_size(&self) -> usize
pub fn total_size(&self) -> usize
Returns the total transaction size.
Total transaction size is the transaction size in bytes serialized as described in BIP144, including base data and witness data.
pub fn vsize(&self) -> usize
pub fn vsize(&self) -> usize
Returns the “virtual size” (vsize) of this transaction.
Will be ceil(weight / 4.0)
. Note this implements the virtual size as per BIP141
, which
is different to what is implemented in Bitcoin Core. The computation should be the same for
any remotely sane transaction, and a standardness-rule-correct version is available in the
policy
module.
Virtual transaction size is defined as Transaction weight / 4 (rounded up to the next integer).
pub fn is_coinbase(&self) -> bool
pub fn is_coinbase(&self) -> bool
Checks if this is a coinbase transaction.
The first transaction in the block distributes the mining reward and is called the coinbase transaction. It is impossible to check if the transaction is first in the block, so this function checks the structure of the transaction instead - the previous output must be all-zeros (creates satoshis “out of thin air”).
pub fn is_explicitly_rbf(&self) -> bool
pub fn is_explicitly_rbf(&self) -> bool
Returns true
if the transaction itself opted in to be BIP-125-replaceable (RBF).
§Warning
Incorrectly relying on RBF may lead to monetary loss!
This does not cover the case where a transaction becomes replaceable due to ancestors being RBF. Please note that transactions may be replaced even if they do not include the RBF signal: https://bitcoinops.org/en/newsletters/2022/10/19/#transaction-replacement-option.
pub fn is_absolute_timelock_satisfied(&self, height: Height, time: Time) -> bool
pub fn is_absolute_timelock_satisfied(&self, height: Height, time: Time) -> bool
Returns true if this [Transaction
]’s absolute timelock is satisfied at height
/time
.
§Returns
By definition if the lock time is not enabled the transaction’s absolute timelock is considered to be satisfied i.e., there are no timelock constraints restricting this transaction from being mined immediately.
pub fn is_lock_time_enabled(&self) -> bool
pub fn is_lock_time_enabled(&self) -> bool
Returns true
if this transactions nLockTime is enabled (BIP-65).
pub fn script_pubkey_lens(&self) -> impl Iterator<Item = usize>
pub fn script_pubkey_lens(&self) -> impl Iterator<Item = usize>
Returns an iterator over lengths of script_pubkey
s in the outputs.
This is useful in combination with [predict_weight
] if you have the transaction already
constructed with a dummy value in the fee output which you’ll adjust after calculating the
weight.
pub fn total_sigop_cost<S>(&self, spent: S) -> usize
pub fn total_sigop_cost<S>(&self, spent: S) -> usize
Counts the total number of sigops.
This value is for pre-taproot transactions only.
In taproot, a different mechanism is used. Instead of having a global per-block limit, there is a per-transaction-input limit, proportional to the size of that input. ref: https://bitcoin.stackexchange.com/questions/117356/what-is-sigop-signature-operation#117359
The spent
parameter is a closure/function that looks up the output being spent by each input
It takes in an [OutPoint
] and returns a [TxOut
]. If you can’t provide this, a placeholder of
|_| None
can be used. Without access to the previous [TxOut
], any sigops in a redeemScript (P2SH)
as well as any segwit sigops will not be counted for that input.
pub fn tx_in(&self, input_index: usize) -> Result<&TxIn, InputsIndexError>
pub fn tx_in(&self, input_index: usize) -> Result<&TxIn, InputsIndexError>
Returns a reference to the input at input_index
if it exists.
pub fn tx_out(&self, output_index: usize) -> Result<&TxOut, OutputsIndexError>
pub fn tx_out(&self, output_index: usize) -> Result<&TxOut, OutputsIndexError>
Returns a reference to the output at output_index
if it exists.
pub fn verify<S>(&self, spent: S) -> Result<(), TxVerifyError>
pub fn verify<S>(&self, spent: S) -> Result<(), TxVerifyError>
Verifies that this transaction is able to spend its inputs.
Shorthand for [Self::verify_with_flags
] with flag bitcoinconsensus::VERIFY_ALL
.
The spent
closure should not return the same [TxOut
] twice!
Trait Implementations§
Source§impl BorshDeserialize for CircuitTransaction
impl BorshDeserialize for CircuitTransaction
fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self>
§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSerialize for CircuitTransaction
impl BorshSerialize for CircuitTransaction
Source§impl Clone for CircuitTransaction
impl Clone for CircuitTransaction
Source§fn clone(&self) -> CircuitTransaction
fn clone(&self) -> CircuitTransaction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for CircuitTransaction
impl Debug for CircuitTransaction
Source§impl Deref for CircuitTransaction
impl Deref for CircuitTransaction
Source§impl DerefMut for CircuitTransaction
impl DerefMut for CircuitTransaction
Source§impl From<CircuitTransaction> for Transaction
impl From<CircuitTransaction> for Transaction
Source§fn from(val: CircuitTransaction) -> Self
fn from(val: CircuitTransaction) -> Self
Source§impl From<Transaction> for CircuitTransaction
impl From<Transaction> for CircuitTransaction
Source§impl Hash for CircuitTransaction
impl Hash for CircuitTransaction
Source§impl PartialEq for CircuitTransaction
impl PartialEq for CircuitTransaction
impl Eq for CircuitTransaction
impl StructuralPartialEq for CircuitTransaction
Auto Trait Implementations§
impl Freeze for CircuitTransaction
impl RefUnwindSafe for CircuitTransaction
impl Send for CircuitTransaction
impl Sync for CircuitTransaction
impl Unpin for CircuitTransaction
impl UnwindSafe for CircuitTransaction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T, U> ExactFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> ExactFrom<T> for Uwhere
U: TryFrom<T>,
fn exact_from(value: T) -> U
§impl<T, U> ExactInto<U> for Twhere
U: ExactFrom<T>,
impl<T, U> ExactInto<U> for Twhere
U: ExactFrom<T>,
fn exact_into(self) -> U
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
fn overflowing_into(self) -> (U, bool)
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T, U> RoundingInto<U> for Twhere
U: RoundingFrom<T>,
impl<T, U> RoundingInto<U> for Twhere
U: RoundingFrom<T>,
fn rounding_into(self, rm: RoundingMode) -> (U, Ordering)
§impl<T, U> SaturatingInto<U> for Twhere
U: SaturatingFrom<T>,
impl<T, U> SaturatingInto<U> for Twhere
U: SaturatingFrom<T>,
fn saturating_into(self) -> U
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.