Package org.xrpl.xrpl4j.codec.binary
Class XrplBinaryCodec
java.lang.Object
org.xrpl.xrpl4j.codec.binary.XrplBinaryCodec
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDecodes canonical XRPL binary hex encoded transaction string to JSON.Encodes JSON to canonical XRPL binary as a hex string.encodeForBatchInnerMultiSigning(Batch batch, Address signerAddress) Encode aBatchfor multi-signing by a specific signer.encodeForBatchInnerSigning(Batch batch) Encodes aBatchtransaction to canonical XRPL binary as a hex string for signing purposes.encodeForMultiSigning(String json, String xrpAccountId) Encodes JSON to canonical XRPL binary as a hex string for signing purposes.encodeForSigning(String json) Encodes JSON to canonical XRPL binary as a hex string.encodeForSigningClaim(String json) Encodes JSON to canonical XRPL binary as a hex string for signing payment channel claims.static XrplBinaryCodecGet a singleton instance ofXrplBinaryCodec.
-
Field Details
-
TRX_SIGNATURE_PREFIX
- See Also:
-
TRX_MULTI_SIGNATURE_PREFIX
- See Also:
-
PAYMENT_CHANNEL_CLAIM_SIGNATURE_PREFIX
- See Also:
-
BATCH_SIGNATURE_PREFIX
- See Also:
-
CHANNEL_FIELD_NAME
- See Also:
-
AMOUNT_FIELD_NAME
- See Also:
-
-
Constructor Details
-
XrplBinaryCodec
public XrplBinaryCodec()
-
-
Method Details
-
getInstance
Get a singleton instance ofXrplBinaryCodec.- Returns:
- A singleton instance of
XrplBinaryCodec.
-
encode
Encodes JSON to canonical XRPL binary as a hex string. -
encodeForSigning
public String encodeForSigning(String json) throws com.fasterxml.jackson.core.JsonProcessingException Encodes JSON to canonical XRPL binary as a hex string.- Parameters:
json- String containing JSON to be encoded.- Returns:
- hex encoded representations
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- if JSON is not valid.
-
encodeForMultiSigning
public String encodeForMultiSigning(String json, String xrpAccountId) throws com.fasterxml.jackson.core.JsonProcessingException Encodes JSON to canonical XRPL binary as a hex string for signing purposes. -
encodeForBatchInnerSigning
public UnsignedByteArray encodeForBatchInnerSigning(Batch batch) throws com.fasterxml.jackson.core.JsonProcessingException Encodes aBatchtransaction to canonical XRPL binary as a hex string for signing purposes. Note that this function slightly diverges from the pattern of the other encodeForSigning functions because the bytes to be signed for a Batch transaction are not simply the canonical binary representation of the JSON. Instead, we have distinct portions of the Batch transaction that are signed. Also, unlikeencodeForSigning(String), which accepts JSON and then checks for JsonNode values, this implementation instead accepts a well-typed Java object and operates on that, for safety and correctness.- Parameters:
batch- ABatchcontaining JSON to be encoded.- Returns:
- hex encoded representations
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- if JSON is not valid.
-
encodeForBatchInnerMultiSigning
public UnsignedByteArray encodeForBatchInnerMultiSigning(Batch batch, Address signerAddress) throws com.fasterxml.jackson.core.JsonProcessingException Encode aBatchfor multi-signing by a specific signer. This is used when a multi-sig account acts as a BatchSigner with nested Signers. Per rippled's checkBatchMultiSign, this uses batch serialization (serializeBatch) followed by appending the signer's account ID (finishMultiSigningData).- Parameters:
batch- TheBatchto encode.signerAddress- The address of the signer (will be appended as account ID suffix).- Returns:
- An
UnsignedByteArraycontaining the batch serialization with account ID suffix. - Throws:
com.fasterxml.jackson.core.JsonProcessingException- if there is an error processing the JSON.
-
encodeForSigningClaim
public String encodeForSigningClaim(String json) throws com.fasterxml.jackson.core.JsonProcessingException Encodes JSON to canonical XRPL binary as a hex string for signing payment channel claims. The only JSON fields which will be encoded are "Channel" and "Amount".- Parameters:
json- String containing JSON to be encoded.- Returns:
- The binary encoded JSON in hexadecimal form.
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- If the JSON is not valid.
-
decode
Decodes canonical XRPL binary hex encoded transaction string to JSON.
-