aboutsummaryrefslogtreecommitdiffstats
path: root/src/wallet.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-06-27 15:55:53 -0700
committerAdam Soltys <[email protected]>2026-06-27 15:55:53 -0700
commite52327891130138d73e48ee8dd42781359a473c8 (patch)
treee3753b13e77383fa5467d74e817d2b057be02629 /src/wallet.js
parent2edad313d270354eb2f8e3420272897c14325f42 (diff)
downloadcoinosv3-e52327891130138d73e48ee8dd42781359a473c8.tar.gz
coinosv3-e52327891130138d73e48ee8dd42781359a473c8.zip
Auto-scan for silent payments + fold found value into balance
scanSilentPayments() now recomputes the balance so received SP value shows in the wallet total (not just the Receive card), and gains a silent mode. It's triggered automatically after each full scan and on the poll loop (incremental, cheap), so payments appear without tapping anything. The Receive card now shows a status line ('Watching for payments' / found amount) with a small manual Rescan instead of a primary Scan button. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Diffstat (limited to 'src/wallet.js')
-rw-r--r--src/wallet.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/wallet.js b/src/wallet.js
index 107076a..bff8910 100644
--- a/src/wallet.js
+++ b/src/wallet.js
@@ -307,13 +307,13 @@ export class Wallet {
// Scan the configured SP indexer from the last-scanned height to the tip, find
// outputs paying our scan/spend keys, and verify each is unspent via the chain
// backend (the indexer only does discovery). Updates this.spUtxos.
- async scanSilentPayments({ rescan = false } = {}) {
+ async scanSilentPayments({ rescan = false, silent = false } = {}) {
const keys = this.silentPaymentKeys();
const indexer = spIndexerUrl(this.netName);
if (!keys || !indexer || this.offline) return { unavailable: true };
if (this.spScanning) return { busy: true };
this.spScanning = true;
- this.emit();
+ if (!silent) this.emit(); // manual scans show a "Scanning…" state; auto-scans stay quiet
try {
if (rescan) { this.spUtxos = []; this.lastSpScan = 0; }
const from = (this.lastSpScan || 0) + 1;
@@ -345,12 +345,13 @@ export class Wallet {
} catch {}
}
await this._refreshSpUtxos();
+ this._recomputeBalanceFromChains(); // fold found SP value into the displayed balance
this.saveCache();
this.emit();
return { found: found.length, scanned: tip };
} finally {
this.spScanning = false;
- this.emit();
+ if (!silent) this.emit();
}
}
@@ -729,6 +730,7 @@ export class Wallet {
}
this.loaded = true;
this.saveCache();
+ this.scanSilentPayments({ silent: true }).catch(() => {}); // fold in any silent-payment receipts
} finally {
this._refreshing = false;
this.historyLoading = false; // clear even if an earlier step threw
@@ -1633,6 +1635,7 @@ export class Wallet {
if (Date.now() - (this._lastPoll || 0) < due) return;
this._lastPoll = Date.now();
this.refreshLive();
+ this.scanSilentPayments({ silent: true }).catch(() => {}); // pick up new SP receipts (incremental, cheap)
}, 1000);
// No periodic full re-scan: the WS (and the frontier poll above) keep the
// balance current, and refreshLive's _reconcileHeld catches spends of held