Sovereign Clinical — Payment & Integrity Rails

Generalization case: the consent and attestation primitives behind FSL’s behavioral-health platforms — EIP-191 wallet signatures and MerkleAnchor — applied to a clinical practice platform built for a second domain and a second jurisdiction.

Self-hosted Bitcoin settlement and on-chain record integrity for a clinical practice platform

Designed and built end to end by Margarita Montañez Davenport — product, UX/UI, the practice website, the clinical application, and the payment and integrity rails. Live at clinical.futuresystemslab.io.

Working prototype of an owner-controlled clinical record — access granted and revoked by the participant; encryption keys held by the practice in the current build, owner-held keys specified as the end state — built for a jurisdiction where it can be operated.

Payment rail architecture: invoice to ledger through a self-hosted node, BTCPay Server, and a signature-verified webhook

Self-Hosted Bitcoin Payments

The platform accepts Bitcoin through a self-hosted, fully validating Bitcoin node and BTCPay Server. The wallet is non-custodial and watch-only: the server holds only what it needs to generate addresses and watch for payments. Each Bitcoin invoice is created from the platform’s own billing records, so every checkout corresponds to an issued invoice in the practice ledger.

  • Self-hosted, fully validating Bitcoin node
  • BTCPay Server on self-hosted infrastructure
  • Non-custodial, watch-only wallet
  • Invoices created from the platform’s billing records

Settlement Integrity

Settlement arrives as a signed webhook. The platform verifies each one with HMAC-SHA256 using a constant-time comparison, and automated tests confirm that forged, missing and wrong-length signatures are rejected. A verified settlement is recorded exactly once, keyed on the BTCPay invoice ID, at the amount actually received; an underpayment leaves the invoice partial. A reconciliation sweep runs every 15 minutes and records any settled invoice whose webhook was missed.

  • HMAC-SHA256 webhook signatures, constant-time comparison
  • Forged, missing and wrong-length signatures rejected in automated tests
  • Exactly-once recording, idempotent on the BTCPay invoice ID
  • Amount received is recorded; underpayment leaves the invoice partial
  • Reconciliation sweep every 15 minutes

On-Chain Record Integrity

Every day, the platform hashes its new records, builds a Merkle tree, and anchors the root to the MerkleAnchor contract on the Ethereum Sepolia testnet. Each record stores its own Merkle proof. The verify page recomputes the root from a record’s leaf and proof, then checks it against the RootAnchored event in the anchoring transaction on chain. Only hashes go on chain: no clinical content and no identifiers.

  • Daily Merkle-root anchoring on the Ethereum Sepolia testnet
  • MerkleAnchor contract 0x09f318717B44a22919Bd0B0EA445A41Ad889168c
  • Per-record Merkle proof stored with each batch
  • Verification recomputes the root and checks the RootAnchored event
  • Hashes only on chain — no clinical content, no identifiers
Verify a record →
$1.00
Production Test Payment Settled (On-Chain)
86
Records in First Anchored Batch
15 min
Reconciliation Sweep
1,650
Unit Test Assertions Passing
46
Billing Checks Passing
129
End-to-End Browser Checks Passing

Proven in Production

A $1.00 test invoice, paid on-chain in production, ran end to end: the payment was received and confirmed, the settlement webhook was delivered and accepted with HTTP 200, and exactly one ledger row was written. The first integrity batch anchored 86 records on the Ethereum Sepolia testnet in a single transaction, and records from that batch verify against the on-chain root.

  • $1.00 on-chain test payment in production: received, confirmed, webhook delivered (HTTP 200), one ledger row
  • First anchored batch: 86 records — view transaction on Blockscout (Ethereum Sepolia testnet)
  • Test suites passing: 1,650 unit assertions, 46 billing checks, 129 end-to-end browser checks
BTCPay checkout showing the $1.00 production test payment received
Production test payment at the received stage; BTCPay then confirmed it at one block and settled it, and the ledger recorded it once.