Status: constructing transaction

This commit is contained in:
tobtoht 2020-12-24 15:46:56 +01:00
parent 136f877778
commit 0dc196e76d
No known key found for this signature in database
GPG key ID: 1CADD27F41F45C3C
3 changed files with 47 additions and 12 deletions

View file

@ -758,9 +758,11 @@ void AppContext::onTransactionCreated(PendingTransaction *tx, const QString &add
if(address == this->donationAddress)
this->donationSending = true;
// Let UI know that the transaction was constructed
emit endTransaction();
// tx created, but not sent yet. ask user to verify first.
emit createTransactionSuccess(tx, address, mixin);
emit endTransaction();
}
void AppContext::onTransactionCommitted(bool status, PendingTransaction *tx, const QStringList& txid){

View file

@ -79,7 +79,7 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) :
connected ? m_statusBtnTor->setIcon(QIcon(":/assets/images/tor_logo.png"))
: m_statusBtnTor->setIcon(QIcon(":/assets/images/tor_logo_disabled.png"));});
connect(m_ctx->nodes, &Nodes::updateStatus, [=](const QString &msg){
m_statusLabelStatus->setText(msg);
this->setStatusText(msg);
});
// menu connects
@ -234,6 +234,22 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) :
connect(m_ctx, &AppContext::initiateTransaction, ui->xmrToWidget, &XMRToWidget::onInitiateTransaction);
connect(m_ctx, &AppContext::endTransaction, ui->xmrToWidget, &XMRToWidget::onEndTransaction);
connect(m_ctx, &AppContext::initiateTransaction, [this]{
m_statusDots = 0;
m_constructingTransaction = true;
m_txTimer.start(1000);
});
connect(m_ctx, &AppContext::endTransaction, [this]{
// Todo: endTransaction can fail to fire when the node is switched during tx creation
m_constructingTransaction = false;
m_txTimer.stop();
this->setStatusText(m_statusText);
});
connect(&m_txTimer, &QTimer::timeout, [this]{
m_statusLabelStatus->setText("Constructing transaction" + this->statusDots());
});
// testnet/stagenet warning
auto worthlessWarning = QString("Feather wallet is currently running in %1 mode. This is meant "
"for developers only. Your coins are WORTHLESS.");
@ -592,9 +608,9 @@ void MainWindow::onWalletOpened() {
this->activateWindow();
this->setEnabled(true);
if(!m_ctx->tor->torConnected)
m_statusLabelStatus->setText("Wallet opened - Starting Tor (may take a while)");
this->setStatusText("Wallet opened - Starting Tor (may take a while)");
else
m_statusLabelStatus->setText("Wallet opened - Searching for node");
this->setStatusText("Wallet opened - Searching for node");
connect(m_ctx->currentWallet, &Wallet::connectionStatusChanged, this, &MainWindow::onConnectionStatusChanged);
@ -655,22 +671,28 @@ void MainWindow::onBalanceUpdated(double balance, double unlocked, const QString
m_balanceWidget->setHidden(hide);
}
void MainWindow::setStatusText(const QString &text) {
m_statusText = text;
if (!m_constructingTransaction)
m_statusLabelStatus->setText(text);
}
void MainWindow::onSynchronized() {
this->updateNetStats();
m_statusLabelStatus->setText("Synchronized");
this->setStatusText("Synchronized");
this->onConnectionStatusChanged(Wallet::ConnectionStatus_Connected);
}
void MainWindow::onBlockchainSync(int height, int target) {
QString blocks = (target >= height) ? QString::number(target - height) : "?";
QString heightText = QString("Blockchain sync: %1 blocks remaining").arg(blocks);
m_statusLabelStatus->setText(heightText);
this->setStatusText(heightText);
}
void MainWindow::onRefreshSync(int height, int target) {
QString blocks = (target >= height) ? QString::number(target - height) : "?";
QString heightText = QString("Wallet refresh: %1 blocks remaining").arg(blocks);
m_statusLabelStatus->setText(heightText);
this->setStatusText(heightText);
}
void MainWindow::onConnectionStatusChanged(int status)
@ -684,7 +706,7 @@ void MainWindow::onConnectionStatusChanged(int status)
switch(status){
case Wallet::ConnectionStatus_Disconnected:
statusIcon = ":/assets/images/status_disconnected.svg";
m_statusLabelStatus->setText("Disconnected");
this->setStatusText("Disconnected");
break;
case Wallet::ConnectionStatus_Connected:
if (m_ctx->currentWallet->synchronized()) {
@ -695,11 +717,11 @@ void MainWindow::onConnectionStatusChanged(int status)
break;
case Wallet::ConnectionStatus_Connecting:
statusIcon = ":/assets/images/status_lagging.svg";
m_statusLabelStatus->setText("Connecting to daemon");
this->setStatusText("Connecting to daemon");
break;
case Wallet::ConnectionStatus_WrongVersion:
statusIcon = ":/assets/images/status_disconnected.svg";
m_statusLabelStatus->setText("Incompatible daemon");
this->setStatusText("Incompatible daemon");
break;
default:
statusIcon = ":/assets/images/status_disconnected.svg";
@ -1300,6 +1322,12 @@ void MainWindow::rescanSpent() {
}
}
QString MainWindow::statusDots() {
m_statusDots++;
m_statusDots = m_statusDots % 4;
return QString(".").repeated(m_statusDots);
}
MainWindow::~MainWindow() {
delete ui;
}

View file

@ -168,6 +168,8 @@ private:
void updatePasswordIcon();
void updateNetStats();
void rescanSpent();
void setStatusText(const QString &text);
QString statusDots();
WalletWizard *createWizard(WalletWizard::Page startPage);
@ -179,8 +181,6 @@ private:
AboutDialog *m_aboutDialog = nullptr;
XMRigWidget *m_xmrig = nullptr;
bool m_windowSpawned = false;
QSystemTrayIcon *m_trayIcon;
QMenu m_trayMenu;
QAction *m_trayActionCalc;
@ -218,6 +218,11 @@ private:
QTimer m_updateBytes;
QString m_statusText;
int m_statusDots;
bool m_constructingTransaction = false;
QTimer m_txTimer;
private slots:
void menuToggleTabVisible(const QString &key);
};