aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-06-24 19:07:50 -0700
committerAdam Soltys <[email protected]>2026-06-24 19:07:50 -0700
commit8f9952c5f3872ba86265b2845c833eb9c25b511d (patch)
treef24f1373d8e83c53a3f70fe9432ca9a621219e50 /src
parent5bea564663d5c053764ed4444009a2f46f7ca551 (diff)
downloadcoinosv3-8f9952c5f3872ba86265b2845c833eb9c25b511d.tar.gz
coinosv3-8f9952c5f3872ba86265b2845c833eb9c25b511d.zip
Guard the receive celebration to recent payments only
Defense-in-depth so the "payment received" screen can never fire for an old payment on opening a wallet: in addition to the ack baseline, require an incoming tx that is pending or confirmed within the last ~2 hours. Verified it still celebrates genuine new (pending/recent) payments. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/app.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/app.js b/src/app.js
index 34b9989..45b1df1 100644
--- a/src/app.js
+++ b/src/app.js
@@ -1455,14 +1455,22 @@ function tabContent() {
}
}
+// A payment is "recent" enough to celebrate if it's still pending or confirmed
+// within the last couple hours. This is a hard guard so an old payment can never
+// trigger the celebration on import, regardless of receive-index bookkeeping.
+function hasRecentIncoming() {
+ const now = Date.now() / 1000;
+ return wallet.txs.some((tx) => tx.net > 0 && (!tx.confirmed || (tx.blockTime && now - tx.blockTime < 2 * 3600)));
+}
+
// ---------------------------------------------------------------- Receive
function receiveTab() {
// A payment landed on the shown address (the fresh index advanced past what
// the user last saw) — celebrate, and wait for a tap before showing the next.
// Until receiveSeenIndex has been baselined (post-scan, in enterWallet) it
- // stays null and we never celebrate, so importing a wallet with existing
- // history doesn't flash "payment received" for old payments.
- if (ui.receiveSeenIndex != null && wallet.nextReceiveIndex > ui.receiveSeenIndex) {
+ // stays null and we never celebrate. The recency guard additionally ensures an
+ // already-old payment never celebrates when a wallet is opened.
+ if (ui.receiveSeenIndex != null && wallet.nextReceiveIndex > ui.receiveSeenIndex && hasRecentIncoming()) {
let amt = 0;
for (let i = ui.receiveSeenIndex; i < wallet.nextReceiveIndex; i++) {
const e = wallet._addrInfo(0, i);