]> Nutra Git (v1) - gamesguru/feather.git/commitdiff
Tools: add address checker
authortobtoht <thotbot@protonmail.com>
Tue, 6 Jul 2021 14:10:24 +0000 (16:10 +0200)
committertobtoht <thotbot@protonmail.com>
Tue, 6 Jul 2021 14:10:24 +0000 (16:10 +0200)
src/MainWindow.cpp
src/MainWindow.h
src/MainWindow.ui

index c552aa722f8fe8003c64a8966974ae205f458010..dd08be1fe5c546a65c562a65b9c7bb58283d432a 100644 (file)
@@ -5,6 +5,7 @@
 #include "ui_MainWindow.h"
 
 #include <QFileDialog>
+#include <QInputDialog>
 #include <QMessageBox>
 
 #include "config-feather.h"
@@ -305,6 +306,7 @@ void MainWindow::initMenu() {
     connect(ui->actionLoadSignedTxFromText,        &QAction::triggered, this, &MainWindow::loadSignedTxFromText);
     connect(ui->actionImport_transaction,          &QAction::triggered, this, &MainWindow::importTransaction);
     connect(ui->actionPay_to_many,                 &QAction::triggered, this, &MainWindow::payToMany);
+    connect(ui->actionAddress_checker,             &QAction::triggered, this, &MainWindow::showAddressChecker);
     connect(ui->actionCalculator,                  &QAction::triggered, this, &MainWindow::showCalcWindow);
     connect(ui->actionCreateDesktopEntry,          &QAction::triggered, this, &MainWindow::onCreateDesktopEntry);
 
@@ -967,6 +969,27 @@ void MainWindow::showAccountSwitcherDialog() {
     dialog.exec();
 }
 
+void MainWindow::showAddressChecker() {
+    QString address = QInputDialog::getText(this, "Address Checker", "Address:                                      ");
+    if (address.isEmpty()) {
+        return;
+    }
+
+    if (!WalletManager::addressValid(address, constants::networkType)) {
+        QMessageBox::warning(this, "Address Checker", "Invalid address.");
+        return;
+    }
+
+    SubaddressIndex index = m_ctx->wallet->subaddressIndex(address);
+    if (!index.isValid()) {
+        // TODO: probably mention lookahead here
+        QMessageBox::warning(this, "Address Checker", "This address does not belong to this wallet.");
+        return;
+    } else {
+        QMessageBox::information(this, "Address Checker", QString("This address belongs to Account #%1").arg(index.major));
+    }
+}
+
 void MainWindow::showNodeExhaustedMessage() {
     // Spawning dialogs inside a lambda can cause system freezes on linux so we have to do it this way ¯\_(ツ)_/¯
 
index 212b62df0b546029411d117432adb92f46195443..41272f892f861aca3aa4a2b45e896dc2fb17da0b 100644 (file)
@@ -155,6 +155,7 @@ private slots:
     void showViewOnlyDialog();
     void showWalletCacheDebugDialog();
     void showAccountSwitcherDialog();
+    void showAddressChecker();
 
     void donateButtonClicked();
     void showCalcWindow();
index 4386c2e4123cbc2896ece138ab1b0521604d0626..6b8868137d80510d0d7a428df285f152a9ce0092 100644 (file)
      <x>0</x>
      <y>0</y>
      <width>977</width>
-     <height>28</height>
+     <height>27</height>
     </rect>
    </property>
    <widget class="QMenu" name="menuFile">
     <addaction name="actionImport_transaction"/>
     <addaction name="separator"/>
     <addaction name="actionPay_to_many"/>
+    <addaction name="actionAddress_checker"/>
     <addaction name="actionCalculator"/>
     <addaction name="actionCreateDesktopEntry"/>
    </widget>
     <string>Show Searchbar</string>
    </property>
   </action>
+  <action name="actionAddress_checker">
+   <property name="text">
+    <string>Address checker</string>
+   </property>
+  </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <customwidgets>