From d3ba9661422bd660a8a6911db4828ec57a63e917 Mon Sep 17 00:00:00 2001 From: malik1004x Date: Wed, 17 Dec 2025 18:18:03 +0100 Subject: [PATCH] Remove replaced electrum transactions (#2738) * fix: remove replaced btc transactions * fix: remove replaced btc transactions * remove debug print --- cw_bitcoin/lib/electrum_wallet.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cw_bitcoin/lib/electrum_wallet.dart b/cw_bitcoin/lib/electrum_wallet.dart index a285ff979..298ccc5d0 100644 --- a/cw_bitcoin/lib/electrum_wallet.dart +++ b/cw_bitcoin/lib/electrum_wallet.dart @@ -2311,10 +2311,21 @@ abstract class ElectrumWalletBase final history = await electrumClient.getHistory(addressRecord.getScriptHash(network)); + if (history.isNotEmpty) { addressRecord.setAsUsed(); walletAddresses.clearLockIfMatches(addressRecord.type, addressRecord.address); + if(this is BitcoinWallet) { + //removes transactions no longer returned by the api, presumed replaced/invalid. + transactionHistory.transactions.removeWhere( + (hash, tx) => + tx.outputAddresses != null && + tx.outputAddresses!.contains(addressRecord.address) && + !history.any((newTransaction) => newTransaction['tx_hash'] == hash), + ); + } + await Future.wait(history.map((transaction) async { txid = transaction['tx_hash'] as String; final height = transaction['height'] as int;