Skip to main content

Module serialization

Module serialization 

Source
Expand description

Binary serialization primitives.

Two contexts use slightly different wire formats:

ContextString-length prefixUsed by
Order-ID hashingu32 (4 bytes LE)LimitOrder::order_id()
Transaction signingu64 (8 bytes LE)Transaction::serialize()

Both are little-endian throughout.

Functions§

write_bool
Write a boolean as a single byte (0 or 1).
write_f64
Write an f64 in little-endian.
write_pubkey_bytes
Write a Pubkey’s raw 32 bytes into the buffer.
write_string_u32
Write a length-prefixed UTF-8 string with a u32 length prefix. Used for order-ID hash generation.
write_string_u64
Write a length-prefixed UTF-8 string with a u64 length prefix. Used for transaction serialization (signing).
write_u8
Write a u8 (1 byte).
write_u32
Write a u32 in little-endian.
write_u64
Write a u64 in little-endian.