From fabfff494c5c5a76ccfb0021f3a7c0fe6f6d9577 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 24 Jun 2026 22:01:32 -0700 Subject: Balance, claim button, and gift-recipient backup verification - Spendable headline no longer counts pending incoming receives: compute it from UTXOs (confirmed coins + our own unconfirmed change, minus gift locks) so a pending spend still debits immediately but a pending receive shows only on the PENDING line (new pendingIncoming getter). - Claim button shows the fee in parens in slightly smaller font, no dot. - Gift recipients now get the same "Verify backup" / "Skip verification" flow as new-wallet creation instead of a single "I've written it down" button. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/wallet.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/wallet.js') diff --git a/src/wallet.js b/src/wallet.js index d4418a5..5b524e6 100644 --- a/src/wallet.js +++ b/src/wallet.js @@ -591,9 +591,23 @@ export class Wallet { const res = this.reservedSet(); return this.utxos.reduce((s, u) => s + (res.has(utxoId(u)) ? u.value : 0), 0); } - // What the user can actually spend right now: everything minus gift locks. + // The spendable headline: confirmed coins plus our own unconfirmed change (the + // remainder of a spend we just made, so the spend debits immediately), minus + // anything locked in gifts. Unconfirmed *incoming* receives are NOT counted + // here — they show as pending until they confirm. get spendable() { - return this.total - this.lockedValue; + const res = this.reservedSet(); + return this.utxos.reduce((s, u) => { + if (res.has(utxoId(u))) return s; + if (u.confirmed || u.chain === 1) return s + u.value; + return s; + }, 0); + } + // Unconfirmed incoming receives (not our change, not gift-locked) — shown as a + // separate pending line, kept out of the spendable headline. + get pendingIncoming() { + const res = this.reservedSet(); + return this.utxos.reduce((s, u) => s + ((!u.confirmed && u.chain === 0 && !res.has(utxoId(u))) ? u.value : 0), 0); } _recomputeBalanceFromChains() { -- cgit v1.2.3