pub struct Transaction { /* private fields */ }
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub fn match_output(&self, criteria: &MatchCriteria) -> Option<usize>
pub fn match_output(&self, criteria: &MatchCriteria) -> Option<usize>
Returns the first output index that matches the given parameters, returns None or null if not found.
Sourcepub fn match_outputs(&self, criteria: &MatchCriteria) -> Vec<usize>
pub fn match_outputs(&self, criteria: &MatchCriteria) -> Vec<usize>
Returns a list of outputs indexes that match the given parameters
Sourcepub fn match_input(&self, criteria: &MatchCriteria) -> Option<usize>
pub fn match_input(&self, criteria: &MatchCriteria) -> Option<usize>
Returns the first input index that matches the given parameters, returns None or null if not found.
Sourcepub fn match_inputs(&self, criteria: &MatchCriteria) -> Vec<usize>
pub fn match_inputs(&self, criteria: &MatchCriteria) -> Vec<usize>
Returns a list of input indexes that match the given parameters
Source§impl Transaction
impl Transaction
Sourcepub fn hash_inputs(&mut self, sighash: SigHash) -> Vec<u8> ⓘ
pub fn hash_inputs(&mut self, sighash: SigHash) -> Vec<u8> ⓘ
(hashPrevouts) https://github.com/bitcoincashorg/bitcoincash.org/blob/master/spec/replay-protected-sighash.md Checks the hash cache to see if there already are hashed inputs, otherwise calculates the hash and adds it to the cache.
Logic:
- If SigHash does not contain ANYONECANPAY, SHA256d all input outpoints
- Else 32 bytes of zeroes
Source§impl Transaction
impl Transaction
pub fn verify(&self, pub_key: &PublicKey, sig: &SighashSignature) -> bool
Source§impl Transaction
impl Transaction
pub fn sign( &mut self, priv_key: &PrivateKey, sighash: SigHash, n_tx_in: usize, unsigned_script: &Script, value: u64, ) -> Result<SighashSignature, BSVErrors>
pub fn sign_with_k( &mut self, priv_key: &PrivateKey, ephemeral_key: &PrivateKey, sighash: SigHash, n_tx_in: usize, unsigned_script: &Script, value: u64, ) -> Result<SighashSignature, BSVErrors>
pub fn sighash_preimage( &mut self, sighash: SigHash, n_tx_in: usize, unsigned_script: &Script, value: u64, ) -> Result<Vec<u8>, BSVErrors>
Source§impl Transaction
Platform Agnostic Functions
ie. Don’t need Result<T, E>
impl Transaction
Platform Agnostic Functions ie. Don’t need Result<T, E>
pub fn get_version(&self) -> u32
pub fn get_ninputs(&self) -> usize
pub fn get_noutputs(&self) -> usize
pub fn get_input(&self, index: usize) -> Option<TxIn>
pub fn get_output(&self, index: usize) -> Option<TxOut>
pub fn get_n_locktime(&self) -> u32
pub fn get_n_locktime_as_bytes(&self) -> Vec<u8> ⓘ
Sourcepub fn new(version: u32, n_locktime: u32) -> Transaction
pub fn new(version: u32, n_locktime: u32) -> Transaction
Creates a new empty transaction where you need to add inputs and outputs Transaction.add_input(TxIn) and Transaction.add_output(TxOut)
pub fn default() -> Transaction
pub fn set_version(&mut self, version: u32) -> Transaction
pub fn set_nlocktime(&mut self, n_locktime: u32) -> Transaction
pub fn add_input(&mut self, input: &TxIn)
pub fn prepend_input(&mut self, input: &TxIn)
pub fn insert_input(&mut self, index: usize, input: &TxIn)
pub fn add_output(&mut self, output: &TxOut)
pub fn prepend_output(&mut self, output: &TxOut)
pub fn insert_output(&mut self, index: usize, output: &TxOut)
pub fn set_input(&mut self, index: usize, input: &TxIn)
pub fn set_output(&mut self, index: usize, output: &TxOut)
pub fn is_coinbase_impl(&self) -> bool
Sourcepub fn satoshis_in(&self) -> Option<u64>
pub fn satoshis_in(&self) -> Option<u64>
XT Method: Returns the combined sum of all input satoshis. If any of the inputs dont have satoshis defined, this returns None or null
Sourcepub fn satoshis_out(&self) -> u64
pub fn satoshis_out(&self) -> u64
Returns the combined sum of all output satoshis.
Source§impl Transaction
Native Specific Functions
impl Transaction
Native Specific Functions
Sourcepub fn get_id_hex(&self) -> Result<String, BSVErrors>
pub fn get_id_hex(&self) -> Result<String, BSVErrors>
Gets the ID of the current transaction as a hex string.
Sourcepub fn get_id_bytes(&self) -> Result<Vec<u8>, BSVErrors>
pub fn get_id_bytes(&self) -> Result<Vec<u8>, BSVErrors>
Gets the ID of the current transaction as a Vec
Sourcepub fn get_size(&self) -> Result<usize, BSVErrors>
pub fn get_size(&self) -> Result<usize, BSVErrors>
Get size of current serialised Transaction object
pub fn from_hex(hex_str: &str) -> Result<Transaction, BSVErrors>
pub fn from_bytes(tx_bytes: &[u8]) -> Result<Transaction, BSVErrors>
pub fn to_json_string(&self) -> Result<String, BSVErrors>
pub fn from_json_string(json_string: &str) -> Result<Transaction, BSVErrors>
pub fn to_json(&self) -> Result<Value, BSVErrors>
pub fn to_bytes(&self) -> Result<Vec<u8>, BSVErrors>
pub fn to_hex(&self) -> Result<String, BSVErrors>
pub fn to_compact_hex(&self) -> Result<String, BSVErrors>
pub fn add_inputs(&mut self, tx_ins: Vec<TxIn>)
pub fn add_outputs(&mut self, tx_outs: Vec<TxOut>)
pub fn get_outpoints(&mut self) -> Vec<Vec<u8>>
Sourcepub fn to_compact_bytes(&self) -> Result<Vec<u8>, BSVErrors>
pub fn to_compact_bytes(&self) -> Result<Vec<u8>, BSVErrors>
Serialises this entire transaction to CBOR, preserving all fields from the standard Transaction format + XT
Sourcepub fn from_compact_bytes(compact_buffer: &[u8]) -> Result<Self, BSVErrors>
pub fn from_compact_bytes(compact_buffer: &[u8]) -> Result<Self, BSVErrors>
Deserialises the provided CBOR buffer to the XT format
pub fn from_compact_hex(compact_hex: &str) -> Result<Self, BSVErrors>
pub fn is_coinbase(&self) -> bool
Trait Implementations§
Source§impl Clone for Transaction
impl Clone for Transaction
Source§fn clone(&self) -> Transaction
fn clone(&self) -> Transaction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more