summaryrefslogtreecommitdiffstats
path: root/src/wallet.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-06-24 22:01:32 -0700
committerAdam Soltys <[email protected]>2026-06-24 22:01:48 -0700
commitfabfff494c5c5a76ccfb0021f3a7c0fe6f6d9577 (patch)
tree9814c007b55762442481e37b53758ae532ebd496 /src/wallet.js
parent6e8cf569c0fa04495b37b673857b9b1d5c7a669b (diff)
downloadcoinosv3-fabfff494c5c5a76ccfb0021f3a7c0fe6f6d9577.tar.gz
coinosv3-fabfff494c5c5a76ccfb0021f3a7c0fe6f6d9577.zip
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) <[email protected]>
Diffstat (limited to 'src/wallet.js')
-rw-r--r--src/wallet.js18
1 files changed, 16 insertions, 2 deletions
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() {