Skip to content

Binary Serialization

Elliot. edited this page Jun 24, 2025 · 1 revision
  • The binary serialization code has a definition for UInt96, but there's no field of that type. It’s among the few types (eg. uint512) using the same base_uint class that don’t have use right now.
  • What are the differences between the UInt160 and STCurrency binary types?
    • UInt160 is only used in TakerPaysCurrency, TakerPaysIssuer, TakerGetsCurrency, and TakerGetsIssuer fields (i.e. order book DirectoryNode ledger entries).
    • Currency is only used in BaseAsset and QuoteAsset (i.e. Price Oracles).
    • Aside from the type ID, there is no difference in how they're serialized to binary. The binary should be the same.
    • We cannot update the code to use the same data type for all objects because they have different type IDs. With different type IDs, the binary for an object containing those fields would not be the same, even if the binary inside those fields is the same. It would be impractical to convert them over now, because there are hashed ledger entries containing both types.
    • The JSON representation is different. Plain UInt160 fields just get serialized to hex (even if they contain an account ID—it's kind of an oversight in the original DirectoryNode that it uses UInt160 instead of AccountID for the issuer fields) whereas STCurrency can be shortened to 3 char ISO-like codes if they match the standard Currency format.
Clone this wiki locally