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

View file

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