Package com.tuladb

Class Codec

java.lang.Object
com.tuladb.Codec

public final class Codec extends Object
  • Field Details

  • Method Details

    • normalizeTxnIdForKey

      public static String normalizeTxnIdForKey(String txnId)
    • buildTransferIdCanonicalInput

      public static byte[] buildTransferIdCanonicalInput(long sourceId, int ledgerId, int currency, String txnId)
      ledgerId and currency are the engine's u32s carried in a Java int, as everywhere on this SDK's wire: a value of 2^31 or more arrives negative and is read UNSIGNED ((int) 3_000_000_000L is ledger 3000000000). The long overloads take the plain value. Ledger ids above LEDGER_ID_CLIENT_MAX (0xFFFFFFEF) are the engine's reserved range and are refused, which also catches a stray -1.
    • buildTransferIdCanonicalInput

      public static byte[] buildTransferIdCanonicalInput(long sourceId, long ledgerId, long currency, String txnId)
      As above, with ledger and currency as plain (non-negative) u32 values.
    • deriveTransferIdBytes

      public static byte[] deriveTransferIdBytes(long sourceId, int ledgerId, int currency, String txnId)
    • deriveTransferIdBytes

      public static byte[] deriveTransferIdBytes(long sourceId, int ledgerId, int currency, String txnId, boolean useIso20022RefSize)
    • deriveTransferIdBytes

      public static byte[] deriveTransferIdBytes(long sourceId, long ledgerId, long currency, String txnId, boolean useIso20022RefSize)
      As above, with ledger and currency as plain u32 values (see buildTransferIdCanonicalInput).
    • transferIdFromBytes

      public static String transferIdFromBytes(byte[] raw)
    • transferIdFromBytes

      public static String transferIdFromBytes(byte[] raw, boolean useIso20022RefSize)
      Format a 32-byte wire transfer id in the client's id mode: 35-char Base62 (bytes 0..25) or 64-char hex. In Base62 mode a non-zero byte 26..31 throws Codec.TransferIdModeException instead of being dropped.
    • deriveTransferId

      public static String deriveTransferId(long sourceId, int ledgerId, int currency, String txnId)
    • deriveTransferId

      public static String deriveTransferId(long sourceId, int ledgerId, int currency, String txnId, boolean useIso20022RefSize)
    • deriveTransferId

      public static String deriveTransferId(long sourceId, long ledgerId, long currency, String txnId, boolean useIso20022RefSize)
      As above, with ledger and currency as plain u32 values.
    • encode

      public static byte[] encode(Models.LedgerInstance l)
    • decodeLedgerInstance

      public static Models.LedgerInstance decodeLedgerInstance(byte[] payload, int offset)
    • encodeLedgerGet

      public static byte[] encodeLedgerGet(int ledgerId)
    • encodeLedgerSourceAllow

      public static byte[] encodeLedgerSourceAllow(int ledgerId, int sourceNumeric)
    • encode

      public static byte[] encode(Models.SourceInstance s)
    • decodeSourceInstance

      public static Models.SourceInstance decodeSourceInstance(byte[] payload, int offset)
    • encodeSourceGet

      public static byte[] encodeSourceGet(int numeric)
    • encodeSourceSetActive

      public static byte[] encodeSourceSetActive(int numeric, boolean active)
    • encodeAccountKey

      public static byte[] encodeAccountKey(Models.AccountKey key)
      A bare WireAccountKey (32 bytes).
    • encodeGetBalance

      public static byte[] encodeGetBalance(Models.AccountKey key, long minBatchSeq)
      GET_BALANCE: the key (32 B); with a non-zero read-your-writes token, the key then the u64 batch_seq the read must have applied through (40 B).
    • encodeAccountSetActive

      public static byte[] encodeAccountSetActive(Models.AccountKey key, boolean active)
    • encodeListAccountBalances

      public static byte[] encodeListAccountBalances(int ledgerId, long accountHi, long accountLo)
      LIST_ACCOUNT_BALANCES (0x2C): {u32 ledger_id; u32 0; u64 0; u128 id} (32 B).
    • decodeAccountBalanceRow

      public static Models.AccountBalance decodeAccountBalanceRow(byte[] payload, int offset)
      One 64-byte WireAccountBalanceRow at offset.
    • decodeListAccountBalances

      public static List<Models.AccountBalance> decodeListAccountBalances(byte[] payload)
      [u32 count][u32 pad][count x 64-byte rows], one row per currency.
    • encode

      public static byte[] encode(Models.CurrencyInstance ci)
    • decodeCurrencyInstance

      public static Models.CurrencyInstance decodeCurrencyInstance(byte[] payload, int offset)
    • encodeCurrencyGet

      public static byte[] encodeCurrencyGet(int numeric)
    • encodeCurrencySetActive

      public static byte[] encodeCurrencySetActive(int numeric, boolean active)
    • encode

      public static byte[] encode(Models.AccountCreate a)
    • encode

      public static byte[] encode(Models.TransferCreate t)
    • encode

      public static byte[] encode(Models.TieredTransferCreate t)
    • encodeTransferId

      public static byte[] encodeTransferId(String transferId, boolean useIso20022RefSize)
    • encodeTransferId

      public static byte[] encodeTransferId(String transferId)
    • encodeGetHistory

      public static byte[] encodeGetHistory(Models.AccountKey key, long afterSeq, int limit)
    • encodeGetHistory

      public static byte[] encodeGetHistory(Models.AccountKey key, long afterSeq, int afterIndex, int limit)
      Composite pagination cursor (M1). A batch shares one batch_seq across all of its records, so a batch larger than one page must resume mid-batch on batch_index or its overflow rows are re-emitted (or dropped); the server orders by (batch_seq, batch_index) strictly after (afterSeq, afterIndex). afterIndex 0 resumes at the batch start — the original behaviour. Mirrors encodeListTransfers(long, int, int); the WireGetHistory after_index field lives at offset 44, after the 32-byte key.
    • encodeGetAccountHistory

      public static byte[] encodeGetAccountHistory(Models.AccountKey key, long afterTimestamp, int limit)
    • encodeListAccounts

      public static byte[] encodeListAccounts(int offset, int limit)
    • encodeListTransfers

      public static byte[] encodeListTransfers(long afterSeq, int limit)
    • encodeListTransfers

      public static byte[] encodeListTransfers(long afterSeq, int afterIndex, int limit)
      Composite pagination cursor. A batch shares one batch_seq across all of its records, so a batch larger than one page must resume mid-batch on batch_index or its overflow rows are silently dropped; the server orders by (batch_seq, batch_index) strictly after (afterSeq, afterIndex). Zero afterIndex resumes at the batch start.
    • encodeSearchTransactions

      public static byte[] encodeSearchTransactions(Models.TxnSearch search)
    • decodeTransferResult

      public static Models.TransferResult decodeTransferResult(byte[] payload)
    • decodeTransferResult

      public static Models.TransferResult decodeTransferResult(byte[] payload, int overrideStatus)
    • decodeTieredTransferResult

      public static Models.TieredTransferResult decodeTieredTransferResult(byte[] payload)
    • decodeBalance

      public static Models.Balance decodeBalance(byte[] payload)
    • decodeTxnRecord

      public static Models.TxnRecord decodeTxnRecord(byte[] payload)
    • decodeHistory

      public static List<Models.TxnRecord> decodeHistory(byte[] payload)
    • decodeAccountMetadataEvent

      public static Models.AccountMetadataEvent decodeAccountMetadataEvent(byte[] payload)
    • decodeAccountHistory

      public static List<Models.AccountMetadataEvent> decodeAccountHistory(byte[] payload)
    • decodeListTransfers

      public static List<Models.TxnRecord> decodeListTransfers(byte[] payload)
    • decodeClusterStatus

      public static Models.ClusterStatus decodeClusterStatus(byte[] payload)
    • decodeAccountInfo

      public static Models.AccountInfo decodeAccountInfo(byte[] payload)
    • decodeListAccounts

      public static Codec.ListAccountsResult decodeListAccounts(byte[] payload)