Skip to content

fix(flashcard): name a Cashu card's unit at once from what the mint named before - #752

Merged
islandbitcoin merged 3 commits into
mainfrom
jabariennis/flashcard-v2-known-units
Oct 5, 2026
Merged

islandbitcoin merged 3 commits into
mainfrom
jabariennis/flashcard-v2-known-units

Conversation

@islandbitcoin

Copy link
Copy Markdown
Contributor

A tap shows the Cashu card at once, but its balance read "· unit unknown" until forge's keyset list came back. That list was cached in memory only, so after a cold start every first tap waited on the network. A card operation that moves the balance, such as a top-up load, did the same. Found during the 2026-10-02 device test.

Fix: a keyset's unit never changes, so the flashcardV2 slice now keeps the units the mint names (keysetUnits).

  • Labelled at once: a read whose keysets are all named is labelled on its first render. So is a card operation's new split.
  • Still asked: the mint is still asked on every read, and its answer replaces the label.
  • No guessing: a card holding a keyset the mint hasn't named waits for its answer, as before.
  • Same rules as the slice: only signed-in reads write it, and logout clears it. It's public mint data, no account data.
  • Late answers: a late mint answer for an old split still never lands on the card. Its units are kept, since they're facts about the mint.

Tests:

  • a later read labelled before the mint answers;
  • a card with an unnamed keyset still waiting;
  • a signed-out read keeping nothing;
  • a value-moving operation labelled at once;
  • the slice merging what the mint names, and reset clearing it.

Each fails when the behaviour it names is removed. Full suite: 154 suites, 1,826 tests.

🤖 Generated with Claude Code

…amed before

A tap showed the card at once, but its balance as "· unit unknown" until
forge's keyset list came back: the list was cached in memory only, so after
a cold start every first tap waited on the network. A balance-moving card
operation (a top-up load) did the same.

A keyset's unit never changes, so the flashcardV2 slice now keeps the units
the mint names (`keysetUnits`, signed-in reads only; logout clears them). A
read, or an operation's new split, whose keysets are all named is labelled
on its first render; the mint is still asked, and a card holding a keyset it
has not named waits for its answer as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@islandbitcoin
islandbitcoin force-pushed the jabariennis/flashcard-v2-known-units branch from 11fb81c to 6b796b1 Compare October 4, 2026 23:04
Dread and others added 2 commits October 4, 2026 18:28
…card from known units

Review fixes for #752:
- A tap labelled from `keysetUnits` now sets the card record's unit too,
  as the card-operation path already did. `cardSeen` clears that unit when
  the balance moved, so after a spend elsewhere the home row said "unit
  unknown" beside a card screen that named the unit, until the mint
  answered (never, offline).
- Tests: the record is named at once after a spend while the mint is
  slow; a card holding one named and one unnamed keyset still waits on the
  mint (`every`, not `some`); a stale mint answer's units are still kept.
- Docs: `CashuCardState.unitTotals`, `resolveCashuUnits`, `KnownCard.unit`
  and `cardUnitResolved` now describe labelling from `keysetUnits`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d from known units

Review fixes for #752:
- A tap the mint cannot label leaves the record's unit as `cardSeen` left
  it. New spec beside "the record's unit alone": a record named on a build
  before `keysetUnits` keeps its unit at an unchanged balance while the
  mint is unreachable, so the home row does not fall back to "500 · unit
  unknown". It fails if the tap path dispatches an unlabelled unit as the
  op path does; the guard's comment now says why it does not.
- A card holding sat and usd names no single unit on its record, on a tap
  and after an op that loads the second unit, both labelled at once from
  `keysetUnits` (`soleUnit`, never the first unit). `makeSplitCard` takes
  a `loadKeyset` for the op case.
- Docs: `balanceLines` and the op spec's header now say a split whose
  keysets the mint named before is labelled at once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@islandbitcoin
islandbitcoin merged commit b31610f into main Oct 5, 2026
8 of 9 checks passed
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.

1 participant