Skip to content

Commit

Permalink
fix lydra locked ui balance
Browse files Browse the repository at this point in the history
  • Loading branch information
RosenKrumov committed Oct 10, 2023
1 parent 3863d78 commit 4dd08b0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,15 @@ void OverviewPage::setBalance(const interfaces::WalletBalances& balances)
lydraLockedCache = getAllLydraLockedCache();
trials++;
}
auto allLydraLockedCache = std::get<0>(lydraLockedCache);
uint64_t allLydraLockedCache = std::get<0>(lydraLockedCache);
m_balances = balances;
auto balanceValue = 0;
if (allLydraLockedCache > balances.stake) balanceValue = balances.balance + balances.stake - allLydraLockedCache;
else balanceValue = balances.balance;
if (balanceValue < 0) balanceValue = 0;
uint64_t balanceValue = 0;
if (allLydraLockedCache > balances.stake){
balanceValue = balances.balance + balances.stake - allLydraLockedCache;
} else {
balanceValue = balances.balance;
}

ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balanceValue, false, BitcoinUnits::separatorAlways));
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithUnit(unit, balances.unconfirmed_balance, false, BitcoinUnits::separatorAlways));
ui->labelImmature->setText(BitcoinUnits::formatWithUnit(unit, balances.immature_balance, false, BitcoinUnits::separatorAlways));
Expand Down
19 changes: 18 additions & 1 deletion src/qt/titlebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <iostream>
#include <string>

#include <locktrip/lydra.h>

//namespace TitleBar_NS {
//const int titleHeight = 50;
//}
Expand Down Expand Up @@ -118,8 +120,23 @@ void TitleBar::removeWallet(WalletModel *_model)

void TitleBar::setBalanceLabel(const interfaces::WalletBalances &balances)
{
auto lydraLockedCache = getAllLydraLockedCache();
int trials = 0;
while (!std::get<1>(lydraLockedCache)){
if (trials>5000) break;
lydraLockedCache = getAllLydraLockedCache();
trials++;
}
uint64_t allLydraLockedCache = std::get<0>(lydraLockedCache);
uint64_t balanceValue = 0;
if (allLydraLockedCache > balances.stake){
balanceValue = balances.balance + balances.stake - allLydraLockedCache;
} else {
balanceValue = balances.balance;
}

if(m_model && m_model->getOptionsModel())
{
ui->lblBalance->setText(BitcoinUnits::formatWithUnitTitleBar(m_model->getOptionsModel()->getDisplayUnit(), balances.balance));
ui->lblBalance->setText(BitcoinUnits::formatWithUnitTitleBar(m_model->getOptionsModel()->getDisplayUnit(), balanceValue));
}
}

0 comments on commit 4dd08b0

Please sign in to comment.