Pular para o conteúdo

Direct Settlement Architecture: How HD Wallets and xPub Derivation Work

Payora10 min readEN · RU · UK · ES · DE

The single biggest security risk in any cryptocurrency payment system is private key exposure. If the server that monitors incoming payments can also spend those funds, a single breach means total loss. Direct-settlement architecture can reduce this risk — and the mechanism behind it, HD wallet key derivation, is elegant enough to be worth understanding.

The Problem With Hot Wallets on Servers

A "hot wallet" is a wallet whose private key lives on an internet-connected machine. Most naive crypto payment implementations work like this: generate a wallet, put the private key in a config file or database, and use it to create deposit addresses and sign payout transactions.

The problem is obvious in retrospect: any attacker who compromises the server — through an unpatched vulnerability, a supply chain attack, a leaked credential, or a misconfigured firewall — gets the private key and can drain every wallet linked to it. The history of crypto exchange hacks is largely a history of hot wallet compromises.

The solution is to separate the ability to watch payments from the ability to spend funds.

HD Wallets and the Extended Public Key

BIP-32 (Hierarchical Deterministic wallets) defines a way to derive an infinite tree of key pairs from a single master seed. The crucial property is public key derivation: given the extended public key (xPub) of a parent node, you can derive all child public keys — and therefore all child Bitcoin addresses — without ever seeing the private key.

This is mathematically possible because of elliptic curve arithmetic: public keys are points on a curve, and you can add a deterministic tweak to derive child public keys from a parent public key alone.

In practice, it means:

  1. You generate a master seed offline — on an air-gapped computer, a hardware wallet, or a signing device.
  2. You export the xPub (just the public key, no private material) and give it to your payment server.
  3. The server derives address #1 for invoice #1, address #2 for invoice #2, and so on — all unique, all yours — without ever knowing the private key.

How Address Derivation Works in Practice

For a BIP-32 xPub at derivation path m/44'/0'/0' (standard Bitcoin BIP-44), the server derives addresses at m/44'/0'/0'/0/N where N is the invoice index. Each N produces a unique address. The addresses are deterministic — the same xPub + same N always produces the same address — so you can re-derive any address for verification.

For UTXO chains (Bitcoin, Litecoin, Dogecoin, Bitcoin Cash), this is the standard approach. Other chains use different but equivalent mechanisms:

  • TON and Tron: each invoice gets a freshly generated keypair; only the public key (and thus the address) is stored on the server. The private key is either discarded (for watch-only use) or held in an offline pool.
  • Solana: an offline pool of pre-generated public keys (derived from an offline seed) is consumed one-per-invoice.
  • EVM chains (ETH, BSC, Polygon, etc.): xPub derivation via BIP-44, same as Bitcoin.
  • XRP and XLM: shared-address model with unique destination tags or memos per invoice.

The Complete Direct-Settlement Payment Flow

  1. Invoice created: your site calls the gateway API. The gateway derives a fresh deposit address (or assigns a unique tag) using only public material.
  2. Customer pays: funds are sent to that address. The gateway detects the transaction via a blockchain explorer API.
  3. Confirmation: after the required number of confirmations, the gateway updates the invoice status and fires a signed webhook to your server.
  4. Funds arrive: in your own wallets. The gateway never held them, cannot move them, and has no private key to do so.
  5. Withdrawal: when you want to sweep funds or process a payout, you sign the transaction offline — on an air-gapped machine, a hardware wallet, or any signing device — and broadcast the signed transaction. The server records the tx hash but cannot initiate the spend.

What This Means for Security

A complete compromise of the payment server in this model is, at worst, a data breach — an attacker can see order history and in-progress invoices, but cannot move a single satoshi. The funds are in wallets controlled by keys that never touched the server.

This is why non-custodial gateways require you to export an xPub (or use a key-generation tool offline) before processing payments. The slightly higher setup cost buys you a fundamentally different risk profile: server compromise ≠ loss of funds.

For any operator handling meaningful volume, this architecture is a useful model to understand. Payora uses a balance-first model by default; vetted merchants can request direct settlement using merchant public-key material where supported. Learn how Payora settlement modes work.

Comments

Ready to get started?

Create an account and have your first invoice running in under an hour.

O que esta página responde