Module transaction

Module transaction 

Source
Expand description

Transaction handling and digital signature functionality.

This module provides functionality for creating, managing, and signing blockchain transactions. It supports single and multi-signature transactions using ECDSA with the secp256k1 curve.

§Features

  • Transaction creation and management
  • Transaction ID generation
  • Single and multi-signature support
  • GTV (Generic Tree Value) encoding

§Example

use crate::utils::transaction::{Transaction, TransactionStatus};

let brid = "FA189BEBA886669CF7DF7DB3D8CFD878D1F80ED360BDCF26B43ABE3D9B3D53CC"; // Replace with actual blockchain RID

let brid_to_vec = hex::decode(brid).unwrap();
 
// Create a new transaction
let mut tx = Transaction::new(
    brid_to_vec,    // blockchain RID
    Some(vec![]),   // operations
    None,           // signers
    None            // signatures
);

// Sign the transaction
let private_key1 = "C70D5A77CC10552019179B7390545C46647C9FCA1B6485850F2B913F87270300";  // Replace with actual private key
tx.sign(&hex::decode(private_key1).unwrap().try_into().expect("Invalid private key 1")).expect("Failed to sign transaction");

// Multi sign the transaction
let private_key2 = "17106092B72489B785615BD2ACB2DDE8D0EA05A2029DCA4054987494781F988C";  // Replace with actual private key
tx.sign(&[
&hex::decode(private_key1).unwrap().try_into().expect("Invalid private key 1"),
&hex::decode(private_key2).unwrap().try_into().expect("Invalid private key 2")
]).expect("Failed to multi sign transaction");

// Sign the transaction from raw private key
tx.sign_from_raw_priv_key(private_key1);

// Multi sign the transaction from raw private keys
tx.multi_sign_from_raw_priv_keys(&[private_key1, private_key2]);

Structs§

Transaction
Represents a blockchain transaction with operations and signatures.
TransactionConfirmationProofData

Enums§

TransactionStatus
Represents the current status of a transaction in the blockchain.