fix Electrum transaction updates (#953)

This commit is contained in:
Serhii 2023-06-14 23:53:58 +03:00 committed by GitHub
parent a7ba4a84e8
commit f88e150cd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -35,7 +35,7 @@ abstract class ElectrumTransactionHistoryBase
@override
void addMany(Map<String, ElectrumTransactionInfo> transactions) =>
transactions.forEach((_, tx) => _updateOrInsert(tx));
transactions.forEach((_, tx) => _update(tx));
@override
Future<void> save() async {
@ -74,7 +74,7 @@ abstract class ElectrumTransactionHistoryBase
if (val is Map<String, dynamic>) {
final tx = ElectrumTransactionInfo.fromJson(val, walletInfo.type);
_updateOrInsert(tx);
_update(tx);
}
});
@ -84,18 +84,6 @@ abstract class ElectrumTransactionHistoryBase
}
}
void _updateOrInsert(ElectrumTransactionInfo transaction) {
if (transactions[transaction.id] == null) {
void _update(ElectrumTransactionInfo transaction) =>
transactions[transaction.id] = transaction;
} else {
final originalTx = transactions[transaction.id];
originalTx?.confirmations = transaction.confirmations;
originalTx?.amount = transaction.amount;
originalTx?.height = transaction.height;
originalTx?.date ??= transaction.date;
originalTx?.isPending = transaction.isPending;
originalTx?.direction = transaction.direction;
}
}
}