From 18304984ce9b5fc1bd7a601bba69da692511ae80 Mon Sep 17 00:00:00 2001 From: Padreug Date: Tue, 22 Sep 2026 23:10:31 +0200 Subject: [PATCH] fix(wallet): gate the received-payment toast on status, not absent `pending` Last remaining reader of the phantom `pending` field, same root cause as #161: it is a pydantic `@property` and never appears in the payload, so `!payment.pending` was always true. The guard reduced to `amount > 0` alone and never actually suppressed an unsettled payment, which is what it was there to do. Now checks `status === 'success'`. The nested `else` that toasted "Sent N sats" was unreachable: the enclosing condition already required `amount > 0`. Dropped rather than repaired, because a send made from this app is already confirmed by SendDialog's own success toast and re-announcing it here would double up. An outgoing payment made from another client on the same wallet still lands in the history list; it just does not raise a toast. Verified against a live settled payment over the websocket: amount=44000 status=success pending key present=False Found while checking that the six merged wallet PRs behaved correctly together. --- .../wallet/services/WalletWebSocketService.ts | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/modules/wallet/services/WalletWebSocketService.ts b/src/modules/wallet/services/WalletWebSocketService.ts index 5243b79..4d1b58d 100644 --- a/src/modules/wallet/services/WalletWebSocketService.ts +++ b/src/modules/wallet/services/WalletWebSocketService.ts @@ -289,14 +289,21 @@ export class WalletWebSocketService extends BaseService { this.walletService.addTransaction(payment) } - // Show toast notification for incoming payments - if (payment.amount > 0 && !payment.pending) { + // Toast incoming payments only, and only once settled. + // + // This guard used to read `!payment.pending`, which is never present in + // the payload (a pydantic `@property`; see mapPaymentStatus in + // WalletService), so it was always true and an unsettled payment could + // announce itself as received. `status` is the real field. + // + // The old `else` branch toasted outgoing payments but was unreachable, + // since the enclosing condition already required `amount > 0`. It is + // dropped rather than fixed: a send made from this app is already + // confirmed by SendDialog's own toast, so re-announcing it here would + // double up. + if (payment.amount > 0 && payment.status === 'success') { const amountSats = Math.abs(payment.amount / 1000) - if (payment.amount > 0) { - this.toast.success(`Received ${amountSats} sats!`) - } else { - this.toast.info(`Sent ${amountSats} sats`) - } + this.toast.success(`Received ${amountSats} sats!`) } }