add replace tx logic for potentially unconfirmed transactions to update properly

This commit is contained in:
julian 2023-01-13 17:36:59 -06:00
parent c503e8f8d8
commit 7fc4b724c4

View file

@ -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);