Struct clarity_repl::clarity::util::bitcoin::blockdata::transaction::Transaction
source · [−]pub struct Transaction {
pub version: u32,
pub lock_time: u32,
pub input: Vec<TxIn>,
pub output: Vec<TxOut>,
}
Expand description
A Bitcoin transaction, which describes an authenticated movement of coins
Fields
version: u32
The protocol version, should always be 1.
lock_time: u32
Block number before which this transaction is valid, or 0 for valid immediately.
input: Vec<TxIn>
List of inputs
output: Vec<TxOut>
List of outputs
Implementations
sourceimpl Transaction
impl Transaction
sourcepub fn ntxid(&self) -> Sha256dHash
pub fn ntxid(&self) -> Sha256dHash
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.
sourcepub fn txid(&self) -> Sha256dHash
pub fn txid(&self) -> Sha256dHash
Computes the txid. For non-segwit transactions this will be identical
to the output of BitcoinHash::bitcoin_hash()
, but for segwit transactions,
this will give the correct txid (not including witnesses) while bitcoin_hash
will also hash witnesses.
sourcepub fn signature_hash(
&self,
input_index: usize,
script_pubkey: &Script,
sighash_u32: u32
) -> Sha256dHash
pub fn signature_hash(
&self,
input_index: usize,
script_pubkey: &Script,
sighash_u32: u32
) -> Sha256dHash
Computes a signature hash for a given input index with a given sighash flag. To actually produce a scriptSig, this hash needs to be run through an ECDSA signer, the SigHashType appended to the resulting sig, and a script written around this, but this is the general (and hard) part.
Warning This does NOT attempt to support OP_CODESEPARATOR. In general
this would require evaluating script_pubkey
to determine which separators
get evaluated and which don’t, which we don’t have the information to
determine.
Panics
Panics if input_index
is greater than or equal to self.input.len()
sourcepub fn get_weight(&self) -> u64
pub fn get_weight(&self) -> u64
Gets the “weight” of this transaction, as defined by BIP141. For transactions with an empty witness, this is simply the consensus-serialized size times 4. For transactions with a witness, this is the non-witness consensus-serialized size multiplied by 3 plus the with-witness consensus-serialized size.
sourcepub fn is_coin_base(&self) -> bool
pub fn is_coin_base(&self) -> bool
Is this a coin base transaction?
Trait Implementations
sourceimpl BitcoinHash for Transaction
impl BitcoinHash for Transaction
sourcefn bitcoin_hash(&self) -> Sha256dHash
fn bitcoin_hash(&self) -> Sha256dHash
Produces a Sha256dHash which can be used to refer to the object
sourceimpl Clone for Transaction
impl Clone for Transaction
sourcefn clone(&self) -> Transaction
fn clone(&self) -> Transaction
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<D: SimpleDecoder> ConsensusDecodable<D> for Transaction
impl<D: SimpleDecoder> ConsensusDecodable<D> for Transaction
sourcefn consensus_decode(d: &mut D) -> Result<Transaction, Error>
fn consensus_decode(d: &mut D) -> Result<Transaction, Error>
Decode an object with a well-defined format
sourceimpl<S: SimpleEncoder> ConsensusEncodable<S> for Transaction
impl<S: SimpleEncoder> ConsensusEncodable<S> for Transaction
sourceimpl Debug for Transaction
impl Debug for Transaction
sourceimpl Hash for Transaction
impl Hash for Transaction
sourceimpl PartialEq<Transaction> for Transaction
impl PartialEq<Transaction> for Transaction
sourcefn eq(&self, other: &Transaction) -> bool
fn eq(&self, other: &Transaction) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &Transaction) -> bool
fn ne(&self, other: &Transaction) -> bool
This method tests for !=
.
impl Eq for Transaction
impl StructuralEq for Transaction
impl StructuralPartialEq for Transaction
Auto Trait Implementations
impl RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl UnwindSafe for Transaction
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcepub fn equivalent(&self, key: &K) -> bool
pub fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more