feat: BSV mechanism for the x402 exact scheme (BRC-121/BRC-29) - #1
feat: BSV mechanism for the x402 exact scheme (BRC-121/BRC-29)#1sirdeggen wants to merge 1 commit into
Conversation
8e7e107 to
02af619
Compare
|
Thanks for your contribution @sirdeggen! See here for instructions: https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification The team will not review this PR before ALL commits have been verified and it will be closed after 1 week of inactivity. Unverified commits:
|
|
Filed the CAIP-2 namespace registration upstream: ChainAgnostic/namespaces#190 (ChainAgnostic/namespaces#190). It proposes |
Add new @x402/bsv mechanism package implementing the exact payment scheme for the BSV blockchain, including client, server, and facilitator scheme implementations with unit and integration tests. - Add scheme_exact_bsv.md spec and reference it from scheme_exact.md - Wire BSV into advanced client, server, and facilitator all_networks examples - Add scoped npm publish workflow and changeset for the new package Signed-off-by: Deggen <d.kellenschwiler@bsvassociation.org>
424461d to
b7f97f4
Compare
What
Adds BSV as an x402 payment mechanism for the
exactscheme, for internal discussion before anything goes to the x402 Foundation. New package@x402/bsv, a protocol spec, example wiring, and a WhatsOnChain USD price feed — built on the BRC-121 / BRC-29 flow already shipped in@bsv/402-pay.How it maps BRC-121 onto x402
payTo= the recipient wallet's BRC-100 identity public key (never appears on chain — every payment pays a fresh BRC-42-derived key){ transaction (base64 BEEF), derivationPrefix, derivationSuffix, senderIdentityKey, outputIndex }; the suffix decodes to a Unix-ms timestamp (BRC-121 freshness)createAction— no gas sponsorshipverifychecks structure, wallet-chain agreement, freshness, exact amount, and the derived destination;settle=internalizeAction, with a txid dedup cache +isMergefor replay defensebsv:mainnet/bsv:testnet— absvCAIP-2 namespace now proposed at ChainAgnostic/namespaces#190 (human-readable network names,casperprecedent; notebip122can also represent BSV via its fork-block hash, as it does for Bitcoin Cash)What's in the PR
@x402/bsvpackage (typescript/packages/mechanisms/bsv), modeled on the Concordium mechanism:exact/client— derives the per-payment key and builds the funded BEEF paymentexact/facilitator— verifies and settles into the recipient walletexact/server— buildsPaymentRequirements, satoshi price parsing (8 decimals)createWhatsOnChainMoneyParser— converts USD route prices ("$0.001") to satoshis via the WhatsOnChain exchange-rate API (60 s cache, single-flight refresh, bounded stale fallback)constants/types, README, package/tsup/tsconfig/vitest config, changeset, and an npm publish workflowSpec:
specs/schemes/exact/scheme_exact_bsv.md(fullexact-on-BSV spec incl. a Key Linkage Revelation & Auditability appendix) + BSV safety invariants in the sharedscheme_exact.mdappendix.Examples: all three
all_networksexamples wired —BSV_WALLET=true+ a running BRC-100 wallet (e.g. BSV Desktop)BSV_SERVER_PRIVATE_KEY+BSV_WALLET_STORAGE_URLvia@bsv/simpleServerWalletBSV_IDENTITY_KEY, priced in USD through the money parserHardening (adversarial review)
A multi-lens review (interface correctness, security,
@bsv/sdkfidelity, spec consistency, conventions) surfaced 24 confirmed findings, all fixed on this branch:verifynow derives the BRC-42 destination (getPublicKeyforSelf) and matches it against the P2PKH script, so unfundable/mispaid BEEFs fail before any resource workatomicTxid, matching what the wallet internalizesmaxTimeoutSeconds, so slow handlers don't void valid paymentsisMergeis a wallet-toolbox extension (not core BRC-100), so a facilitator-side txid dedup cache backs it upgetNetwork()against the requested networktransaction: ""on all failures per core v2, non-BSV assets rejected at config time, case-insensitive payee comparisonTesting
pnpm testin the package) — payload construction, verify/settle rules, Atomic BEEF subject resolution, replay paths, timestamp windows, and the rate-feed parser (cache / stale / error paths)BSV_INTEGRATION=true pnpm test:integrationwith BSV Desktop running (create → verify → settle → replay-reject) — not yet run, needs a funded walletPoints to discuss before a Foundation PR
bsvnamespace is now up for review at ChainAgnostic/namespaces#190 — please review/comment there. Open question: keep the name-basedbsv:mainnet/bsv:testnetscheme, or fall back tobip122:<fork-block-hash>if the editors prefer it (would mean reworking the network IDs here).revealSpecificKeyLinkage, BRC-69/BRC-94) enabling destination verification without custody — also the auditability path for regulated assets like BSV stablecoins.exact) vs BRC-121's overpay-tolerant check — the spec documents the divergence.🤖 Generated with Claude Code
https://claude.ai/code/session_01U8iaxitVKXh9EZR5HzAYfg