Description

A group of 1 to 100 operations that modify the ledger state.

pub struct Transaction {
		network_passphrase: String,
    tx: stellar_xdr::Transaction,
    signatures: Vec<DecoratedSignature>,
    fee: String,
    envelope_type: stellar_xdr::EnvelopeType,
    memo: stellar_xdr::Memo,
    sequence: String,
    source: String,
    time_bounds: Option<TimeBounds>,
    ledger_bounds: Option<LedgerBounds>,
    min_account_sequence: Option<String>,
    min_account_sequence_age: u32,
    min_account_sequence_ledger_gap: u32,
    extra_signers: Vec<stellar_xdr::AccountId>,
    operations: Vec<stellar_xdr::Operation>,
}

Interface Code

pub trait Transaction {

    // Returns the signatures of the transaction
    fn signatures(&self) -> &Vec<stellar_xdr::DecoratedSignature>;

    // Returns the transaction object
    fn tx(&self) -> stellar_xdr::Transaction;

    // Returns the fee of the transaction
    fn fee(&self) -> &str;

    // Returns the network passphrase of the transaction
    fn network_passphrase(&self) -> &str;

    // Sets the network passphrase of the transaction
    fn set_network_passphrase(&mut self, network_passphrase: &str);

    // Signs the transaction with the given keypairs
    fn sign(&mut self, keypairs: &[Keypair]);

    // Gets the signature of the transaction for the given keypair
    fn get_keypair_signature(&self, keypair: &Keypair) -> String;

    // Adds a signature to the transaction
    fn add_signature(&mut self, public_key: &str, signature: &str);

    // Adds a decorated signature to the transaction envelope
    fn add_decorated_signature(&mut self, signature: stellar_xdr::DecoratedSignature);

    // Signs the transaction with the hashX preimage
    fn sign_hashX(&mut self, preimage: &[u8]);

    // Returns the hash for this transaction
    fn hash(&self) -> Vec<u8>;

    // Returns the signature base for this transaction
    fn signature_base(&self) -> Vec<u8>;

    // Returns the transaction envelope
    fn to_envelope(&self) -> stellar_xdr::TransactionEnvelope;

    // Returns the transaction envelope as a base64-encoded string
    fn to_xdr(&self) -> String;

    // Returns the time bounds of the transaction
    fn time_bounds(&self) -> Option<(String, String)>;

    // Returns the ledger bounds of the transaction
    fn ledger_bounds(&self) -> Option<(u32, u32)>;

    // Returns the minimum account sequence of the transaction
    fn min_account_sequence(&self) -> Option<String>;

    // Returns the minimum account sequence age of the transaction
    fn min_account_sequence_age(&self) -> Option<u64>;

    // Returns the minimum account sequence ledger gap of the transaction
    fn min_account_sequence_ledger_gap(&self) -> Option<u32>;

    // Returns the extra signers of the transaction
    fn extra_signers(&self) -> Option<Vec<String>>;

    // Returns the sequence number of the transaction
    fn sequence(&self) -> &str;

    // Returns the source of the transaction
    fn source(&self) -> &str;

    // Returns the operations of the transaction
    fn operations(&self) -> Vec<stellar_xdr::Operation>;

    // Returns the memo of the transaction
    fn memo(&self) -> &stellar_xdr::Memo;

    // Calculates the claimable balance ID for an operation within the transaction
    fn get_claimable_balance_id(&self, op_index: usize) -> Result<String, String>;
}

Design Considerations

Created TransactionBuilder helper struct to implement a builder pattern for the Transaction module

Interface Code Link

https://github.com/rahul-soshte/rs-stellar-base/blob/main/src/transaction.rs https://github.com/rahul-soshte/rs-stellar-base/blob/main/src/transaction_builder.rs