From 7fc4b724c4f930f5635806d75f057824073b3a12 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 17:36:59 -0600 Subject: [PATCH] add replace tx logic for potentially unconfirmed transactions to update properly --- lib/services/mixins/wallet_db.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/services/mixins/wallet_db.dart b/lib/services/mixins/wallet_db.dart index 00247f851..3668670f1 100644 --- a/lib/services/mixins/wallet_db.dart +++ b/lib/services/mixins/wallet_db.dart @@ -38,6 +38,13 @@ mixin WalletDB { for (final data in transactionsData) { final tx = data.item1; + final potentiallyUnconfirmedTx = + await isar.transactions.where().txidEqualTo(tx.txid).findFirst(); + if (potentiallyUnconfirmedTx != null) { + // update use id to replace tx + tx.id = potentiallyUnconfirmedTx.id; + await isar.transactions.delete(potentiallyUnconfirmedTx.id); + } // save transaction await isar.transactions.put(tx);