Transaction Methods
Methods for working with transactions on the XRP Ledger.
- exception xrpl.transaction.XRPLReliableSubmissionException
Bases:
XRPLExceptionGeneral XRPL Reliable Submission Exception.
- xrpl.transaction.autofill(transaction: T, client: SyncClient, signers_count: int | None = None) T
Autofills fields in a transaction. This will set all autofill-able fields according to the current state of the server this Client is connected to. For Batch transactions, it will also handle autofilling inner transactions. It also converts all X-Addresses to classic addresses.
- Parameters:
transaction – the transaction to be signed.
client – a network client.
signers_count – the expected number of signers for this transaction. Only used for multisigned transactions.
- Returns:
The autofilled transaction.
- xrpl.transaction.autofill_and_sign(transaction: T, client: SyncClient, wallet: Wallet, check_fee: bool = True) T
Signs a transaction locally, without trusting external rippled nodes. Autofills relevant fields.
- Parameters:
transaction – the transaction to be signed.
client – a network client.
wallet – the wallet with which to sign the transaction.
check_fee – whether to check if the fee is higher than the expected transaction type fee. Defaults to True.
- Returns:
The signed transaction.
- xrpl.transaction.combine_batch_signers(transactions: List[Batch | str]) str
Takes several transactions with BatchSigners fields (in object or blob form) and creates a single transaction with all BatchSigners that then gets signed and returned.
- Parameters:
transactions – The transactions to combine BatchSigners values on.
- Raises:
XRPLException – If the list of transactions provided is invalid.
- Returns:
A single signed Transaction which has all BatchSigners from transactions within it.
- xrpl.transaction.combine_loanset_counterparty_signers(transactions: List[LoanSet | str]) CombineLoanSetResult
Combines multiple LoanSet transactions signed by the counterparty into a single transaction.
- Parameters:
transactions – An array of signed LoanSet transactions (in object or blob form) to combine.
- Returns:
tx: The combined LoanSet transaction object
tx_blob: The serialized transaction blob (hex string) ready to submit
- Return type:
A CombineLoanSetResult containing
- Raises:
XRPLException – If: - There are no transactions to combine - Any of the transactions are not LoanSet transactions - Any of the transactions do not have Signers in CounterpartySignature - Any of the transactions do not have a first party signature - The transactions are not identical (except for Signers)
- xrpl.transaction.compute_signature(tx_json: Dict[str, Any], private_key: str, sign_as: str | None = None) str
Signs a transaction with the proper signing encoding.
- Parameters:
tx_json – A transaction JSON to sign.
private_key – A key to sign the transaction with.
sign_as – Multisign only. An account address to include in the Signer field. Can be either a classic address or an XAddress.
- Returns:
A signed transaction signature in hex format.
- xrpl.transaction.multisign(transaction: Transaction, tx_list: List[Transaction]) Transaction
Takes several transactions with Signer fields and creates a single transaction with all Signers that then gets signed and returned.
- Parameters:
transaction – the transaction to be multisigned.
tx_list – a list of signed transactions to combine into a single multisigned transaction.
- Returns:
The multisigned transaction.
- xrpl.transaction.sign(transaction: T, wallet: Wallet, multisign: bool = False) T
Signs a transaction locally, without trusting external rippled nodes.
- Parameters:
transaction – the transaction to be signed.
wallet – the wallet with which to sign the transaction.
multisign – whether to sign the transaction for a multisignature transaction.
- Returns:
The signed transaction blob.
- xrpl.transaction.sign_and_submit(transaction: Transaction, client: SyncClient, wallet: Wallet, autofill: bool = True, check_fee: bool = True) Response
Signs a transaction (locally, without trusting external rippled nodes) and submits it to the XRPL.
- Parameters:
transaction – the transaction to be signed and submitted.
client – the network client with which to submit the transaction.
wallet – the wallet with which to sign the transaction.
autofill – whether to autofill the relevant fields. Defaults to True.
check_fee – whether to check if the fee is higher than the expected transaction type fee. Defaults to True.
- Returns:
The response from the ledger.
- xrpl.transaction.sign_loan_set_by_counterparty(wallet: Wallet, transaction: LoanSet | str, multisign: bool | str = False) SignLoanSetResult
Signs a LoanSet transaction as the counterparty.
This function adds a counterparty signature to a LoanSet transaction that has already been signed by the first party. The counterparty uses their wallet to sign the transaction, which is required for multi-party loan agreements on the XRP Ledger.
- Parameters:
wallet – The counterparty’s wallet used for signing the transaction.
transaction – The LoanSet transaction to sign. Can be either: - A LoanSet transaction object that has been signed by the first party - A serialized transaction blob (string) in hex format
multisign – Specify True/False to use multisign or actual address (classic/x-address) to make multisign tx request. The actual address is only needed in the case of regular key usage.
- Returns:
tx: The signed LoanSet transaction object
tx_blob: The serialized transaction blob (hex string) ready to submit
hash: The transaction hash (useful for tracking the transaction)
- Return type:
A SignLoanSetResult containing
- Raises:
XRPLException – If: - The transaction is not a LoanSet transaction - The transaction fails validation checks - The transaction is already signed by the counterparty - The transaction has not been signed by the first party yet
- xrpl.transaction.sign_multiaccount_batch(wallet: Wallet, transaction: Batch, multisign: bool = False) Batch
Sign a multi-account Batch transaction.
- Parameters:
wallet – Wallet instance.
transaction – The Batch transaction to sign.
multisign – Specify true/false to use multisign. Defaults to False.
- Raises:
XRPLException – If the wallet signing the transaction doesn’t have an account in the Batch.
- Returns:
The Batch transaction with the BatchSigner included.
- xrpl.transaction.simulate(transaction: Transaction, client: SyncClient, *, binary: bool = False) Response
Simulates a transaction without actually submitting it to the network.
- Parameters:
transaction – The transaction to simulate.
client – The network client with which to submit the transaction.
binary – Whether the return data should be encoded in the XRPL’s binary format. Defaults to False.
- Raises:
XRPLRequestFailureException – If the transaction fails in the simulated scenario.
- Returns:
The response from the ledger.
- xrpl.transaction.submit(transaction: Transaction, client: SyncClient, *, fail_hard: bool = False) Response
Submits a transaction to the ledger.
- Parameters:
transaction – the Transaction to be submitted.
client – the network client with which to submit the transaction.
fail_hard – an optional boolean. If True, and the transaction fails for the initial server, do not retry or relay the transaction to other servers. Defaults to False.
- Returns:
The response from the ledger.
- Raises:
XRPLRequestFailureException – if the rippled API call fails.
- xrpl.transaction.submit_and_wait(transaction: Transaction, client: SyncClient, wallet: Wallet | None = None, *, check_fee: bool = True, autofill: bool = True, fail_hard: bool = False) Response
Signs a transaction locally, without trusting external rippled nodes (only if the input transaction is unsigned; otherwise, proceeds to the next steps), submits, and verifies that it has been included in a validated ledger (or has errored /will not be included for some reason). See Reliable Transaction Submission
- Parameters:
transaction – the signed/unsigned transaction (or transaction blob) to be submitted.
client – the network client with which to submit the transaction.
wallet – an optional wallet with which to sign the transaction. This is only needed if the transaction is unsigned.
check_fee – an optional bolean indicating whether to check if the fee is higher than the expected transaction type fee. Defaults to True.
autofill – an optional boolean indicating whether to autofill the transaction. Defaults to True.
fail_hard – an optional boolean. If True, and the transaction fails for the initial server, do not retry or relay the transaction to other servers. Defaults to False.
- Returns:
The response from the ledger.
- xrpl.transaction.transaction_json_to_binary_codec_form(dictionary: Dict[str, Any]) Dict[str, Any]
Returns a new dictionary in which the keys have been formatted as CamelCase and standardized to be serialized by the binary codec.
- Parameters:
dictionary – The dictionary to be reformatted.
- Returns:
A new dictionary object that has been reformatted.