Files
minibits_wallet/__tests__
minibits-cashandClaude Opus 4.8 d008d452ac Add mint capability model (Stage 2 of onchain)
Onchain (NUT-30) means a mint can no longer be assumed to speak bolt11:
a mint may support onchain only, or gain/lose a method over time. The
wallet needs to read what each mint actually advertises and offer only
that.

Fixes the refresh first, because it was doubly broken and nothing built
on mintInfo could be trusted without it:

  - `time` was never written. Every caller passed a raw GetInfoResponse
    through a cast (`info as GetInfoResponse & {time: number}`), so
    mintInfo.time was undefined, `now - undefined` was NaN, and
    `NaN > ttl` is false — the TTL could never fire.
  - The check also sat below getMint's early return for an already-cached
    cashu-ts instance, so it was unreachable for any mint touched once
    this session.

Together those meant mintInfo was fetched when a mint was added and then
never refreshed again. setMintInfo now stamps the time itself (callers
cannot forget), and the staleness check runs even for cached instances,
fire-and-forget so it never delays the operation that triggered it.

Capability views on the Mint model read nuts[4]/nuts[5], which is where
onchain advertises itself — it has no nuts[30] block, it is just another
method entry, so capability is always a (method, unit) question. Two
rules: onchain additionally requires NUT-20 (the mint MUST reject an
onchain quote with no pubkey, error 20009), and when info was never
cached bolt11 is assumed while anything newer must prove itself —
assuming bolt11 exactly preserves today's behaviour and cannot strand an
upgrading user with an empty menu.

Mints that cannot serve an operation are now listed but disabled in the
Topup/Transfer selectors, with the reason in place of the hostname;
hiding them would leave the user hunting for a mint that silently
vanished.

WalletScreen's Send/Receive sheets are relabelled ahead of onchain: the
verb moves to the sheet heading so the rows become plain nouns (Ecash /
Bitcoin) that read as a real either/or, and the descriptions give the
criteria users actually decide on — speed and cost — rather than protocol
names. faBolt would be wrong once onchain exists, so the rail row now
uses the circled faBitcoin mark, tinted to match the BtcIcon SVG already
used by CurrencySign. Neither row asks the user to pick a rail: paying
infers it from what they paste, and topping up asks in TopupScreen where
the mint and unit are known.

221/221 tests pass; typecheck introduces no new errors.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-13 12:45:48 +02:00
..
2026-06-27 23:55:40 +02:00
2026-07-08 15:44:11 +02:00