fix: close the defects an adversarial audit found
An outside integrator and a code audit both concluded the merchant half was a demo wearing a product's clothes. What they proved, and what changed: - The watcher confirmed on ABSOLUTE balance, so an address that already held funds marked an invoice paid the moment it was created and the merchant shipped goods nobody paid for. Payment is now a delta from a baseline read at registration. - A payment that landed before the deadline lost to an expiry evaluated after it, stranding the payer's funds. Payment now wins. - The API had no auth and wildcard CORS, so any page the merchant visited could read the whole invoice ledger, inject invoices, and, via a caller-supplied webhook URL, make the watcher sign arbitrary bodies with the merchant's secret. Bearer token required, exact-origin CORS, and the webhook URL is server configuration only. - Signatures covered the body alone and replayed forever. They now cover timestamp.body, expire in five minutes, and carry a deliveryId to dedupe on. An unset secret refuses to send rather than sending unsigned. - Retry after a failed confirmation re-broadcast the payment. The sent hash is remembered, so a retry only waits. - The hosted page interpolated URL params into innerHTML: any link could run script on the payment origin and rewrite the address being paid. Built from DOM nodes now, with the address and amount validated first. - resolveToken assumed 18 decimals for unknown addresses, a 10^12 error on a 6-decimal token. It refuses instead. Empty and multi-dot amounts parsed as 0 and as truncated values; both throw. - The receipt copied the invoice's network claim; it now reports the wallet's, and a network mismatch is refused before any prompt. - e2e-live.mjs proved confirmation by watching a funded address and reporting paid. That was a false positive presented as evidence. It now asserts the opposite, plus signature replay rejection. 51 tests, up from 31: the HTTP surface had none at all. Docs corrected too, including a Tier 1 install that never worked and privacy claims the code did not support. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
B
bongbongcrypto committed
4cd57af39508db8b4511b1dfefbedefc1ed8ea4a
Parent: 8fb2658