Implementing transactions
Transactions in a blockchain network represent the transfer of assets or information between participants. In this section, we dissect the core components of transactions – TXInput
, TXOutput
, and the overarching Transaction
struct. These structures intricately manage inputs, outputs, and transactional data, crucial for secure asset exchanges within the blockchain ecosystem.
All the code we write in this section will be available in the transactions.rs
file.
Understanding TXInput transactions
We have already seen the TXInput
struct in the previous chapter; now, let’s understand the implementation functions for all TXInput
transactions. It will look like the following code:
impl TXInput { pub fn new(txid: &[u8], vout: usize) -> TXInput { TXInput { txid: txid.to_vec(), ...