Skip to content

feat(send): max amount button on the amount screen - #689

Merged
islandbitcoin merged 8 commits into
mainfrom
feat/max-amount-button
Aug 15, 2026
Merged

islandbitcoin merged 8 commits into
mainfrom
feat/max-amount-button

Conversation

@islandbitcoin

Copy link
Copy Markdown
Contributor

Summary

Implements the approved design for a MAX button on Lightning sends: a compact chip in the amount screen's balance header, immediately right of the balance value.

Fixes #512

UX

  • Chip states: outlined green (available) → solid green while the entered amount equals the computed max → back to outlined the moment the user edits the amount. Greyed out and non-interactive when the balance is zero. All colors come from the theme (colors.primary) — no hardcoded hex.
  • Info row: while the chip is solid, a note under the amount explains the computation (fee reserved / no fee / recipient cap). An error message always takes precedence over the note.
  • Currency toggle: toggling display currency keeps the same underlying amount, so the chip stays solid.

Max rules

Destination Max Note shown
Intraledger / Flash-to-Flash Full wallet balance, no API call "Full balance — no fee between Flash accounts"
External invoice / LNURL (BTC wallet) Balance − fee estimate via fetchBreezFee (reuses the resolved payRequest from #680, no second LNURL round-trip) "~$0.26 reserved for the network fee — final fee shown on confirm"
External invoice (USD wallet) Balance − fee via the existing fee probes (useIbexFee), probed at the full balance same as above
LNURL destinations Clamped to min(computed max, maxSendable) — reuses the LUD-06 bounds validation shipped in #680; applies to BTC-wallet intraledger sends too since they settle via LNURL-pay "Capped at … — the most this recipient can receive per payment"
Fee estimate fails / times out Fills the full balance anyway; the existing pre-validation from #680 surfaces the typed fee error. The tap never blocks and never spinner-traps. —

Architecture

amount-input-screen stays a generic component with zero payment knowledge. It gains an optional maxAmountButton?: { disabled?: boolean; compute: () => Promise<{ amount, note? } | null> } prop — when absent (all other usages of the amount screen), no chip renders and nothing changes.

The computation lives in the send flow:

  • app/screens/send-bitcoin-screen/max-send-amount.ts — pure, dependency-free max rules (computeMaxSendAmount), unit-testable under plain jest (same pattern as fee-errors.ts from fix(send): surface real BTC fee errors and validate LNURL receive limits #680).
  • send-bitcoin-details-screen.tsx builds the config from the payment detail (intraledger vs external vs LNURL, balances, resolved receiverPayRequest/receiverLimits) and threads it: DetailAmountNote → AmountInput → AmountInputModal → AmountInputScreen → AmountInputScreenUI.

The filled amount is floored in the primary display currency so it never converts back to more than the computed max in wallet units.

i18n

Four new AmountInputScreen keys in app/i18n/en/index.ts (max, maxNoteIntraledger, maxNoteFeeReserved, maxNoteRecipientCap). English placeholders appended to all 23 locale files under raw-i18n/translations/ for the next translation batch; generated i18n-types.ts and raw-i18n/source/en.json committed. No literal $ before interpolations — currency symbols arrive in the interpolated values.

Tests

  • __tests__/utils/max-send-amount.spec.ts — 12 unit cases: intraledger = balance; external = balance − fee; LNURL clamp (binding, non-binding, on intraledger, on the fallback); fee null / throw / timeout fallbacks; zero balance; fee ≥ balance; negative/NaN fee.
  • __tests__/components/amount-input-screen-max-chip.spec.tsx — 6 component cases in the house style of the fix(send): surface real BTC fee errors and validate LNURL receive limits #680 DetailAmountNote tests: no chip without the prop; outlined → tap fills the display-currency amount, goes solid, shows the note; editing returns it to outlined and hides the note; solid across currency toggle; greyed + inert at zero balance.

Checks run locally: yarn test 57 suites / 332 tests green, yarn tsc:check clean, eslint clean on changed lines, yarn check:translation-drift green, yarn update-translations idempotent (generated files committed).

🤖 Generated with Claude Code

https://claude.ai/code/session_015fAxSGEsL2LsMx1uCjAzHH

Dread and others added 4 commits August 13, 2026 14:23
Adds a MAX chip beside the balance in the amount input screen's header
(issue #512). Outlined green when available, solid green while the
entered amount is the computed max, back to outlined the moment the
user edits, greyed out on a zero balance. Theme colors only.

Max rules, computed in the send flow (the amount screen stays free of
payment knowledge via an optional maxAmountButton prop):
- intraledger / Flash-to-Flash: full wallet balance, no API call; note
  says there is no fee between Flash accounts
- external invoice / LNURL: balance minus the fee estimate (BTC wallet
  via fetchBreezFee, USD wallet via the existing fee probes); note
  states the reserved fee
- LNURL destinations clamp to the receiver's maxSendable (reuses the
  payRequest bounds from #680)
- fee estimate failure or timeout fills the full balance and lets the
  existing pre-validation surface the typed fee error — the tap never
  blocks

The currency toggle keeps the same underlying amount, so the chip
stays solid across toggles.

i18n: new AmountInputScreen keys in en, English placeholders appended
to all 23 locale files for the next translation batch.

Tests: computeMaxSendAmount unit suite (12 cases) and an
AmountInputScreen component suite for the chip states (6 cases).

Fixes #512

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015fAxSGEsL2LsMx1uCjAzHH
- BTC-wallet intraledger sends settle via LNURL-pay with a real Breez
  fee: route them through the fee path (effectiveMaxPaymentType) instead
  of filling the full balance with a false no-fee note, which dead-ended
  every BTC-wallet MAX-to-Flash send at confirm time
- exclude onchain from the chip: its fee estimate needs the not-yet-
  selected fee speed and the flow already has its own send-all Max
- guard NaN balances: disable the chip while wallets are still loading
  and treat non-finite balances as zero in computeMaxSendAmount, so the
  number pad can never fill the literal string NaN
- drop stale in-flight max computations: any edit (key press, clear,
  currency toggle) invalidates the pending fee fetch so a slow resolve
  can no longer overwrite the user's typed amount or revert a currency
  toggle; the chip now shows a computing state while the fetch runs
- show no note when the reserved fee is zero (a $0.00 reservation note
  is nonsense)
- extract the decision logic into pure functions (maxChipSupports-
  PaymentType, effectiveMaxPaymentType, resolveRecipientCap,
  noteForResult) and unit-test them, plus component tests for the
  computing state and stale-resolve races

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015fAxSGEsL2LsMx1uCjAzHH
fetchBreezFee bounds-validates the probe amount against the receiver's
LUD-06 limits before preparing, so probing at the full balance was
guaranteed to fail whenever the recipient cap binds — the fee came back
null and MAX filled the cap-clamped amount with no fee headroom. In the
band where balance - cap < fee, confirm-time validation then dead-ended
with "amount exceeds balance (amount + fee)".

computeMaxSendAmount now derives the probe amount (balance clamped to
the recipient cap) and passes it to fetchFee; the details screen probes
Breez/IBEX at that amount. Both regimes now yield a confirm-safe MAX:
min(balance - fee, cap). Adds unit tests for the probe amount and the
cap-within-fee-distance-of-balance band.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015fAxSGEsL2LsMx1uCjAzHH
…overdraw

On-device repro (iPhone, USD cash wallet, zero-amount invoice): the API
reports USD balances in FRACTIONAL cents (109.9346 = $1.099346 at
IBEX); MAX offered it un-floored, downstream rounding produced a
$1.10 invoice, and IBEX rejected the send — 'insufficient balance.
Current Balance: 1.099346 ... invoice amount: 1.100000'.

computeMaxSendAmount now floors the spendable balance, the fee-adjusted
result, and the recipient cap to whole minor units (no-op for integer
sat balances), and a sub-cent balance counts as zero. Four regression
tests pin the repro numbers.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015fAxSGEsL2LsMx1uCjAzHH
@islandbitcoin

Copy link
Copy Markdown
Contributor Author

Device-testing follow-up: MAX on a fractional-cent USD balance ($1.099346) produced a $1.10 invoice and an IBEX insufficient-balance rejection. Fixed in the latest commit — the max computation now floors balance, fee-adjusted result, and recipient cap to whole minor units (sats unaffected), with regression tests pinning the exact repro numbers. Full suite 360/360 green.

The pad can hold a different currency than the wallet (JMD display over
a USD wallet). The fill converted the wallet-unit max into the pad
currency and floored there — but the send path converts the pad amount
BACK to wallet units and rounds, so a forward-rounding conversion (or a
rate tick) can still round-trip above the computed max and overdraw.

The fill now steps the pad amount down until its round-trip back to
wallet units stays within the computed max. Component test pins the
class with a coarse rounding converter (109-sat max, 10-sats-per-cent:
naive fill 11 cents → 110 sats overdraw; guarded fill 10 cents).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015fAxSGEsL2LsMx1uCjAzHH
Dread and others added 3 commits August 14, 2026 11:31
Review fixes for the MAX amount chip (PR #689):

- amount-input-screen: the initialAmount reset effect now clears the
  applied-MAX chip state and bumps the edit generation. A new initial
  amount means the caller committed or replaced the amount (Set Amount
  closed the modal and it reopened), so a late MAX resolve can no longer
  overwrite the committed amount or leave the chip solid with a stale
  fee note asserting the committed amount is the computed max.

- max-amount-button: extract buildMaxAmountButton from the details
  screen into a dependency-injected factory next to max-send-amount.ts,
  and unit-test the previously uncovered glue in plain jest — the Breez
  fetchFee adapter's err-to-null mapping, knownPayRequest reuse, the
  flash-address preference, the USD probe-detail construction via
  setAmount/getIbexFee, and the note-kind to string mapping.

- sub-cent balances: disable the chip when Math.floor(balance) is zero
  (a USD wallet drained by a MAX send holds fractional cents, e.g.
  0.9346, which is unspendable), and have compute() return null on a
  zero-balance result instead of emptying the pad under a solid chip.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015fAxSGEsL2LsMx1uCjAzHH
A positive wallet-units max worth under one display minor unit (e.g. a
dust BTC balance under USD display) floored to a zero fill: the pad
emptied under a solid MAX chip and Set Amount stayed ready to commit a
zero amount. When the display fill floors (or steps) to 0 while the
computed max is positive, fill the pad in wallet units instead — the
true max needs no display round-trip since the computation already
floors it to whole wallet minor units.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015fAxSGEsL2LsMx1uCjAzHH
Round-3 review follow-ups for PR #689:

- The zero-max escape gated on reason === 'zero-balance' only, but a fee
  estimate meeting/exceeding the balance ({amount: 0, reason:
  'fee-reserved'}) and a receiver advertising maxSendable 0 also produce
  zero — and would empty the pad under a solid chip. Gate on the amount
  itself; three unit tests cover the routes.

- After a wallet-units dust fill, toggling display currency rounds the
  amount (0.5 cents → 1 cent = double the 5-sat max, or 0.4 → 0 = empty
  pad) while the chip stayed solid. A lossy toggle now drops the MAX
  claim; faithful toggles keep it. Component test pins it.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015fAxSGEsL2LsMx1uCjAzHH
@islandbitcoin
islandbitcoin merged commit 12a9c77 into main Aug 15, 2026
10 checks passed
@islandbitcoin
islandbitcoin deleted the feat/max-amount-button branch August 15, 2026 07:46
islandbitcoin added a commit that referenced this pull request Aug 15, 2026
…#697)

The conversion and cashout percentage quick-buttons Math.round-ed the raw
fractional-cent balance (flash#480), so on a wallet holding 109.9346 cents
tapping 100% filled 110 cents — more than is spendable — driving cashout
into the max-amount error and conversion into a swap that can't be filled.

Extract percentageOfBalance next to toSpendableBalance: floor the balance
to whole minor units first, then floor the percentage result, so every
quick-set amount is a whole, sendable minor unit <= the spendable balance.
At 100% this matches toSpendableBalance exactly — the same rule as the
MAX chip (#689) and the balance displays (#695).

Fixes #696


Claude-Session: https://claude.ai/code/session_015fAxSGEsL2LsMx1uCjAzHH

Co-authored-by: Dread <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>
islandbitcoin pushed a commit that referenced this pull request Aug 16, 2026
check:translation-drift requires each locale to contain every key in
en.json. Added with the English text as the placeholder, matching how
previous key-adding PRs (#689, #691, #693) seeded new keys before
translation.
islandbitcoin added a commit that referenced this pull request Aug 16, 2026
* fix(swap): stop reporting unsettled conversions as successful

A Cash->BTC conversion showed the success screen while no funds moved,
and the retry died on a generic error. Three defects in the swap flow,
all of which also affect production:

- swap() returned `true` for PENDING, so the confirmation screen
  navigated to "Conversion successful". A payment that is merely in
  flight — or one the API could not confirm at all — rendered as
  settled. It now returns a discriminated {status: "success"|"pending"},
  and the success screen shows an "in progress" state (payment-pending
  icon, its own copy, longer dwell) for the pending case.
- swap() read `status` before `errors`. The API reports a payment it
  could not confirm as PENDING *carrying* an error (see flash#483), so
  errors must win; they now throw.
- prepareUsdToBtc swallowed lnUsdInvoiceFeeProbe payload errors via
  `amount || 0`, sending the user to confirmation on a fee we never
  obtained — the real reason ("An error occurred. Contact support…")
  was discarded and resurfaced later as a vaguer send failure. Probe
  errors and a missing amount are now surfaced at the details screen.
- The Breez branch of swap() fell off the end returning undefined when
  the send failed, which the confirmation screen read as "nothing
  happened": no success, no error, no spinner reset. It now throws on
  failure and distinguishes Completed from Pending.

Also fixes the shared Breez SDK test mock, which exported PaymentStatus
as strings keyed "Complete" while the real SDK (and app code such as
app/types/transactions.ts) uses numeric `Completed` — any test touching
that comparison silently took the wrong branch.

Tests: 10 new covering each behaviour above. Full suite 67/471 green,
tsc clean, no ESLint errors on changed lines.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01NEoz7nBtdtsHyuYG5wNPQV

* chore(i18n): carry the three new keys into every translation file

check:translation-drift requires each locale to contain every key in
en.json. Added with the English text as the placeholder, matching how
previous key-adding PRs (#689, #691, #693) seeded new keys before
translation.

* fix(swap): address review on the pending/probe-error PR

- conversion-details-screen: submit-time errors go to a separate
  `submitErrorMsg` state instead of `errorMsg`. `ConversionAmountError`
  only clears `errorMsg` from an effect keyed on the amount, so a probe
  error parked there left Next permanently greyed out with no hint that
  nudging the amount was the only escape.
- conversion-details-screen: wrap `moveToNextScreen` in try/catch/finally.
  `receivePaymentBreez` has no try/catch and the Apollo fee probe rejects
  on network error, so a probe timeout left the spinner up forever plus an
  unhandled rejection.
- conversion-confirmation-screen: drop the `if (lnInvoice)` wrapper so the
  `!lnInvoice` guard added in useSwap is reachable. `prepareBtcToUsd` can
  produce `lnInvoice: ""`, and Convert was a silent dead tap for it.
- useSwap: switch on the generated `PaymentSendResult` const instead of raw
  string literals, with an explicit `FAILURE` case so `default:` means only
  "unrecognised". A codegen rename would otherwise break the app at runtime
  with every test green.
- useSwap: correct the errors-outrank-status comment — the server does not
  pair an error with a non-failed status today; the ordering is defensive.
- useSwap: `throw new Error("Invoice is already paid")` was hardcoded
  English toasted straight to the user; use the translated
  `ReceiveScreen.invoicePaid`.
- useSwap: delete the three remaining `console.log(">>>>>>>>")` lines; one
  dumped the full Breez receivePayment response into the retained log
  buffer on every USD->BTC conversion.
- i18n: drop all three new English keys. `common.somethingWentWrong` was
  byte-identical to the already-translated `errors.generic`, and the
  pending copy duplicates the fully-translated
  `SendBitcoinScreen.notConfirmed` the send flow already renders for an
  unconfirmed payment. They had shipped as English into all 23 locales;
  app/i18n/ is now byte-identical to main.
- tests: new conversion-success-screen, conversion-confirmation-screen and
  conversion-details-screen suites — the wiring that turns
  `{status: "pending"}` into a pending screen had no coverage at all.
  Verified by mutation: hardcoding `pending`, restoring the `if (lnInvoice)`
  guard, moving the submit error back into `errorMsg`, or removing the
  try/catch each turns them red.
- tests: useSwap's wholesale mock of @app/graphql/generated now takes
  `PaymentSendResult` from `jest.requireActual`, so a codegen change fails
  the test instead of passing against stale literals.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01NEoz7nBtdtsHyuYG5wNPQV

* fix(swap): report probe failures, clear stale submit errors, fix PaymentType mock

Follow-up review fixes on the pending/probe-error PR.

- __mocks__ PaymentType was still string-valued while the real SDK enum is
  numeric (Send = 0, Receive = 1) — the same trap that had already been fixed
  for PaymentStatus three lines below, left armed in the same object literal.
  Any test using a realistic Breez fixture (paymentType: 1) would have compared
  1 === "Receive", taken the send branch, and passed green while asserting the
  opposite of production behaviour. Both enums now carry the generated numbering
  and one comment covering the whole block.
- conversion-details-screen: the new catch swallowed the rejection into on-screen
  text and reported it nowhere, unlike its sibling in conversion-confirmation-screen.
  It now records the error to Crashlytics before setting the message, so the
  fee-probe failure rate is visible in the field.
- conversion-details-screen: submitErrorMsg was cleared only on submit, so a stale
  "An error occurred" stayed pinned under the inputs after a direction flip or an
  amount edit — describing a request that no longer matched the screen. It now
  clears on the same keys ConversionAmountError re-validates on.

Tests:
- app/types/__tests__/transactions.test.ts (new): isReceiveTransaction and
  getTransactionStatus against raw numeric SDK values; red with the string mock.
- conversion-details-screen tests: the amount-validation gate test now actually
  produces an error (was passing purely on "no amount entered", so deleting
  `|| Boolean(errorMsg)` left the suite green); a new test drives the USD→BTC
  direction and asserts prepareUsdToBtc is the one called; two new tests cover
  stale submit-error clearing; the reject tests now assert the Crashlytics report.

All five fixes verified by mutation: reverting each one turns its test red.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01NEoz7nBtdtsHyuYG5wNPQV

* fix(swap): record non-Error rejections to Crashlytics too

The catch branch added for non-Error rejections showed the generic copy
and recorded nothing, so the least diagnosable failure — an Apollo link
or Breez binding throwing a string — was also the only invisible one.
Wrap instead of branching: the report now carries the raw thrown value,
while the user still sees the generic message.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01NEoz7nBtdtsHyuYG5wNPQV

* style: prettier formatting on the crashlytics wrap

---------

Co-authored-by: Dread <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
islandbitcoin pushed a commit that referenced this pull request Aug 21, 2026
…hem (#706)

* fix(send): compare LNURL bounds in the wallet's own units, and name them

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

* fix(send): quantize LNURL bounds to whole wallet units and share the 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

* fix(send): enforce LNURL bounds in sats, quote them in the pad's units

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.

* test(send): cover the pad toggled into wallet units

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

* test: name the redeem-flow spec after the behaviour, not the misspelling

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

---------

Co-authored-by: Dread <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] - Create Max amount button for Lightning Transactions

1 participant