Component Map
This document describes the 13 XChain Platform services, their roles, inputs, outputs, and connections. Services are grouped by function. For detailed documentation on any individual service, see the corresponding subdirectory under ../components/.
Service Groups
| Group | Services |
|---|---|
| Core Pipeline | decoder, indexer, explorer |
| Transaction Creation | encoder, utxo-tracker, sdk |
| Data Replication | sync |
| Infrastructure | hub, node, regtest-miner, e2e-test |
| Contract Execution | vm |
| Client | wallet |
Core Pipeline
These three services form the backbone of the platform. Data flows from coin node through decoder and indexer to explorer in one direction only.
xchain-decoder
| Purpose | Polls a coin node for blocks, extracts XChain transactions, writes raw decoded data |
| Inputs | Coin node JSON-RPC (getblockcount, getblockhash, getblock, getrawtransaction) |
| Outputs | Decoder MariaDB (XChain_{CHAIN}_{NETWORK}_Decoder) |
| Storage | MariaDB (relational; blocks, transactions, decoded ACTION strings) |
| Communication | Outbound JSON-RPC to coin node; inbound JSON-RPC API on DECODER_API_PORT (default 3002, no API key: ping, health, getlatestblock, getmempool) plus HTTP GET /status and GET /live probes |
Key technical details:
- Parses transactions using bitcoinjs-lib with coin-specific pre-processing: Litecoin requires stripping the HogEx flag; Dogecoin requires stripping AuxPoW merge-mining headers.
- Deobfuscates each output using AES-128-CTR with a key derived from the first input’s txid. Identifies XChain payloads by the
XCHNmagic prefix. - Detects chain reorganizations by comparing stored block hashes. On reorg, rolls back to the last common ancestor before resuming.
- Tracks the mempool separately to support the dispenser protocol (unconfirmed transaction response).
- Runs as one instance per chain/network combination.
See ../components/decoder/ for full documentation.
xchain-indexer
| Purpose | Reads decoded ACTIONs from the Decoder DB, validates them, executes business logic, writes final state |
| Inputs | Decoder MariaDB (SQL polling every 5 seconds); local Hub DB (cross-chain price data) |
| Outputs | Indexer MariaDB (XChain_{CHAIN}_{NETWORK}_Indexer); outbound JSON-RPC pushes to xchain-hub (pushchaintip, pushpriceround, pushoracleprice) |
| Storage | Three database connections: Decoder DB (read), Indexer DB (read/write, 100+ tables), local Hub DB (read, synced from xchain-hub) |
| Communication | Outbound SQL reads from Decoder DB and local Hub DB; outbound HTTP/WebSocket to xchain-hub; inbound JSON-RPC API with no write method (xchain-hub polls read methods such as getownstake, getcapabilityvalidators and getpendingattestation_requests) |
Key technical details:
- Routes each ACTION string to one of 48 dedicated handler classes (
IssueAction,SendAction,OrderAction,PriceAction, etc.). - Validates all fields before execution. Invalid actions are recorded with status
invalidand produce no ledger effects. - Maintains a double-entry ledger: every token movement is a credit to one address and a debit from another. Balance = SUM(credits) - SUM(debits). A sanity check asserts
token_supply == net ledger totalafter each issuance. - Holds XCHAIN gas in escrow for time-bounded operations (orders, dispensers). Releases escrow on expiration or cancellation.
- DEX matching engine handles
ORDERandSWAPactions, matching bids and asks within each block. - Processes expirations after each block: open orders and active dispensers whose expiration timestamp is past the block’s own time are closed automatically. Token-weighted governance polls (
VOTE) are finalized the same way, by a deterministic sweep at each poll’s end block. - All writes for a block are wrapped in a single MariaDB transaction. Either the full block commits or it rolls back entirely.
- On reorg, rolls back across 80+ tables in a single transaction, then re-processes from the reorg block.
- Watchdog timer (5-minute default) restarts the indexer if it hangs during block processing.
- Runs as one instance per chain/network combination.
See ../components/indexer/ for full documentation.
xchain-explorer
| Purpose | Serves REST endpoints, JSON-RPC 2.0, and a web UI over the Indexer DB |
| Inputs | Indexer MariaDB (direct SQL reads); Decoder MariaDB (raw transaction lookups); xchain-hub (config sync every 60s, plus the hub-mirror snapshot and live feed under self_sync) |
| Outputs | HTTP responses (REST, JSON-RPC, HTML) |
| Storage | A hub-mirror schema it owns (created and written under "self_sync": true); otherwise a read layer over indexed state |
| Communication | Inbound HTTP from clients; outbound SQL to Indexer and Decoder DBs; DDL and row writes to its own hub-mirror DB; outbound JSON-RPC to xchain-hub |
Key technical details:
- 323 REST endpoint patterns across the
/apiand/explorernamespaces, covering tokens, balances, holders, orders, dispensers, transactions, events, market data, contracts, staking, attestations, cross-chain calls, betting feeds and bets, governance polls and ballots, contract emissions, vote delegations, validator capabilities and slashing, chain reorgs, anchor reward attestations, per-block commitments, and more. The breakdown, re-derived fromxchain-explorer/src/XChainExplorer.json 2026-10-19:- 192
/{COIN}/api/...and 112/{COIN}/explorer/...patterns in the dispatch table built bysetupUrls(), matched by the catch-all handler rather than registered with Express individually. - 19 hand-registered
/{COIN}/api/...routes that bypass the dispatch table: raw file download, fee quote (GET and POST), oracle fee quote, preflight (registered twice, GET and POST, because the largest legal action does not fit a query string), the two POST batch reads (balances, COINPay obligations), fee schedule, checkpoint list, checkpoint range, checkpoint verify, hub-mirror status, the five Merkle proof endpoints (balance, locked balance, action, validator set, contract state), and the POST contract-call query endpoint. - Outside those two namespaces the same server also registers 117 HTML page routes plus
/openapi.json,/icon,/relay, and the static asset mounts.
- 192
- JSON-RPC 2.0 interface compatible with Counterparty-style tooling.
- Bootstrap-based web UI with Highcharts for order book and market price visualization.
- Reads configuration from xchain-hub every 60 seconds (fee schedules, supported parameters, fiat pricing).
- Approximately 9,400 lines of SQL query logic. All queries are parameterized; no ORM.
- Supports SSL/TLS termination.
- Runs as a single shared instance across all chains and networks; each request is routed to its coin’s databases by the
/{COIN}/prefix in the URL path.
See ../components/explorer/ for full documentation.
Data Replication
xchain-sync
| Purpose | Replicates indexer databases to validators and consumers for lightweight chain verification |
| Inputs | Indexer MariaDB (SQL polling per chain/network), xchain-hub (JSON-RPC config discovery) |
| Outputs | REST API (snapshots, status, transparency log), WebSocket (real-time block and reorg streaming) |
| Storage | MariaDB (95 replicated indexer tables; one replica DB per chain/network) |
| Communication | Inbound REST + WebSocket from validators/consumers; outbound JSON-RPC to hub; outbound SQL reads from indexer DBs |
Key technical details:
- Runs as a single instance serving all chains/networks on the node, discovers installed indexers by calling the hub’s
getallconfigsmethod. - Operates in two modes: server mode (polls indexer databases and serves data) and client mode (replicates from remote sync servers).
- Polls each indexer database for new blocks every 3 seconds (configurable). Builds a complete block payload from all affected tables and broadcasts to WebSocket subscribers.
- Full snapshots are streamed as gzip-compressed JSON for bootstrapping new validators.
- Incremental snapshots provide deltas since a given block height for catch-up after downtime.
- Indexer block payloads carry the indexer’s three per-block chained SHA256 hashes (ledger, actions, contracts) plus a fourth, replication-only
state_hashcovering the in-place mutations and backdated refund credits those three cannot see; decoder payloads carry a singleblock_hash. - On apply, an indexer replica recomputes
state_hash(VERIFY_STATE_HASH, default on) and the per-block SPV state-commitment roots (balances, block Merkle root) with sync’s SHA-256 Merkle/SMT primitives (VERIFY_STATE_COMMITMENT, default on), and halts durably on a mismatch. Both checks still trust the source for the committed values, so they do not by themselves catch a single dishonest source. - Separately, server mode keeps a transparency log that groups indexer blocks into Merkle epochs (
MERKLE_EPOCH_SIZE) and serves inclusion proofs and the latest root for external auditors. - Clients can sync from 2+ independent sources and cross-verify block hashes to detect tampered data.
- Reorg detection mirrors the indexer’s pattern: detects rollbacks in the source database and broadcasts reorg events. Clients roll back their local replicas using the same table lists as the indexer’s
Rollback.js.
See ../components/sync/ for full documentation.
Transaction Creation
These services support the construction and submission of XChain transactions.
xchain-encoder
| Purpose | Converts an ACTION string + UTXOs + public key into an unsigned PSBT |
| Inputs | JSON-RPC calls from SDK or callers (ACTION string, pubkey, and optionally UTXOs, which are fetched from xchain-utxo-tracker when omitted) |
| Outputs | Unsigned PSBT (one or two transactions depending on format) |
| Storage | None (fully stateless) |
| Communication | Inbound JSON-RPC from SDK/callers; outbound JSON-RPC to the coin node (broadcast_tx, estimatesmartfee-based fee estimation) and to xchain-utxo-tracker (UTXO lookups, sync-lag checks, health probes) |
Key technical details:
- With
encodingomitted, selects betweenOP_RETURN(≤80 bytes/output, 76 bytes user data, 1 tx) andP2SH(476 bytes/chunk, 2 tx) by payload size.MULTISIGN(60 bytes/output, 1 tx),P2WSH(476 bytes/chunk up to the 8,192-byte compiled-payload ceiling, 2 tx) andTAPROOT(the envelope, up to 390,000 bytes in one tapscript witness, 2 tx, segwit chains only) are never reached by that size fallback; they are used only when explicitly requested, or whenencoding: AUTOopts into smallest-footprint selection. - P2SH and P2WSH use a two-transaction pattern: fund tx commits funds to a script; reveal tx spends it, embedding the data in the unlocking script. TAPROOT uses a commit/reveal pair returned together from one call.
- Obfuscates payloads with AES-128-CTR. Key and IV are derived from the first input’s txid, deterministic and reversible by any party with the txid.
- Calls the coin node directly over JSON-RPC (configured by the
NODE_*variables) to broadcast and to estimate fees, and calls xchain-utxo-tracker for UTXO lookups;create_txrefuses tracker data that lags by more thanUTXO_TRACKER_MAX_LAG_BLOCKS.
See ../components/encoder/ for full documentation.
xchain-utxo-tracker
| Purpose | Indexes all UTXOs from a coin node and serves address/balance/UTXO queries |
| Inputs | Coin node JSON-RPC (block polling); JSON-RPC queries from SDK and encoder |
| Outputs | JSON-RPC API (UTXO lookups, address balances) |
| Storage | LevelDB (prefix-keyed; blocks, transactions, inputs, outputs, hints) |
| Communication | Outbound JSON-RPC to coin node; inbound JSON-RPC from SDK/encoder |
Key technical details:
- LevelDB key schema uses single-character prefixes:
B=block,T=transaction,I=spent input,O=unspent output keyed by scriptHash,H=outpoint-to-scriptHash hint,J=input hint, andS/Z/K/M/N/Wfor script tracking and reorg undo (full layouts in the utxo-tracker key schema). - Processes blocks in batches of up to 200 (flush may trigger earlier under heap pressure), writing each batch atomically to LevelDB.
- Maintains a per-chain, per-network undo window (mainnet and regtest: BTC 12 / LTC 120 / DOGE 120 blocks; testnet: BTC 120 / LTC 5000 / DOGE 120 blocks; overridable via XCHAIN_UNDO_BLOCKS_
) to support chain reorganization rollback. - Tracks the mempool for real-time unconfirmed UTXO state.
- Supports bootstrap from tar archives to avoid re-indexing from genesis.
- Outputs are indexed by scriptPubKey hash, enabling efficient address lookups.
- Runs as one instance per chain/network combination.
See ../components/utxo-tracker/ for full documentation.
xchain-sdk
| Purpose | Developer SDK for constructing and submitting XChain actions |
| Inputs | Developer calls (action parameters); JSON-RPC from encoder and explorer |
| Outputs | Signed or unsigned transactions; query responses |
| Storage | None (stateless) |
| Communication | Outbound JSON-RPC to encoder, explorer, hub; optional inbound JSON-RPC (microservice mode) |
Key technical details:
- Exposes 32 action construction methods (one per developer-invocable ACTION type) and 118 explorer query wrappers.
- Batch builder allows multiple actions to be combined into a single
BATCHaction string. - Discovers service endpoints via xchain-hub.
- Implements retry with exponential backoff and connection pooling for all outbound calls.
- Supports request hooks (pre/post processing middleware).
- Three deployment modes: Node.js library, JSON-RPC microservice, browser bundle via webpack.
See ../components/sdk/ for full documentation.
Infrastructure
These services manage deployment, configuration, and testing.
xchain-hub
| Purpose | Decentralized config oracle, price oracle, cross-chain attestation, SWAP coordinator, PBFT consensus, governance |
| Inputs | JSON-RPC calls from all services; external price APIs (CoinGecko, Kraken, Coinbase; CoinMarketCap optional with API key); P2P gossip from other validators |
| Outputs | Config values, service endpoints, oracle prices, fee quotes, cross-chain attestations, governance decisions |
| Storage | MariaDB (configs, validators, consensus, price_snapshots, oracle_prices, oracle_submissions, attestations, swaps, reorgs, governance, validator_rewards, slashing) |
| Communication | Inbound JSON-RPC from all services (incl. PRICE pushes from indexers); outbound HTTP for price fetching; WebSocket P2P gossip between validators; inbound WebSocket /hub-db/subscribe from indexers (HubDbSync clients) for hub DB sync |
Key technical details:
- Operates in two modes: standalone (simple config oracle) and validator mode (full PBFT consensus, P2P gossip, oracle, cross-chain attestation, governance).
- Supports multi-instance deployment, multiple hub instances against shared MariaDB, with consumer fallback via
HUB_VALIDATORS. - Config writes go through PBFT consensus in validator mode (PRE_PREPARE → PREPARE → COMMIT, reaching a federation quorum that is stake-weighted and source-deduped at/above
STAKE_WEIGHTED_QUORUM_ACTIVATIONand the legacymax(2f+1, ceil((N+1)/2))signer count below it). - Decentralized price oracle: validators fetch from CoinGecko, Kraken and Coinbase (CoinMarketCap optional, requires API key), aggregate via trimmed median (discard top/bottom 15%), finalize via PBFT.
- Cross-chain attestation engine with per-chain-pair validator subsets and confirmation thresholds (BTC: 6, LTC: 12, DOGE: 60; env-tunable via
XCHAIN_CONFIRMATIONS_<COIN>). - SWAP lifecycle tracking: initiated → attested → executed → settled.
- Off-chain governance: 7-day voting period, 2/3+ approval, 50% quorum, parameter change bounds enforcement.
- Reward tracking and slash detection for oracle participants.
- Ed25519 validator identity for P2P message signing.
- Explorer and SDK poll the hub every 60 seconds to refresh their config caches.
See ../components/hub/ for full documentation.
xchain-node
| Purpose | CLI tool for installing, configuring, and managing all platform services as Docker containers |
| Inputs | Operator CLI commands |
| Outputs | Running Docker containers; status reports |
| Storage | Local config files |
| Communication | Docker Engine API; downloads service images from registry |
Key technical details:
- Downloads and configures coin nodes (bitcoind, litecoind, dogecoind) alongside all platform services.
- Creates Docker containers with a consistent naming scheme: per-chain services are
xchain-node-{coin}-{network}-{service}(e.g.xchain-node-bitcoin-mainnet-xchain-encoder); shared services (database, hub, explorer, sync) arexchain-node-{service}(e.g.xchain-node-xchain-hub). - Each coin/network combination gets its own Docker bridge network (
xchain-node-{coin}-{network}), giving DNS-based service discovery between that chain’s containers. The database, hub and explorer are also connected to every coin/network network; sync stays on the basexchain-nodenetwork only. Each indexer also joins the networks of the other installed coins on the same network tier, for its cross-chain sibling reads. - Blessed TUI provides a real-time status dashboard in the terminal.
- Supports create, start, stop, update, and monitor operations per container.
- A single xchain-node installation can manage multiple chains and networks simultaneously.
See ../components/node/ for full documentation.
xchain-regtest-miner
| Purpose | Auto-mines mempool transactions for regtest development environments |
| Inputs | Coin node JSON-RPC (mempool polling every 100 ms) |
| Outputs | Mined blocks via generatetoaddress |
| Storage | None |
| Communication | Outbound JSON-RPC to coin node; inbound JSON-RPC control API |
Key technical details:
- On detecting mempool transactions, waits up to 30 seconds (resetting to 5 seconds on each new arrival) before mining.
- Inbound JSON-RPC control API: funding (
send_funds,fill_mempool), on-demand mining (generate_blocks), auto-mine control (pause_mining,continue_mining,set_mining_time), and the rest listed in the regtest-miner API reference. - Only used in regtest; not deployed in testnet or mainnet environments.
See ../components/regtest-miner/ for full documentation.
xchain-e2e-test
| Purpose | End-to-end Mocha test suite that exercises the full platform stack |
| Inputs | Live regtest environment (all services running) |
| Outputs | Pass/fail test results |
| Storage | None |
| Communication | JSON-RPC to encoder, explorer, hub; indirect via SDK |
Key technical details:
- Uses BIP39/BIP32 wallet generation to create deterministic test addresses.
- Tests run in order and share blockchain and indexer state; each test builds on the output of prior tests.
- Discovers service endpoints from xchain-hub.
- Requires xchain-regtest-miner to be running to advance blocks.
See ../components/e2e-test/ for full documentation.
Contract Execution
xchain-vm
| Purpose | Deterministic smart contract execution engine; runs JavaScript contracts in sandboxed V8 isolates |
| Inputs | Called by xchain-indexer at EXECUTE/DEPLOY processing time; receives contract code, method name, params, and an xchain gateway context |
| Outputs | Emitted ACTION queue; contract state mutations; gas consumed; execution log |
| Storage | None (stateless library; state is written by the indexer to the Indexer MariaDB) |
| Communication | In-process library only; no network interface |
Key technical details:
- Ships as a Node.js library (
xchain-vm) embedded inside xchain-indexer; not deployed as a standalone service. - Each EXECUTE call runs the target contract in a fresh
isolated-vmV8 isolate with a separate heap and no access to the host process, filesystem, or network. - Non-deterministic globals (
Date,Math.random,fetch,eval, etc.) are stripped before any contract code runs;Mathis replaced by a frozen deterministic subset. - Gas is metered by AST instrumentation (acorn parse + astring regenerate) rather than wall-clock time, so cost is a deterministic function of code structure.
- A per-block compilation cache (keyed by contract index plus code hash, bounded to 1,000 entries) avoids recompiling the same contract across multiple calls in a block.
- Requires Node.js 22 exactly:
xchain-vmpins the consensus runtime to Node ABI 127, so Node.js 24 failscheckConsensusRuntime()even thoughisolated-vminstalls there from a prebuilt binding.
See ../components/vm/ for full documentation.
Client
xchain-wallet
| Purpose | Self-custodial multi-chain reference wallet; browser SPA, Chrome MV3 extension, Electron desktop app, and Capacitor mobile app (Android shipped, iOS pending App Store release) |
| Inputs | User interaction; xchain-sdk for action construction; xchain-explorer for balance and history queries; xchain-hub for config and fee data |
| Outputs | Signed transactions broadcast to coin nodes via the encoder; read-only views of balances, tokens, actions, and markets |
| Storage | Client-side only; no server-side state. The AES-256-GCM-encrypted vault lives in IndexedDB (web), chrome.storage.local (extension), an encrypted file under Electron userData (desktop), or an app-private file via the native XChainVault plugin under an OS-keystore key (mobile). The vault never sits in localStorage. Browser-based shells do keep small side records there beside UI state, such as the web shell’s KDF parameters and, with biometric unlock on, the authenticator-wrapped copy of the password. See wallet architecture and wallet security |
| Communication | Outbound JSON-RPC and REST to xchain-encoder, xchain-explorer, and xchain-hub; no inbound API |
Key technical details:
- Built on xchain-sdk; all action construction goes through the SDK’s 32 developer-invocable ACTION methods.
- Supports every chain the platform runs on, today Bitcoin, Litecoin, and Dogecoin (mainnet, testnet, regtest), from the same codebase.
- Deployed as a web SPA (served from a static docroot), a Chrome MV3 extension (packaged from the same source), an Electron desktop application, and a Capacitor mobile app wrapping the same web build (Android shipped, iOS pending App Store release).
- Private keys never leave the client; signing happens locally before broadcast.
- Targets non-technical end users; UI language is intentionally plain (e.g., “About” not “Token Spec”).
See ../components/wallet/ for full documentation.
Full Connection Diagram
The xchain-hub config oracle serves four consumers (sdk, explorer, indexer, decoder); the coin node itself is one physical service that every pipeline stage below reaches over JSON-RPC, drawn once here even though it sits at the center of several flows.
flowchart TD
HUB["xchain-hub<br>(MariaDB; config + oracle)"]
SDK["xchain-sdk"]
EXPLORER["xchain-explorer"]
ENCODER["xchain-encoder"]
IDXDB[("Indexer MariaDB<br>XChain_{C}_{N}_Indexer")]
INDEXER["xchain-indexer"]
SIGN["User signs +<br>broadcasts"]
COINNODE["Coin Node<br>(bitcoind etc.)"]
MINER["regtest-miner"]
DECDB[("Decoder MariaDB<br>XChain_{C}_{N}_Decoder")]
DECODER["xchain-decoder"]
UTXO["utxo-tracker<br>(LevelDB)"]
SDK -->|config| HUB
EXPLORER -->|config| HUB
INDEXER -->|config| HUB
DECODER -->|config| HUB
SDK -->|"JSON-RPC"| ENCODER
ENCODER -->|PSBT| SIGN
SIGN --> COINNODE
EXPLORER -->|"SQL reads"| IDXDB
INDEXER -->|"SQL writes"| IDXDB
DECDB -->|"SQL reads"| INDEXER
DECODER -->|"SQL writes"| DECDB
MINER -->|mine| COINNODE
COINNODE -->|"JSON-RPC polling"| MINER
COINNODE -->|"JSON-RPC polling"| DECODER
COINNODE -->|"JSON-RPC queries"| UTXO
Multi-Chain Deployment
Each core pipeline service (decoder, indexer, utxo-tracker, encoder) runs as a separate instance per chain/network combination. xchain-hub and xchain-explorer each run as a single shared instance across all chains.
A full mainnet deployment across all three supported chains requires:
| Service | Instances | Notes |
|---|---|---|
| Coin nodes | 3 | One each for Bitcoin, Litecoin, Dogecoin |
| xchain-decoder | 3 | One per coin |
| xchain-indexer | 3 | One per coin |
| xchain-explorer | 1 | Shared across all chains; routes by the coin prefix in the URL |
| xchain-utxo-tracker | 3 | One per coin |
| xchain-encoder | 3 | One per coin (or shared if stateless routing used) |
| xchain-hub | 1+ | Shared across all chains; supports multi-instance for HA |
| xchain-node | 1 | Manages all containers |
Adding a new chain means adding one more set of pipeline instances (coin node + decoder + indexer + utxo-tracker + encoder) and registering them with the hub. The shared explorer serves the new coin without an extra instance.
Deployment Configurations
Minimal (regtest development):
- 1 coin node (regtest)
- decoder + indexer + explorer + encoder + utxo-tracker (all pointing to regtest)
- xchain-hub
- xchain-regtest-miner
- xchain-e2e-test (run on demand)
Full mainnet:
- 3 coin nodes + decoder, indexer, utxo-tracker and encoder per coin + one shared xchain-explorer + xchain-hub + xchain-node
- No regtest-miner or e2e-test in production
Copyright © 2025–2026 Dankest, LLC
Based on XChain Platform by Dankest, LLC – https://dankest.llc
Licensed under the GNU Affero General Public License v3.0 (AGPL-3.0-or-later) with a commercial license available for proprietary use.
You may use, modify, and distribute this material under the terms of the License. See LICENSE and NOTICE for full terms. See the licensing overview.