fix x402: Lightning millisat amounts, drop unserviced BCH rail, correct fee docs - #384
Merged
ralyodio merged 1 commit intoOct 1, 2026
Conversation
- Lightning quotes in millisats (decimals 11), matching the verifier's expected.amount unit; sub-sat USD values no longer round to 0. - Remove BCH from x402 accepts: the settle route refuses bitcoin-cash (no verified lookup), so it must not be advertised. Re-add with a tested verify path. - Fee docs: the 1.0%/0.5% commission is collected on custodial rails, not on x402 where the buyer pays the merchant wallet directly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Courtesy fixes for three x402 issues I found while studying the multi-rail flow. Minimal, no behavior changes beyond what each fix needs.
1. Lightning quoted in millisats, not sats
PAYMENT_METHODS.lightninguseddecimals: 0, soconvertUsdToAssetAmountrounded sub-sat USD values to"0"— a $5 offer emitted"maxAmountRequired": "0"while/api/x402/verifychecksexpected.amountin millisats (ln_payments.amount_msat). The amount check was vacuous. Nowdecimals: 11(10^11 millisats per BTC), matching the verifier's unit: $5 →"5000000", $1 →"1000000"(at BTC=$100k). Added a regression test asserting nonzero for a $1 offer, in the rail's native smallest unit.2. BCH removed from x402
acceptsThe SDK advertised
bitcoin-cashinaccepts, but/api/x402/settlerefuses it ("no verified lookup wired up") — an offered rail no payment could complete on. RemovedbchfromPAYMENT_METHODS, the legacy network map, the docs table/examples, and the x402 marketing page, each with a note to re-add it once a verified lookup exists and is tested. Nothing else in the platform's (working) BCH support was touched.3. Fee docs now match the code
The docs and pricing page said a 1.0%/0.5% commission is "deducted before forwarding to the merchant" on x402. The settle route's own header documents the reality: on x402 the buyer pays the merchant wallet directly, no platform wallet is in the path, and the fee is not collected (the computed
splitTieredPaymentvalues are record-keeping only). Reworded both fee sections to say the 1.0%/0.5% is the standard rate collected on custodial rails, and 0% on x402. No fee-collection code was added — out of scope.Test evidence (all against this branch):
packages/sdk/test/x402.test.js: 49/49 pass (incl. new millisats regression test)packages/sdk/test/x402-v2.test.js+x402-v2-offer.test.js: 49/49 passpackages/extension/src/core/__tests__/x402.test.ts: 27/27 passsrc/app/api/x402/verify/route.test.ts,settle/route.test.ts,settle/route-v2.test.ts: 68/68 passtsc --noEmiton the editedsrc/app/x402/page.tsx: cleanSlid Phi Labs accepts donations to keep the lab independent: https://www.patreon.com/SlidPhiLabs