v1.0 Beta — Mainnet Compatible

The XRP Ledger,
reimplemented in Rust

56,000 lines of memory-safe Rust. Full peer protocol. Full consensus. 22 transaction types. Connects to the live XRPL network today.

56,275
Lines of Rust
138
Source Files
22
TX Types
250+
Tests
Why xLedgRS

Built for the next decade of XRPL infrastructure

A ground-up rewrite that brings modern systems engineering to the XRP Ledger without compromising on protocol compatibility.

🛡

Compile-Time Memory Safety

Written entirely in Rust. Buffer overflows, use-after-free, data races, and null pointer dereferences are eliminated by the compiler — not by hope. No garbage collector overhead. No manual memory management mistakes.

Async-Native Architecture

Built on Tokio from the ground up. Every peer connection, RPC request, WebSocket subscription, and consensus timer runs on an async executor. No thread-per-connection. No blocking I/O on the critical path.

🔗

Full Network Compatibility

Speaks the exact same RTXP protocol as rippled. Connects to existing peers, syncs the full account state tree via SHAMap download, and validates transactions against the live network. Drop-in network participant.

💾

Dual-Layer Persistence

NuDB for content-addressed Merkle tree nodes (SHAMap) with 256MB cache. SQLite in WAL mode for relational data (ledger headers, transaction index, metadata). Crash-safe, delta-based writes between ledger closes.

🌐

Full Consensus Implementation

Implements the XRP Ledger Consensus Protocol: proposal rounds with convergence thresholds (50% → 65% → 70% → 80%), UNL quorum validation, manifest-based ephemeral key delegation, and amendment tracking.

📊

rippled-Compatible APIs

JSON-RPC with 15+ methods (server_info, account_info, tx, ledger, book_offers, submit, sign, and more). WebSocket API with subscribe/unsubscribe for live ledger events. Same response format — existing tools just work.

Architecture

Modular design, proven patterns

Mirrors rippled's battle-tested architecture — the view stack, SHAMap, consensus rounds — while leveraging Rust's type system for correctness.

View Stack (Transaction Application)

ClosedLedger
ReadView
OpenView
TxsRawView
ApplyViewImpl
ApplyView
New Ledger
Validated

Consensus Phases

Open
Collect TXs
Establish
Exchange proposals
Accept
Apply TX set
Validate
80% UNL quorum

Source Modules

crypto/
secp256k1 & Ed25519 keys, base58check encoding, SHA-512-Half, RIPEMD160, account ID derivation, family seed encode/decode
transaction/
STObject canonical binary serialization, field catalog with type/field codes, binary parser for all field types, fluent transaction builder with multi-algorithm signing
ledger/
Radix-16 Merkle tree (SHAMap), view stack, state table, 22 transaction handlers, order book with BTreeMap price-time priority, directory management, metadata generation
consensus/
Proposal & validation rounds, manifest delegation (master → ephemeral key), convergence thresholds with UNL quorum, amendment tracking
network/
RTXP framing (6-byte uncompressed / 10-byte LZ4 compressed), HTTP upgrade handshake with session-hash signing, peer state machine (connecting → connected → active)
rpc/
JSON-RPC dispatcher with 15+ rippled-compatible methods, WebSocket server with subscribe/unsubscribe, live ledger/transaction/validation event streams
sync/
Peer-based SHAMap state download with multi-peer fan-out, progressive tree sync with missing-node detection, NuDB content-addressed persistence, 7-9K objects/sec sustained
node/
Central event loop orchestrating all subsystems: peer accept/dial, RTXP message dispatch, RPC serving, consensus timer, sync coordination, follower replay engine
Protocol

Wire-compatible with every rippled node

xLedgRS implements the complete XRPL peer protocol. Every message, every handshake field, every compression mode.

Peer Handshake

  • TLS 1.2 with self-signed certificates (OpenSSL)
  • HTTP upgrade with session-signature verification
  • Headers: Network-ID, Network-Time, Public-Key, Session-Signature, Instance-Cookie, Closed-Ledger, Previous-Ledger, X-Protocol-Ctl
  • Bidirectional RTXP message stream post-upgrade

Message Framing (RTXP)

  • 6-byte header for uncompressed messages
  • 10-byte header for LZ4-compressed messages
  • Protobuf-encoded payloads (prost, proto2 schema)
  • Generated from rippled's official xrpl.proto

Supported Message Types

  • TMProposeSet — validator proposals
  • TMValidation — ledger validations
  • TMManifests — ephemeral key delegation
  • TMTransaction — transaction relay
  • TMGetLedger / TMLedgerData — state sync
  • TMEndpoints — peer discovery (v2 with IPv6)
  • TMStatusChange — node status broadcasts
  • TMPing / TMPong — latency measurement
  • TMSquelch — validator suppression

Cryptographic Primitives

  • secp256k1 ECDSA — signing & verification
  • Ed25519 — signing & verification
  • SHA-512-Half — primary hash (first 256 bits of SHA-512)
  • SHA-256 + RIPEMD-160 — account ID derivation
  • HMAC-SHA-512 — key derivation from family seeds
  • Base58Check — XRPL custom alphabet encoding

SHAMap — The Merkle State Tree

The XRP Ledger stores all account state in a radix-16 Merkle tree called the SHAMap. Each leaf node contains a serialized ledger entry (AccountRoot, Offer, RippleState, etc.) keyed by its SHA-512-Half hash. Inner nodes aggregate 16 child hashes into a single parent hash, enabling efficient proof-of-inclusion and incremental state sync.

