Fast native binary decoder for Xahau/XRPL ledger data, built with Rust and napi-rs.
- 🦀 Native Rust implementation (5-35x faster than JS)
- 📦 Node.js bindings via napi-rs
- 🔄 Batch decoding for efficient bulk processing
- 📋 Full Xahau field definitions (Hooks, URITokens, etc.)
# Install Rust (required)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install from git
npm install git+https://github.com/Silkjaer/xahau-binary-decoder.gitThe build will run automatically during npm install via the postinstall script.
For development:
git clone https://github.com/Silkjaer/xahau-binary-decoder.git
cd xahau-binary-decoder
npm install
npm run buildconst decoder = require('xahau-binary-decoder');
// Load definitions (one of these options):
// Option 1: Bundled definitions (from xahau-binary-codec)
decoder.loadDefaultDefinitions();
// Option 2: Load from file
decoder.loadDefinitionsFromFile('./definitions.json');
// Option 3: Fetch from URL
const response = await fetch('https://xahau.network/server_definitions.json');
decoder.loadDefinitions(await response.text());
// Decode transactions
const tx = decoder.decodeTransaction('1200002280000000...');
// Batch decode (more efficient)
const transactions = decoder.decodeTransactionsBatch([
'1200002280000000...',
'1200002280000001...',
]);
// Decode ledger objects
const obj = decoder.decodeLedgerObject('...');decodeTransaction(hexString: string): object- Decode a single transactiondecodeLedgerObject(hexString: string): object- Decode a single ledger objectdecodeTransactionsBatch(hexStrings: string[]): object[]- Batch decode transactionsdecodeLedgerObjectsBatch(hexStrings: string[]): object[]- Batch decode ledger objectssha512Half(hexString: string): string- Compute SHA-512/256 hashloadDefaultDefinitions()- Load bundled definitions (from xahau-binary-codec)loadDefinitions(json: string)- Load definitions from JSON stringloadDefinitionsFromFile(path: string)- Load definitions from filegetDefinitionsInfo()- Get info about loaded definitionsversion(): string- Get module version
Bundled definitions are from the JavaScript xahau-binary-codec package. Supports all Xahau-specific types including Hooks, URITokens, and related transaction/ledger entry types.
MIT