From a6bfb5bd4429cf7069a5d0c5e61cb5873ddd8230 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 24 Jun 2026 20:31:08 -0700 Subject: Deduct gift-locked coins from the spendable balance Coins reserved behind unclaimed gift links were already excluded from spending, but the headline balance still counted them. Show the spendable balance (total minus gift locks) as the headline and surface the locked amount as its own line, so a gift debits immediately rather than at claim. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/wallet.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/wallet.js') diff --git a/src/wallet.js b/src/wallet.js index 72d33be..2871c5e 100644 --- a/src/wallet.js +++ b/src/wallet.js @@ -583,6 +583,19 @@ export class Wallet { return this.confirmed + this.pending; } + // Confirmed coins locked behind unclaimed gift links. The whole source coin is + // committed until the gift is claimed (our change only comes back in the + // claimer's tx), so it's already excluded from spending — and from the + // spendable balance below. + get lockedValue() { + 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. + get spendable() { + return this.total - this.lockedValue; + } + _recomputeBalanceFromChains() { let c = 0; let p = 0; -- cgit v1.2.3