Remove replaced electrum transactions (#2738)

* fix: remove replaced btc transactions * fix: remove replaced btc transactions * remove debug print

malik1004x committed Dec 17, 2025 at 18:18 UTC d3ba9661422bd660a8a6911db4828ec57a63e917
1 file changed +11
cw_bitcoin/lib/electrum_wallet.dart
+11
@@ -2311,10 +2311,21 @@ abstract class ElectrumWalletBase
2311
2312 final history = await electrumClient.getHistory(addressRecord.getScriptHash(network));
2313
2314 +
2315 if (history.isNotEmpty) {
2316 addressRecord.setAsUsed();
2317 walletAddresses.clearLockIfMatches(addressRecord.type, addressRecord.address);
2318
2319 + if(this is BitcoinWallet) {
2320 + //removes transactions no longer returned by the api, presumed replaced/invalid.
2321 + transactionHistory.transactions.removeWhere(
2322 + (hash, tx) =>
2323 + tx.outputAddresses != null &&
2324 + tx.outputAddresses!.contains(addressRecord.address) &&
2325 + !history.any((newTransaction) => newTransaction['tx_hash'] == hash),
2326 + );
2327 + }
2328 +
2329 await Future.wait(history.map((transaction) async {
2330 txid = transaction['tx_hash'] as String;
2331 final height = transaction['height'] as int;