fix non-mweb confirmations

This commit is contained in:
fossephate 2024-10-31 11:05:43 -07:00
parent f61f590988
commit 0cc9018e34
2 changed files with 20 additions and 7 deletions

View file

@ -1976,18 +1976,28 @@ abstract class ElectrumWalletBase
if (_isTransactionUpdating) {
return;
}
await getCurrentChainTip();
_currentChainTip = await getUpdatedChainTip();
bool updated = false;
transactionHistory.transactions.values.forEach((tx) {
if (tx.unspents != null &&
tx.unspents!.isNotEmpty &&
tx.height != null &&
tx.height! > 0 &&
(_currentChainTip ?? 0) > 0) {
tx.confirmations = _currentChainTip! - tx.height! + 1;
if ((tx.height ?? 0) > 0 && (_currentChainTip ?? 0) > 0) {
var confirmations = _currentChainTip! - tx.height! + 1;
if (confirmations < 0) {
// if our chain tip is outdated then it could lead to negative confirmations so this is just a failsafe:
confirmations = 0;
}
if (confirmations != tx.confirmations) {
updated = true;
tx.confirmations = confirmations;
transactionHistory.addOne(tx);
}
}
});
if (updated) {
await transactionHistory.save();
}
_isTransactionUpdating = true;
await fetchTransactions();
walletAddresses.updateReceiveAddresses();

View file

@ -73,6 +73,9 @@ class TransactionListItem extends ActionListItem with Keyable {
bool isPegOut = (transaction.additionalInfo["isPegOut"] as bool?) ?? false;
bool isPegInOut = isPegIn || isPegOut;
String str = '';
if (transaction.confirmations <= 0) {
str = S.current.pending;
}
if (isPegInOut && transaction.confirmations >= 0 && transaction.confirmations < 6) {
str = " (${transaction.confirmations}/6)";
}