Skip to content

Commit 4dd08b0

Browse files
committed
fix lydra locked ui balance
1 parent 3863d78 commit 4dd08b0

2 files changed

Lines changed: 26 additions & 6 deletions

File tree

src/qt/overviewpage.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,15 @@ void OverviewPage::setBalance(const interfaces::WalletBalances& balances)
298298
lydraLockedCache = getAllLydraLockedCache();
299299
trials++;
300300
}
301-
auto allLydraLockedCache = std::get<0>(lydraLockedCache);
301+
uint64_t allLydraLockedCache = std::get<0>(lydraLockedCache);
302302
m_balances = balances;
303-
auto balanceValue = 0;
304-
if (allLydraLockedCache > balances.stake) balanceValue = balances.balance + balances.stake - allLydraLockedCache;
305-
else balanceValue = balances.balance;
306-
if (balanceValue < 0) balanceValue = 0;
303+
uint64_t balanceValue = 0;
304+
if (allLydraLockedCache > balances.stake){
305+
balanceValue = balances.balance + balances.stake - allLydraLockedCache;
306+
} else {
307+
balanceValue = balances.balance;
308+
}
309+
307310
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balanceValue, false, BitcoinUnits::separatorAlways));
308311
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithUnit(unit, balances.unconfirmed_balance, false, BitcoinUnits::separatorAlways));
309312
ui->labelImmature->setText(BitcoinUnits::formatWithUnit(unit, balances.immature_balance, false, BitcoinUnits::separatorAlways));

src/qt/titlebar.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <iostream>
1111
#include <string>
1212

13+
#include <locktrip/lydra.h>
14+
1315
//namespace TitleBar_NS {
1416
//const int titleHeight = 50;
1517
//}
@@ -118,8 +120,23 @@ void TitleBar::removeWallet(WalletModel *_model)
118120

119121
void TitleBar::setBalanceLabel(const interfaces::WalletBalances &balances)
120122
{
123+
auto lydraLockedCache = getAllLydraLockedCache();
124+
int trials = 0;
125+
while (!std::get<1>(lydraLockedCache)){
126+
if (trials>5000) break;
127+
lydraLockedCache = getAllLydraLockedCache();
128+
trials++;
129+
}
130+
uint64_t allLydraLockedCache = std::get<0>(lydraLockedCache);
131+
uint64_t balanceValue = 0;
132+
if (allLydraLockedCache > balances.stake){
133+
balanceValue = balances.balance + balances.stake - allLydraLockedCache;
134+
} else {
135+
balanceValue = balances.balance;
136+
}
137+
121138
if(m_model && m_model->getOptionsModel())
122139
{
123-
ui->lblBalance->setText(BitcoinUnits::formatWithUnitTitleBar(m_model->getOptionsModel()->getDisplayUnit(), balances.balance));
140+
ui->lblBalance->setText(BitcoinUnits::formatWithUnitTitleBar(m_model->getOptionsModel()->getDisplayUnit(), balanceValue));
124141
}
125142
}

0 commit comments

Comments
 (0)