XRPL Binary Codec

Functions for encoding objects into the XRP Ledger’s canonical binary format and decoding them.

exception xrpl.core.binarycodec.XRPLBinaryCodecException

Bases: XRPLException

General XRPL Binary Codec Exception.

xrpl.core.binarycodec.decode(buffer: str) Dict[str, Any]

Decode a transaction from binary format to a JSON-like dictionary representation.

Parameters:

buffer – The encoded transaction binary, as a hexadecimal string.

Returns:

A JSON-like dictionary representation of the transaction.

xrpl.core.binarycodec.encode(json: Dict[str, Any]) str

Encode a transaction or other object into the canonical binary format.

Parameters:

json – A JSON-like dictionary representation of an object.

Returns:

The binary-encoded object, as a hexadecimal string.

xrpl.core.binarycodec.encode_for_multisigning(json: Dict[str, Any], signing_account: str) str

Encode a transaction into binary format in preparation for providing one signature towards a multi-signed transaction. (Only encodes fields that are intended to be signed.)

Parameters:
  • json – A JSON-like dictionary representation of a transaction.

  • signing_account – The address of the signer who’ll provide the signature.

Returns:

A hex string of the encoded transaction.

xrpl.core.binarycodec.encode_for_signing(json: Dict[str, Any]) str

Encode a transaction into binary format in preparation for signing. (Only encodes fields that are intended to be signed.)

Parameters:

json – A JSON-like dictionary representation of a transaction.

Returns:

The binary-encoded transaction, ready to be signed.

xrpl.core.binarycodec.encode_for_signing_batch(json: BatchSigningDict) str

Encode a Batch transaction’s data to be signed by a BatchSigner.

Serializes the XLS-56 Batch V1_1 signing payload:

BATCH_PREFIX | Account | Sequence | Flags | len(transaction_ids)
    | transaction_ids[] | batch_account [ | signer_account ]

The outer account and sequence bind the signature to a specific Batch, preventing it from being replayed under a different outer account or sequence.

Parameters:

json – A dictionary describing the Batch signing data. Requires the outer Batch account, its sequence value (the Sequence, or the TicketSequence value when a ticket is used), flags, the list of inner transaction_ids, and the batch_account (the BatchSigner.Account the signature binds to). signer_account is the inner Signers entry account for a multi-signed BatchSigner.

Returns:

The binary-encoded Batch signing data, as an uppercase hex string.

xrpl.core.binarycodec.encode_for_signing_claim(json: Dict[str, Any]) str

Encode a payment channel Claim to be signed.

Parameters:

json – A JSON-like dictionary representation of a Claim.

Returns:

The binary-encoded claim, ready to be signed.