/// Prepares a transaction for signing and reliable submission by
/// auto-filling required fields.
///
/// ## Links
///
/// - https://xrpl.org/reliable-transaction-submission.html
Prepares a transaction for signing and reliable submission by
auto-filling required fields.
Prepares a transaction for signing and reliable submission by auto - filling required fields .
pub async fn prepare_transaction(&self, tx: Transaction) -> Result<Transaction> {
        let mut tx = tx;
        if tx.sequence.is_none() {
            let resp = self.account_info(&tx.account).send().await?;
            tx.sequence = Some(resp.account_data.sequence);
        }
        if tx.last_ledger_sequence.is_none() || tx.fee.is_none() {
            let resp = self.server_state().send().await?;
            // The recommendation for backend applications is to use (last validated ledger index + 4).
            tx.last_ledger_sequence = Some(resp.state.validated_ledger.seq + 4);
            tx.fee = Some(resp.state.validated_ledger.base_fee);
        }
        Ok(tx)
    }
pub async fn prepare_transaction ( & self , tx : Transaction ) -> Result < Transaction > { let mut tx = tx ; if tx . sequence . is_none ( ) { let resp = self . account_info ( & tx . account ) . send ( ) . await ? ; tx . sequence = Some ( resp . account_data . sequence ) ; } if tx . last_ledger_sequence . is_none ( ) || tx . fee . is_none ( ) { let resp = self . server_state ( ) . send ( ) . await ? ; // The recommendation for backend applications is to use (last validated ledger index + 4). tx . last_ledger_sequence = Some ( resp . state . validated_ledger . seq + 4 ) ; tx . fee = Some ( resp . state . validated_ledger . base_fee ) ; } Ok ( tx ) }
Prepares a transaction for signing and reliable submission by
auto-filling required fields.
Prepares a transaction for signing and reliable submission by auto - filling required fields .
&self
tx
Transaction
links
None