Repository navigation
fix(send): compare LNURL bounds in the wallet's own units, and name them - #706
Merged
Merged
Conversation
Reported in production on v0.6.6: sending to [email protected] from a USD wallet, nothing under $1.00 could be sent, and the error read "The amount on the invoice is less than minimum amount NaN". Two defects in the same branch, both since #689. LUD-06 bounds arrive in SATS; a cash wallet's settlementAmount is in CENTS. The check compared them directly, so Strike's minSendable of 100_000 msat — 100 sats, worth single-digit cents — was read as 100 cents and the app demanded a dollar. That is over 10x the receiver's real floor, and the threshold drifts with the BTC price. The maximum had the same fault in the opposite direction: against a 16M-sat ceiling it could only fire above $160,000, so it never protected anyone. Both bounds are now converted into the sending wallet's units first. The "NaN" came from the i18n placeholder being typed {amount: number}. formatDisplayAndWalletAmount returns a formatted string, so the call site satisfied the type with Number("$0.07 (100 sats)"). The placeholder is now {amount: string} and the formatted value passes through intact — which also makes the mistake uncompilable rather than merely fixed. That retyping surfaced a second call site in redeem-flow, which was passing a bare 1 for "one cent"; it now formats the amount so the message names a unit. Also seeds TopupDetails.allowanceExhausted into the 23 locale files. #700 added it to en/index.ts without regenerating the raw source, so running update-translations here surfaced the gap and check-translation- drift would otherwise fail on this branch. Tests reproduce the production case: 50c to a 100-sat floor is allowed, 5c is still refused, the message names "100 sats" rather than NaN, and the ceiling fires. Verified they fail against the old comparison. 699 tests pass. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_016MsAGwtS4sNodzWu2VMTKR
…rule Review fixes for #706. - The bounds were converted but left fractional, while the number pad only accepts whole minor units, and the message rendered a *rounded* version of that fractional bound — so the app could name a minimum it then refused. Strike's 100-sat floor at $64,000/BTC is 6.4c: the validator rejected 6c, the message read "minimum amount $0.06", the user typed 6c, refused again. Quantize outward (ceil the minimum, floor the maximum) and name the quantized value, so the amount in the message is exactly the smallest (largest) entry that is accepted. Float noise is stripped before quantizing: 100 sats at $70,000/BTC computes to 7.000000000000001c, and a naive ceil would name 8c as the floor of a bound that is really 7c. - Lift lnurlBoundInWalletUnits next to resolveRecipientCap in max-send-amount.ts and call it from both the MAX chip and this check, replacing a local satBound/inWalletUnits pair that re-implemented toBtcMoneyAmount with a divergent currencyCode ("SAT" vs "BTC"). - Convert through paymentDetail.convertMoneyAmount — the same function settlementAmount was derived from, matching the sibling call in send-bitcoin-details-screen.tsx — so both sides of the comparison come from one source. - Tests now probe the bounds themselves (ceil-1 / ceil / floor / floor+1), add non-integral and float-noise rate cases asserting the amount named in the error is itself accepted when re-entered, run every case for USDT as well as USD, and assert on the formatter's arguments instead of a string the mock fabricates — production renders a BTC wallet amount as "₿100", never "100 sats". - Add __tests__/components/redeem-flow-infor-error.spec.tsx: the redeem flow's one-cent threshold message had no coverage anywhere. - Retype minAmountInvoiceError/maxAmountInvoiceError to {amount: string} in the 23 translated locale files, so the corpus matches en.json. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_016MsAGwtS4sNodzWu2VMTKR
Review fixes for the LNURL bounds check.
Enforce on the sat axis. The receiver enforces sats and the request is
built in sats (send-bitcoin-details-screen converts unitOfAccountAmount
to BTC and asks for exactly that many), but the check converted the sat
bound into whole wallet cents and compared it against settlementAmount.
That amount is FRACTIONAL whenever the number pad is denominated in
display currency -- the default, since the pad is seeded with
zeroDisplayAmount and use-price-conversion only rounds when the target
is BTC. JMD display, BTC $65,000, J$158.5/USD, 100-sat floor: J$11.00 is
107 sats, comfortably over the floor, yet 6.94c < 7c refused it. Same
dead end as before, one dimension out. Comparing sats also removes the
crossed-bound case where a band narrower than one cent made 6c "below
the minimum" and 7c "above the maximum".
Quote in the pad's units. lnurlBoundInWalletUnits now backs the MESSAGE
only, pointed at unitOfAccountAmount.currency, so the amount named is
the smallest (largest) entry the pad can actually produce that the
receiver accepts.
Name a cash bound once. A USDT wallet amount renders as USD, but
getSecondaryAmountIfCurrencyIsDifferent compares walletAmount.currency
("USDT") with displayAmount.currencyCode ("USD"), so under a USD display
currency the message printed the same figure twice: "minimum amount
$0.07 ($0.07 USD)". Skip the secondary when both sides render as one
currency.
Tests:
- Display-currency pad cases with a real cross rate (JMD, 158.5 minor
per cent) for both cash wallets: J$11.00 is allowed, the floor and
ceiling the message names are accepted when re-entered, and the
settlement amount is asserted fractional so the case cannot silently
drift back onto the whole-cent axis.
- makeConvert is now a true three-way converter that rounds only BTC
targets, mirroring use-price-conversion; settlementAmount is derived
through it rather than hand-written.
- The format mocks reimplement use-display-currency's rules (USD suffix
on USDT, secondary-amount selection) instead of reading displayAmount
alone, so the duplication is observable; a test asserts the bound is
named exactly once.
- resolveRecipientCap gains a fractional-rate case (100 sats at 0.065
cents/sat -> 6), which fails without the floor wiring.
Verified each fix by reverting it and watching the new tests fail.
The amount toggle flips the pad into the wallet's own minor units while the display currency stays JMD. That is the one reachable combination where describeBound hands formatDisplayAndWalletAmount a wallet-currency primaryAmount and takes the other formatting branch — untested until now, and routine for a JMD-display user. Covers both halves: the refusal names a bound with no NaN or undefined in it, and the amount it names is itself accepted when re-entered. The round-trip is the part that matters — a message quoting a figure the validator then rejects is the dead end this PR already fixed once. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_016MsAGwtS4sNodzWu2VMTKR
The spell check flags the FILENAME. typos.toml already allowlists the identifier InforError, with a comment saying the component rename is a deferred cross-file refactor — but a kebab-case filename splits it into the bare word 'infor', which that entry does not cover. Naming the file after what it asserts avoids propagating the misspelling into a second place while the component keeps its name. The import inside the file still refers to the real identifier, which the allowlist covers. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01NEoz7nBtdtsHyuYG5wNPQV
islandbitcoin
added a commit
that referenced
this pull request
Aug 24, 2026
…708) * fix(send): disclose when the network fee is deducted from the amount Fixes the actionable half of #694. On external sends from cash wallets, IBEX's pre-send estimate for some routes is 0 while settlement deducts the real routing fee FROM THE AMOUNT: the repro was a $1.10 send that displayed "$0.00" fee, debited $1.10, and delivered $1.07. The app cannot conjure the true fee pre-send — IBEX does not provide it on those routes — so an unqualified $0.00 is a claim the settlement then breaks, and the customer discovers the fee on the recipient's side. The confirmation screen now renders, under exactly that case, the note: "The network fee is deducted from the amount — the recipient may receive slightly less." The predicate (fee-from-amount.logic.ts) discloses only on a PROBED zero from a cash wallet on an external send, and each exclusion is a decision: - intraledger stays silent because free is TRUE there, and crying wolf teaches users to ignore the caveat exactly where it matters - BTC-wallet sends stay silent because their probes price the actual route — a zero there is a genuinely free path - loading/error/unset stay silent because those states already carry their own caveats A rare genuinely-free external route reads the soft copy — a mild false positive, priced against the current false NEGATIVE. i18n: key added at the source (app/i18n/en/index.ts), types and raw exports regenerated via yarn update-translations, all 23 locales filled (Spanish translated, others English fallback, matching #706's convention). Drift check green. Deliberately NOT in this PR: making the probe honest server-side (IBEX does not expose the fee on these routes) and showing the actual settled fee in the transaction detail — tracked in the issue as follow-ups. 88 suites / 867 tests green; tsc and eslint clean. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NEoz7nBtdtsHyuYG5wNPQV * fix(send): review fixes — verify Flash-to-Flash probes 0, suppress by payee node, type paymentType, render tests Applies the three review findings on #708: 1. Render-level disclosure tests. The predicate was fully unit-tested but nothing asserted the component actually renders the caveat, so a wiring regression (e.g. passing fee.amount, the object, instead of fee.amount?.amount) would silently kill the feature with every test green. ConfirmationWalletFee.test.tsx now pins a probed-zero render showing the disclosure, a priced-fee render omitting it, and the Flash-node suppression end to end (mutation-tested: breaking the feeAmount wiring fails the probed-zero case). 2. paymentType is now the PaymentType union BasePaymentDetail uses, compared against PaymentType.Intraledger, so the predicate's most safety-critical exclusion is compiler-checked instead of stringly typed. 3. The "rare genuinely-free external route" framing was unverified — and turned out wrong. Verified live on the Test instance (2026-08-24): minting a Flash-internal USD invoice and probing it via lnUsdInvoiceFeeProbe returns a SET fee of 0 (the backend probe is a blind pass-through to IBEX estimate-fee, no internal-invoice special-casing — flash ln-usd-invoice-fee-probe.ts). Without a guard the caveat would fire on every Flash-to-Flash invoice payment, teaching users to ignore it exactly where it matters. The predicate now suppresses when the held bolt11's payee node pubkey is one of the instance's own lnNodePubkeys (new galoy-instances field; globals.nodesIds is empty on prod and test, verified live, so the ids ship as config). Test's node id is pinned and verified (IBEX_SB); Main's list is deliberately empty until someone with a prod account decodes a prod receive invoice — recipe in galoy-instances.ts. Suppression fails open: no invoice, undecodable invoice, or an empty list all still disclose. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NEoz7nBtdtsHyuYG5wNPQV * fix(send): pin the verified prod node for Flash-to-Flash suppression, memoize invoice decode Round-2 review fixes for #708: - Main's lnNodePubkeys was empty, leaving the Flash-to-Flash caveat suppression inert on prod — the disclosure fired on every prod Flash-to-Flash invoice payment despite full-amount delivery. Pinned 03501a74…ac106 (IBEX_Ops1), verified 2026-08-24 by minting five live prod invoices via the LNURL-pay callback across two accounts and four amounts (1 to 50,000 sats); all decode to this single payee. Tests now decode a real prod invoice and fail if the pin regresses or drifts. - payeeNodePubkey ran eagerly on every render, re-doing sync ECDSA pubkey recovery on each fee/quote state transition. Memoized on paymentRequest; a render test counts decode calls and fails on the eager version (verified: 2 calls un-memoized, 1 memoized). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NEoz7nBtdtsHyuYG5wNPQV * fix(i18n): keep the locale diff to the one key this PR introduces The earlier locale fill rewrote the 23 translation JSONs through a JSON parser, which silently DEDUPED a literal duplicate 'allowanceExhausted' line that main carries — runtime-neutral (parsers collapse duplicates anyway) but 23 files of unrelated diff bundled into a send-flow PR. Restored main's exact bytes and re-inserted feeDeductedFromAmount as a text edit. The translations diff vs main is now pure additions: one line per file. Verified: zero deletion lines, all 23 files parse, drift check green, 880 tests green. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NEoz7nBtdtsHyuYG5wNPQV --------- Co-authored-by: Dread <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
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.
Fixes ENG-556. Confirmed in production on v0.6.6.
The report
Sending to
[email protected]from a USD wallet, nothing under $1.00 could be sent, and the error read:Why $1.00, exactly
Strike advertises
minSendable: 100000msat = 100 sats.app/components/send-flow/DetailAmountNote.tsxcompared:LUD-06 bounds are in sats; a cash wallet's
settlementAmountis in cents. So 100 sats was read as 100 cents and the app demanded a dollar — for a receiver whose real floor is worth single-digit cents. Over 10× overstated, and the threshold moves with the BTC price.The maximum had the identical fault in the opposite direction: against Strike's 16,000,000-sat ceiling it could only fire above $160,000, so it never protected anyone. Silent rather than loud, which is why nobody reported it.
Both bounds are now converted into the sending wallet's units before comparing.
Converted is not enough — the bound has to be typeable
A converted bound is usually fractional, and the number pad only accepts whole minor units. Left fractional, the app can name a minimum it then refuses: at BTC $64,000 Strike's floor converts to 6.4¢, the message rounds that to "$0.06", the user types 6¢ — and is refused again. A dead end at roughly half of all price levels.
So the bound is quantized outward before it is either enforced or named: the minimum rounds up, the maximum rounds down, so the quantized bound is always one the receiver accepts, and the amount printed in the message is exactly the smallest (largest) entry that will be accepted. Float noise is stripped first — 100 sats at exactly BTC $70,000 computes to
7.000000000000001cents, and a naiveceilwould name 8¢ as the floor of a bound that is really 7¢.That rule now lives in one place,
lnurlBoundInWalletUnitsinapp/screens/send-bitcoin-screen/max-send-amount.ts, next toresolveRecipientCap, and both the MAX chip and this check call it. The sat→wallet conversion goes throughpaymentDetail.convertMoneyAmount— the same functionsettlementAmountitself was derived from, matching the sibling call insend-bitcoin-details-screen.tsx— so both sides of the comparison come from one source.Why "NaN"
The i18n placeholder was typed as a number:
minAmountInvoiceError: "...minimum amount {amount: number}"formatDisplayAndWalletAmountreturns a formatted string, so the call site satisfied the type withNumber("$0.07")— which isNaN. The placeholder is now{amount: string}and the formatted value passes through intact. That also makes the mistake uncompilable rather than merely fixed.The message names the bound as money in the wallet's own units ("$0.07"), not as sats —
formatDisplayAndWalletAmountdrops the suffix for a cash wallet under a USD display currency.Retyping surfaced a second call site in
redeem-flow/InforError.tsxpassing a bare1for "one cent"; it now formats the amount so the message names a unit ("$0.01").The same two keys were still declared
{amount: number}in all 23 translated locale files. Harmless at runtime — typesafe-i18n strips the annotation when interpolating — but the corpus contradicted its own source of truth andcheck:translation-driftonly compares key presence, so nothing would ever have caught it. Retyped in the same pass that seedsallowanceExhausted, anchored on the key so each locale's own phrasing is preserved.Scope
settlementAmountis already in sats, so its comparison was correct.minSendable: 1000msat = 1 sat, socents < 1is unreachable. It takes an external receiver with a real floor, which is why this survived to production.Tests
detail-amount-note.spec.tsxruns every cash-wallet case against both USD and USDT (DetailAmountNoteroutes them through one branch):ceil(bound) - 1refused,ceil(bound)allowed,floor(maxBound)allowed,floor(maxBound) + 1refused.lnurlBoundInWalletUnitshas its own unit tests inmax-send-amount.spec.ts, including both float-noise directions and NaN passthrough.New:
__tests__/components/redeem-flow-infor-error.spec.tsx— the redeem flow's one-cent threshold had no coverage anywhere. It asserts the message says$0.01(not1, not$1.00), that the formatter is handed a one-centMoneyAmount, and that no error renders once the entry clears a cent.731 tests pass;
tsc:check,check:translations,check:translation-drift,check:codegenandgraphql-checkclean; no new lint on changed lines.One unrelated inclusion, deliberately
TopupDetails.allowanceExhaustedis seeded into the 23 locale files. #700 added it toen/index.tswithout regenerating the raw source, so runningupdate-translationshere surfaced the gap andcheck-translation-driftwould otherwise fail on this branch. Mechanical, and required for CI to pass.🤖 Generated with Claude Code
https://claude.ai/code/session_016MsAGwtS4sNodzWu2VMTKR