diff --git a/package.json b/package.json index 7356b81b5..e88830bce 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@synonymdev/web-relay": "1.0.7", "backpack-client": "github:synonymdev/bitkit-backup-client#f08fdb28529d8a3f8bfecc789443c43b966a7581", "bech32": "2.0.0", - "beignet": "0.0.26", + "beignet": "0.0.27", "bip21": "2.0.3", "bip32": "4.0.0", "bip39": "3.1.0", diff --git a/src/utils/wallet/index.ts b/src/utils/wallet/index.ts index e66c98c0e..4cfaaa26a 100644 --- a/src/utils/wallet/index.ts +++ b/src/utils/wallet/index.ts @@ -937,6 +937,8 @@ const onElectrumConnectionChange = (isConnected: boolean): void => { } }; +// Used to prevent duplicate notifications for the same txid that seems to occur when Bitkit is brought from background to foreground. +let receivedTxids: string[] = []; const onMessage: TOnMessage = (key, data) => { switch (key) { case 'transactionReceived': @@ -953,11 +955,13 @@ const onMessage: TOnMessage = (key, data) => { }); const isTransferToSavings = transfer?.type === 'coop-close' ?? false; - if (!isTransferToSavings) { + const isDuplicate = receivedTxids.includes(txId); + if (!isTransferToSavings && !isDuplicate) { showNewOnchainTxPrompt({ id: txId, value: btcToSats(txMsg.transaction.value), }); + receivedTxids.push(txId); } } setTimeout(() => { @@ -996,7 +1000,9 @@ const onMessage: TOnMessage = (key, data) => { }); break; case 'newBlock': - refreshWallet({}).then(); + refreshWallet({ + onchain: false, // Beignet will handle this. + }).then(); } }; diff --git a/yarn.lock b/yarn.lock index 60fac7413..d4e6bfdbc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5712,10 +5712,10 @@ bech32@^1.1.2, bech32@^1.1.4: resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ== -beignet@0.0.26: - version "0.0.26" - resolved "https://registry.yarnpkg.com/beignet/-/beignet-0.0.26.tgz#f1138e9c97ec67b4748b272996b6aee02eea3e64" - integrity sha512-OvouVDlQfrP69EkwJThwTyRKtj7wVcrMBaKIkNiy4+IcMTghPKk+DoC+oe73cnO10Utw98xG6ulWtOFT+o96nw== +beignet@0.0.27: + version "0.0.27" + resolved "https://registry.yarnpkg.com/beignet/-/beignet-0.0.27.tgz#a6ddb3d238b37a2ae074aecdad036a89b771de38" + integrity sha512-gwZgWV93Y6x8bj3PXeDTeHrBCiWk3nHRa2Jn4SnUsa5RqIMbg2e6WW8NBmZXPD6ER+hokiQL23GKU2TrVl6HbA== dependencies: "@bitcoinerlab/secp256k1" "1.0.5" bech32 "2.0.0"