Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Unclickable 'Click here' in Migration Banner #1456

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "transactiontablemodel.h"
#include "walletmodel.h"
#include "validation.h"
#include "askpassphrasedialog.h"


#ifdef WIN32
#include <string.h>
Expand Down Expand Up @@ -380,14 +382,18 @@ void OverviewPage::onRefreshClicked()
{
auto privateBalance = walletModel->getLelantusModel()->getPrivateBalance();
auto lGracefulPeriod = ::Params().GetConsensus().nLelantusGracefulPeriod;
int heightDifference = lGracefulPeriod - chainActive.Height();
const int approxBlocksPerDay = 570;
int daysUntilMigrationCloses = heightDifference / approxBlocksPerDay;

if(privateBalance.first > 0 && chainActive.Height() < lGracefulPeriod && spark::IsSparkAllowed()) {
ui->warningFrame->show();
lelantusGracefulPeriod = QString::fromStdString(std::to_string(lGracefulPeriod));
currentBlock = QString::fromStdString(std::to_string(chainActive.Height()));
migrationWindowClosesIn = QString::fromStdString(std::to_string(daysUntilMigrationCloses));
blocksRemaining = QString::fromStdString(std::to_string(heightDifference));
migrateAmount = "<b>" + BitcoinUnits::formatHtmlWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), privateBalance.first);
migrateAmount.append("</b>");
ui->textWarning1->setText(tr("Firo is migrating to Spark. Redemption of coins in Lelantus will be disabled at block %1. <i>Current block is %2</i>.").arg(lelantusGracefulPeriod, currentBlock));
ui->textWarning2->setText(tr("to migrate %1 from Lelantus.").arg(migrateAmount));
ui->textWarning1->setText(tr("We have detected Lelantus coins that have not been migrated to Spark. Migration window will close in %1 blocks (~ %2 days).").arg(blocksRemaining , migrationWindowClosesIn));
ui->textWarning2->setText(tr("to migrate %1 ").arg(migrateAmount));
QFont qFont = ui->migrateButton->font();
qFont.setUnderline(true);
ui->migrateButton->setFont(qFont);
Expand All @@ -398,11 +404,27 @@ void OverviewPage::onRefreshClicked()

void OverviewPage::migrateClicked()
{
if(walletModel->getAvailableLelantusCoins() && spark::IsSparkAllowed() && chainActive.Height() < ::Params().GetConsensus().nLelantusGracefulPeriod){
MigrateLelantusToSparkDialog migrate(walletModel);
auto privateBalance = walletModel->getLelantusModel()->getPrivateBalance();
auto lGracefulPeriod = ::Params().GetConsensus().nLelantusGracefulPeriod;
migrateAmount = "<b>" + BitcoinUnits::formatHtmlWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), privateBalance.first);
migrateAmount.append("</b>");
QString info = tr("Your wallet needs to be unlocked to migrate your funds to Spark.");

if(walletModel->getEncryptionStatus() == WalletModel::Locked) {

AskPassphraseDialog dlg(AskPassphraseDialog::Unlock, this, info);
dlg.setModel(walletModel);
dlg.exec();
}
if (walletModel->getEncryptionStatus() == WalletModel::Unlocked){
if(walletModel->getAvailableLelantusCoins() && spark::IsSparkAllowed() && chainActive.Height() < ::Params().GetConsensus().nLelantusGracefulPeriod){
MigrateLelantusToSparkDialog migrate(walletModel);
if(!migrate.getClickedButton()){
ui->warningFrame->hide();
}
}
levonpetrosyan93 marked this conversation as resolved.
Show resolved Hide resolved
}
}

MigrateLelantusToSparkDialog::MigrateLelantusToSparkDialog(WalletModel *_model):QMessageBox()
{
this->model = _model;
Expand Down
4 changes: 2 additions & 2 deletions src/qt/overviewpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public Q_SLOTS:

QTimer countDownTimer;
int secDelay;
QString lelantusGracefulPeriod;
QString currentBlock;
QString migrationWindowClosesIn;
QString blocksRemaining;
QString migrateAmount;

private Q_SLOTS:
Expand Down
Loading