xLedgRS implements the SHAMap with NuDB-backed content-addressed storage, a 256MB LRU cache for hot inner nodes, and a sparse overlay mode for follower nodes that only materializes branches that change between ledgers.

Transaction Engine

22 transaction types, parity-tested against rippled

Each handler implements the full lifecycle: preflight validation, preclaim checks, state application, and metadata generation.

Payment
OfferCreate
OfferCancel
TrustSet
AccountSet
AccountDelete
SetRegularKey
EscrowCreate
EscrowFinish
EscrowCancel
PayChanCreate
PayChanFund
PayChanClaim
CheckCreate
CheckCash
CheckCancel
NFTokenMint
NFTokenBurn
NFTCreateOffer
NFTAcceptOffer
NFTCancelOffer
TicketCreate
DepositPreauth

DEX Engine

The OfferCreate handler implements the full XRPL decentralized exchange: order book crossing with quality-sorted BTreeMap iteration, partial fills with IOU precision arithmetic (16-digit mantissa, round-half-even normalization matching rippled's STAmount), self-offer replacement, ticket-based sequence management, reserve checks (tecINSUFFICIENT_RESERVE), and funding validation (tecUNFUNDED_OFFER).

RPC Methods

MethodDescription
server_infoNode status, peer count, memory, uptime, validated ledger
account_infoAccount balance, sequence, owner count, flags
account_linesTrust lines with balances and limits
account_offersOpen DEX orders for an account
account_txTransaction history per account
txLook up transaction by hash
ledgerLedger header by sequence or "validated"
ledger_dataAll ledger objects (paginated)
book_offersOrder book for a currency pair
submitSubmit a signed transaction
signServer-side transaction signing (all 22 types)
feeCurrent transaction fee (escalation-aware)
featureAmendment status
ripple_path_findCross-currency pathfinding
pingConnectivity check
Quick Start

Build and connect in under 5 minutes

Requires Rust 1.75+, OpenSSL dev headers, and a network connection.

Terminal
# Clone and build (release mode, ~2 min)
git clone https://github.com/realJDP/xLedgRS.git
cd xrpl-rs
cargo build --release

# Run on mainnet as a follower node
./target/release/xledgrs --config cfg/xrplnode.cfg

# Run on testnet
./target/release/xledgrs --config cfg/testnet.cfg

# Query your node
curl -s http://127.0.0.1:5005 \
  -d '{"method":"server_info"}' | jq .result.info

# Check account balance
curl -s http://127.0.0.1:5005 \
  -d '{"method":"account_info","params":[{"account":"rN7n3473SaZBCG4dFL83w7p1W9cgZw6iTP"}]}' | jq .
cfg/xrplnode.cfg
# rippled-compatible configuration format

[server]
port_rpc
port_peer

[port_rpc]
port = 5005
ip = 0.0.0.0
protocol = http

[port_peer]
port = 51235
ip = 0.0.0.0
protocol = peer

[ips]
s1.ripple.com 51235
s2.ripple.com 51235
r.ripple.com 51235

[peers_max]
21

[node_db]
path=./data

[xrpl_rs]
enable_consensus_close_loop = 1

System Requirements

Build

Rust 1.75+ (stable)
OpenSSL dev headers
protoc (prost-build)
~2 min build time

Runtime

Linux x86_64 (primary)
macOS ARM64 (dev)
512 MB RAM (follower)
~10 GB disk (state)

Network

Port 51235 (peer)
Port 5005 (JSON-RPC)
Port 6006 (WebSocket)
Outbound TCP required

Comparison

How xLedgRS compares to rippled

Feature-by-feature comparison against the reference C++ implementation.

Capabilityrippled (C++)xLedgRS (Rust)
LanguageC++17Rust (memory-safe)
Async ModelBoost.AsioTokio (async/await)
Peer Protocol (RTXP)FullFull
TLS + Session SignaturesFullFull
Consensus ProtocolFullFull
State Sync (Peer)FullFull (7-9K obj/sec)
Ledger FollowingFullFull
Transaction Engine30+ types22 types
JSON-RPC APIFull (~50 methods)15 methods
WebSocket APIFullsubscribe/unsubscribe
DEX Order BookFullFull (BTreeMap quality sort)
NFToken SupportFullMint/Burn/Offer/Accept
Escrow & PayChanFullFull
ChecksFullFull
Validator ModeFullIn Progress
Amendment VotingFullTracking Only
History ShardingFullPlanned
Config Formatrippled .cfgrippled .cfg + TOML
Build SystemCMake + ConanCargo (single command)
Binary Size~80 MB~13 MB
Dependencies

Minimal, audited, production-grade

No framework bloat. Every dependency earns its place.

tokioAsync runtime
prostProtobuf codec
opensslTLS + session sigs
rustlsTLS (ring backend)
secp256k1ECDSA signing
ed25519-dalekEd25519 signing
sha2 / sha3Hash functions
ripemdAccount ID hash
lz4_flexMessage compression
nudbContent-addressed store
rusqliteSQLite (bundled)
serde_jsonJSON serialization
tokio-tungsteniteWebSocket server
clapCLI argument parsing
tracingStructured logging
arc-swapLock-free atomics
num-bigintArbitrary precision
rcgenCertificate generation

Open Source. MIT Licensed.

Built in the open. Contributions welcome.
Run it, fork it, improve it.