Binary serialization and deserialization for the XRPL protocol.
This crate implements the canonical binary encoding used by the XRP Ledger for transactions, ledger objects, and other protocol messages.
Architecture
- [
definitions] — Field definitions loaded fromdefinitions.json - [
field_code] — Field ID encoding (1-3 byte headers from type_code/field_code) - [
error] — Codec error types - [
serializer] — Canonical binary serialization - [
deserializer] — Binary to typed objects - [
signing] — Signing-specific serialization with hash prefixes
Examples
Serialize a transaction to binary and deserialize it back:
use json;
use serialize_json_object;
use deserialize_object;
// Build a minimal Payment transaction as JSON
let tx = json!;
// Serialize to canonical binary
let map = tx.as_object.expect;
let mut buf = Vecnew;
serialize_json_object?;
assert!;
// Deserialize back to JSON
let decoded = deserialize_object?;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
# Ok::
Compute a transaction's signing hash and transaction ID:
use json;
use ;
let tx = json!;
let map = tx.as_object.expect;
// Signing hash (for the signer to sign over)
let hash = signing_hash?;
assert_eq!;
// Transaction ID (includes the signature in the hash)
let tx_id = transaction_id_hex?;
assert_eq!; // 32 bytes as uppercase hex
assert!;
# Ok::