aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-06-16 00:00:34 -0700
committerAdam Soltys <[email protected]>2026-06-16 00:00:34 -0700
commit6803575cb3fcbe1bb92a6c40b9e810a294f5d657 (patch)
tree11ed2229ed765aa5f99268373382ea046accb1ff
parentb312abb4432cb3258c896541babd9a31c9aabca9 (diff)
downloadcoinosv3-6803575cb3fcbe1bb92a6c40b9e810a294f5d657.tar.gz
coinosv3-6803575cb3fcbe1bb92a6c40b9e810a294f5d657.zip
Advance fresh address instantly on WS deposit
The pending balance showed immediately from the WS ingest, but the next receive address/QR only appeared after the debounced refreshLive. Now the WS ingest marks the receiving address used and advances the fresh index right away, so the new address shows in the same update as the balance. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
-rw-r--r--src/wallet.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/wallet.js b/src/wallet.js
index b266283..c57149f 100644
--- a/src/wallet.js
+++ b/src/wallet.js
@@ -697,12 +697,27 @@ export class Wallet {
const confirmed = !!(tx.status && tx.status.confirmed);
this.utxos.push({ txid: tx.txid, vout: i, value: vo.value, address: a, chain: p.chain, index: p.index, confirmed });
have.add(id);
- if (confirmed) this.confirmed += vo.value;
- else this.pending += vo.value;
+ // Mark the receiving address used + record its balance, so the fresh
+ // index advances immediately (next address/QR shows right away).
+ const arr = p.chain === 0 ? this.receive : this.change;
+ let entry = arr.find((e) => e.index === p.index);
+ if (!entry) {
+ entry = { chain: p.chain, index: p.index, address: a, used: false, confirmed: 0, pending: 0 };
+ arr.push(entry);
+ }
+ entry.used = true;
+ if (confirmed) entry.confirmed = (entry.confirmed || 0) + vo.value;
+ else entry.pending = (entry.pending || 0) + vo.value;
changed = true;
});
}
- if (changed) this.emit();
+ if (changed) {
+ this.nextReceiveIndex = firstUnused(this.receive);
+ this.nextChangeIndex = firstUnused(this.change);
+ this._recomputeBalanceFromChains();
+ this.retrack(); // start watching the new fresh address
+ this.emit();
+ }
return changed;
}