]> Nutra Git (v1) - gamesguru/feather.git/commitdiff
send: disable send button during tx broadcast
authortobtoht <tob@featherwallet.org>
Fri, 15 Dec 2023 13:10:55 +0000 (14:10 +0100)
committertobtoht <tob@featherwallet.org>
Fri, 15 Dec 2023 13:13:14 +0000 (14:13 +0100)
src/MainWindow.cpp
src/SendWidget.cpp
src/SendWidget.h
src/libwalletqt/Wallet.cpp
src/libwalletqt/Wallet.h

index f5417ac8872bcb25a2c005a0b8a87281f31e0107..b416a7c8207674915cc92df0ca66d40f24b0a87f 100644 (file)
@@ -1577,7 +1577,7 @@ void MainWindow::onKeysCorrupted() {
     if (!m_criticalWarningShown) {
         m_criticalWarningShown = true;
         Utils::showError(this, "Wallet keys are corrupted", "WARNING!\n\nTo prevent LOSS OF FUNDS do NOT continue to use this wallet file.\n\nRestore your wallet from seed.\n\nPlease report this incident to the Feather developers.\n\nWARNING!");
-        m_sendWidget->disableSendButton();
+        m_sendWidget->disallowSending();
     }
 }
 
index 03ac74cfa5c9bdf9cf8cb152d7021a341176f65c..108bb3f85dda862c31438bb940734c0f6167b36c 100644 (file)
@@ -32,8 +32,10 @@ SendWidget::SendWidget(Wallet *wallet, QWidget *parent)
     QValidator *validator = new QRegularExpressionValidator(rx, this);
     ui->lineAmount->setValidator(validator);
 
-    connect(m_wallet, &Wallet::initiateTransaction, this, &SendWidget::onInitiateTransaction);
-    connect(m_wallet, &Wallet::transactionCreated, this, &SendWidget::onEndTransaction);
+    connect(m_wallet, &Wallet::initiateTransaction, this, &SendWidget::disableSendButton);
+    connect(m_wallet, &Wallet::transactionCreated, this, &SendWidget::enableSendButton);
+    connect(m_wallet, &Wallet::beginCommitTransaction, this, &SendWidget::disableSendButton);
+    connect(m_wallet, &Wallet::transactionCommitted, this, &SendWidget::enableSendButton);
 
     connect(WalletManager::instance(), &WalletManager::openAliasResolved, this, &SendWidget::onOpenAliasResolved);
 
@@ -349,18 +351,19 @@ void SendWidget::payToMany() {
     ui->lineAddress->payToMany();
 }
 
-void SendWidget::onInitiateTransaction() {
+void SendWidget::disableSendButton() {
     ui->btnSend->setEnabled(false);
 }
 
-void SendWidget::onEndTransaction() {
-    if (!m_sendDisabled) {
-        ui->btnSend->setEnabled(true);
+void SendWidget::enableSendButton() {
+    if (m_disallowSending) {
+        return;
     }
+    ui->btnSend->setEnabled(true);
 }
 
-void SendWidget::disableSendButton() {
-    m_sendDisabled = true;
+void SendWidget::disallowSending() {
+    m_disallowSending = true;
     ui->btnSend->setEnabled(false);
 }
 
index f379b4673d7478e5b89571eb809828ab10d21497..9b74cbb5e41663d64c0c36133fe975c56a421672 100644 (file)
@@ -38,11 +38,12 @@ public slots:
     void updateConversionLabel();
     void onOpenAliasResolved(const QString &openAlias, const QString &address, bool dnssecValid);
     void onPreferredFiatCurrencyChanged();
-    void disableSendButton();
     void setWebsocketEnabled(bool enabled);
 
-    void onInitiateTransaction();
-    void onEndTransaction();
+    void disableSendButton();
+    void enableSendButton();
+
+    void disallowSending();
 
 private slots:
     void onDataPasted(const QString &data);
@@ -57,7 +58,7 @@ private:
 
     QScopedPointer<Ui::SendWidget> ui;
     Wallet *m_wallet;
-    bool m_sendDisabled = false;
+    bool m_disallowSending = false;
 };
 
 #endif // FEATHER_SENDWIDGET_H
index 774fdedf8e48b6961dfb46117fc213ef9aa9b16c..77c39ed233e868e2201c2ca67b02c35fe69e8638 100644 (file)
@@ -834,6 +834,8 @@ void Wallet::onTransactionCreated(Monero::PendingTransaction *mtx, const QVector
 // Phase 3: Commit or dispose
 
 void Wallet::commitTransaction(PendingTransaction *tx, const QString &description) {
+    emit beginCommitTransaction();
+
     // Clear list of selected transfers
     this->setSelectedInputs({});
 
index f906981e5b5c16ce0e51e940fd9a17a788416fc6..5321b916ed3297fcf275804b677b6e1dffabd2c7 100644 (file)
@@ -431,6 +431,7 @@ signals:
     void deviceButtonPressed();
     void deviceError(const QString &message);
     void walletPassphraseNeeded(bool onDevice);
+    void beginCommitTransaction();
     void transactionCommitted(bool status, PendingTransaction *t, const QStringList& txid, const QMap<QString, QString> &txHexMap);
     void deviceShowAddressShowed();
     void transactionProofVerified(TxProofResult result);