No spend keys on the box.
Root cannot move settled funds.
Each merchant gets a dedicated VPS. The gateway knows public data only: a receiving address per stablecoin network, a BTC xpub/zpub, an XMR address and private view key. Nothing on the server can sign a transaction, so a full compromise cannot drain what has already been paid.
Stablecoin payments land directly in the merchant's own address — no deposit address per invoice, no sweeping, no intermediate balance. The buyer pays the network fee; the merchant pays nothing to receive.
A key-material tripwire refuses to boot if anything that looks like a private key, seed, mnemonic or xprv appears in the settings.
| Network | Credited at | Identity check |
|---|---|---|
| TRON (TRC-20) | Solidified block (/walletsolidity) | Genesis block |
| Ethereum (ERC-20) | finalized (opt-in fast credit at safe under a cap) | eth_chainId |
| BNB Smart Chain | finalized | eth_chainId |
| Solana (SPL) | finalized commitment | getGenesisHash |
| Bitcoin | Configurable confirmations (default 1) | Watch-only wallet |
| Monero | Configurable confirmations (default 1) | View-only wallet |
One address, many invoices.
Attributed by exact amount.
Without per-invoice addresses, attribution needs another discriminator. Every open invoice is assigned a unique amount slot on top of the price: $25.00 becomes 25.0042 USDT. Slots are only ever added — the merchant always receives at least the full price.
- 4 decimals by default: 99 concurrent invoices per exact price, typeable on every exchange withdrawal form we could verify. Overflow to 6 decimals: 9,999 per price.
- Solana: Solana Pay URI with a per-invoice
referencekey, with the amount slot as fallback for wallets that drop it. - Slots are held for the 7-day late-payment window, so a late transfer can never be matched to a newer invoice.
- Anything that does not match exactly (typically an exchange deducting its withdrawal fee) is recorded and queued with ranked candidate invoices — never dropped, never guessed. An optional underpayment tolerance auto-accepts only when exactly one invoice can be meant.
UNIQUE index, inside BEGIN IMMEDIATE.One provider detects.
Another must prove it.
// Runs on the VERIFIER, never the detecting provider. if (($err = $this->chainIdError($ep)) !== null) { return VerifyOutcome::pending($err); // wrong network } $r = rpc_call($ep, 'eth_getTransactionReceipt', [$t->txid]); $fin = $this->header($ep, 'finalized')['number']; if ($status !== '0x1') { return VerifyOutcome::rejected('not a successful transfer'); } if ($claimedHash !== $bh) { // reorg or disagreement return $final ? VerifyOutcome::pending('disagreement') : VerifyOutcome::rejected('reorg'); } // Canonical block at that height must be the receipt's block if ($this->header($ep, $bn)['hash'] !== $bh) { /* … */ } // Pinned token contract, recipient by raw bytes, exact value $found = EvmCodec::transfersInLogs($logs, $n['token'], [$t->toAddress]);
Public RPC providers are the softest part of any non-custodial gateway: a lying or compromised endpoint can invent a transfer. Detection and verification are therefore split across two operators, enforced at boot by registrable domain (Public Suffix List) plus declared operator labels.
A transfer is credited only when the verifier independently confirms:
- the network identity (chain id / genesis hash);
- the pinned token contract or mint — not a look-alike token;
- execution succeeded and the recipient matches by raw bytes;
- the block is final and canonical at its height;
- it agrees with the detection on block, log index and amount.
Disagreements are logged as SECURITY events and never credited. Provider timestamps in the future are refused. Every outbound call goes through one hardened client: https only, verified TLS, no redirects, size and time caps after decompression, per-host backoff on 429.
Exactly once.
In integers, end to end.
There is one path to "paid". The watcher, a buyer-submitted txid, a dashboard lookup and a manual assignment all converge on it, and none of them can create a payment row without a verified transfer.
- Idempotent ingest:
INSERT OR IGNOREkeyed on(chain, txid, log_index)— a transfer seen twice is recorded once. - Optimistic transition: the invoice update is conditional on its previous
statusandpaid_atomic; a lost race changes nothing and emits nothing. - Transactional outbox: payment row, invoice transition and webhook event commit in one
BEGIN IMMEDIATEtransaction. Delivery happens afterwards, at-least-once, withevent_idand a per-invoicesequencefor consumer-side dedupe and ordering. - Crash consistency: fault injection at 11 kill points between insert, attribution, transition and delivery; invariants re-checked after each.
(float) cast or round() in pricing, matching and receipt code.function engine_record_transfer(PDO $db, VerifiedTransfer $t): string { return db_transaction($db, function () use ($db, $t) { $ins = $db->prepare('INSERT OR IGNORE INTO payments …'); $ins->execute([…]); if ($ins->rowCount() !== 1) { return 'duplicate'; // recorded by someone else } $match = engine_match_transfer($db, $t); if ($match === null) { unmatched_enqueue($db, …); // review queue, never dropped return 'unmatched'; } engine_attach_payment($db, …); return 'matched'; }); } // inside engine_attach_payment(): $upd = $db->prepare('UPDATE invoices SET status = ?, paid_atomic = ?, … WHERE id = ? AND status = ? AND paid_atomic = ?'); if ($upd->rowCount() !== 1) { return []; // lost a race: the winner emitted the events }
A fresh address per invoice.
Derived from public keys only.
// argv array: proc_open() executes the binary directly. // No shell is ever spawned, so nothing can be parsed as one. $argv = [BTC_ELECTRUM_CMD, '--dir', BTC_WALLET_DIR, '-w', BTC_WALLET_FILE, $sub]; foreach ($args as $a) { $argv[] = (string)$a; } $proc = proc_open($argv, $desc, $pipes); // non-blocking pipes + hard deadline (BTC_ELECTRUM_TIMEOUT) // watcher.php — first writer wins, webhook fires once $upd = $db->prepare('UPDATE invoices SET status = "paid", … WHERE id = ? AND status != "paid"'); $wasFirst = ($upd->rowCount() === 1); if ($wasFirst) { trigger_noctyra_webhook(…); }
Bitcoin: a watch-only Electrum wallet restored from the merchant's xpub/zpub derives a new BIP32 address per invoice. Payment is matched per UTXO with its confirmation depth (btc_match_utxos), not an address balance, so unconfirmed value can never satisfy the threshold.
Monero: monero-wallet-rpc listens on loopback only and is provisioned by the deploy script from the address and private view key — a view-only wallet. Each invoice gets a new subaddress from create_address; payments are matched from get_transfers against the stored invoice address. Subaddresses are unlinkable on-chain.
Amounts are priced once from the market rate, then compared as atomic integers — satoshis (10⁸) and piconeros (10¹²) — with a strict >=. Views, polls and creation are HMAC-gated and rate-limited per IP, as in section 06.
Trust the signature.
Then verify the destination.
Checkout links (v2) are HMAC-SHA256 under an HKDF-derived subkey over key id, issue time, expiry, cents, order id, asset, offered chains and per-chain address fingerprints. If the gateway's configured address differs from the merchant's own record, checkout is refused before a buyer sees it. A newer link can replace an unpaid invoice; an older one never can.
Invoice views require a per-invoice HMAC view token; a wrong token is a plain 404, compared with hash_equals(). Stablecoin invoice ids are random 96-bit values; on BTC/XMR the token alone gates each sequential id, so there is nothing to enumerate.
Webhooks carry X-Noctyra-Signature: sha256=… over timestamp.body with a separate WEBHOOK_SECRET; two signatures during rotation; max-age checking against replay.
assertPaidToMerchant() checks every webhook against the merchant's own stored addresses (deriving the Solana token account itself), and an off-box canary compares the addresses the gateway serves with the merchant's records.$kid = substr(hash_hmac('sha256', 'noctyra/key-id/v1', $secret), 0, 8); $key = hash_hkdf('sha256', $secret, 32, 'noctyra/checkout-link/v2'); // v2|kid|iat|exp|cents|order|asset|chains|fingerprints $canonical = 'v2|' . $kid . '|' . $iat . '|' . $exp . '|' . $usdCents . '|' . $orderId . '|' . $asset . '|' . implode(',', $chains) . '|' . $fpList; $sig = hash_hmac('sha256', $canonical, $key); // fingerprint = the merchant's own idea of each address substr(hash('sha256', 'noctyra-addr-fp|v1|' . $chain . '|' . normalizeAddress($chain, $address)), 0, 16); // merchant side, before releasing goods: if (!$client->verifyWebhook($body, $sig, $ts)) { http_response_code(401); exit; } $client->assertPaidToMerchant($event, MY_ADDRESSES);
Defence in depth.
Measured, not asserted.
| Layer | Control |
|---|---|
| Browser | Nonce-only CSP (no unsafe-inline), SRI on every script and stylesheet, self-hosted fonts and QR library — no third-party origin on any page that displays an address. no-store, noindex, COOP/CORP, HSTS. |
| Edge | nginx serves an allowlist of entry points; everything else is a bare 404. limit_req per endpoint before PHP is reached; per-IP (IPv6 /64) application rate limits behind trusted-proxy CIDRs only. |
| Runtime | Hardened PHP-FPM pool (open_basedir, disabled exec functions, no uploads); systemd units with sandboxing (exposure score ≤ 2.0); root-owned releases the service user cannot modify. |
| Dashboard | Argon2id, mandatory TOTP with one-time recovery codes, __Host- session cookie rotated after 2FA, CSRF + Sec-Fetch-Site, IP allowlist, lockout without account enumeration, full audit log. Signed, replay-proof pull API. |
| Operations | Monitor with Telegram/email alerts, external address canary, encrypted backups to an off-box key (libsodium), restore drill, settings validated before a release is switched in. |
level max, strict
HTML, SQL, shell, header sinks
Infection, covered code
in the security sweep
Plus an adversarial provider matrix on all four networks, crash consistency at 11 kill points, 60,000 seeded parser mutations per target, load and concurrency tests, and a real root deploy (nginx, PHP-FPM, systemd) in CI. The internal review is OWASP ASVS 4.0.3 Level 2; an independent audit is recommended before significant volume.
Your keys. Your server.
Your settlement.
One VPS per merchant, deployed and hardened in a single command. Try a real payment first, or talk to us about your stack.