]> Nutra Git (v2) - gamesguru/feather.git/commitdiff
wizard: allow setting subaddress lookahead
authortobtoht <tob@featherwallet.org>
Tue, 24 Jan 2023 21:35:47 +0000 (22:35 +0100)
committertobtoht <tob@featherwallet.org>
Tue, 24 Jan 2023 21:48:09 +0000 (22:48 +0100)
28 files changed:
monero
src/WindowManager.cpp
src/WindowManager.h
src/dialog/WalletInfoDialog.cpp
src/dialog/WalletInfoDialog.ui
src/libwalletqt/Wallet.cpp
src/libwalletqt/Wallet.h
src/libwalletqt/WalletManager.cpp
src/libwalletqt/WalletManager.h
src/wizard/PageHardwareDevice.cpp
src/wizard/PageHardwareDevice.h
src/wizard/PageHardwareDevice.ui
src/wizard/PageMenu.cpp
src/wizard/PageSetRestoreHeight.cpp
src/wizard/PageSetSeedPassphrase.cpp
src/wizard/PageSetSubaddressLookahead.cpp [new file with mode: 0644]
src/wizard/PageSetSubaddressLookahead.h [copied from src/wizard/PageHardwareDevice.h with 50% similarity]
src/wizard/PageSetSubaddressLookahead.ui [new file with mode: 0644]
src/wizard/PageWalletRestoreKeys.cpp
src/wizard/PageWalletRestoreKeys.h
src/wizard/PageWalletRestoreKeys.ui
src/wizard/PageWalletRestoreSeed.cpp
src/wizard/PageWalletRestoreSeed.h
src/wizard/PageWalletRestoreSeed.ui
src/wizard/PageWalletSeed.cpp
src/wizard/PageWalletSeed.ui
src/wizard/WalletWizard.cpp
src/wizard/WalletWizard.h

diff --git a/monero b/monero
index 7f9d4b9b21d776551dd3809bfc4f9e11d7c7b933..18bdad879d9f25f35f065354aedf1236e6b0a60b 160000 (submodule)
--- a/monero
+++ b/monero
@@ -1 +1 @@
-Subproject commit 7f9d4b9b21d776551dd3809bfc4f9e11d7c7b933
+Subproject commit 18bdad879d9f25f35f065354aedf1236e6b0a60b
index 1a088a90b959e1065582a27f125b48737edcc3ab..ec0fda7180164e71f6568a0ba0f8e4ce2537b433 100644 (file)
@@ -251,7 +251,7 @@ bool WindowManager::autoOpenWallet() {
 // ######################## WALLET CREATION ########################
 
 void WindowManager::tryCreateWallet(Seed seed, const QString &path, const QString &password, const QString &seedLanguage,
-                                    const QString &seedOffset) {
+                                    const QString &seedOffset, const QString &subaddressLookahead) {
     if(Utils::fileExists(path)) {
         auto err = QString("Failed to write wallet to path: \"%1\"; file already exists.").arg(path);
         this->handleWalletError(err);
@@ -265,7 +265,7 @@ void WindowManager::tryCreateWallet(Seed seed, const QString &path, const QStrin
 
     Wallet *wallet = nullptr;
     if (seed.type == Seed::Type::POLYSEED || seed.type == Seed::Type::TEVADOR) {
-        wallet = m_walletManager->createDeterministicWalletFromSpendKey(path, password, seed.language, constants::networkType, seed.spendKey, seed.restoreHeight, constants::kdfRounds, seedOffset);
+        wallet = m_walletManager->createDeterministicWalletFromSpendKey(path, password, seed.language, constants::networkType, seed.spendKey, seed.restoreHeight, constants::kdfRounds, seedOffset, subaddressLookahead);
     }
     else if (seed.type == Seed::Type::MONERO) {
         wallet = m_walletManager->recoveryWallet(path, password, seed.mnemonic.join(" "), seedOffset, constants::networkType, seed.restoreHeight, constants::kdfRounds);
@@ -282,7 +282,7 @@ void WindowManager::tryCreateWallet(Seed seed, const QString &path, const QStrin
     this->onWalletOpened(wallet);
 }
 
-void WindowManager::tryCreateWalletFromDevice(const QString &path, const QString &password, const QString &deviceName, int restoreHeight)
+void WindowManager::tryCreateWalletFromDevice(const QString &path, const QString &password, const QString &deviceName, int restoreHeight, const QString &subaddressLookahead)
 {
     if (Utils::fileExists(path)) {
         auto err = QString("Failed to write wallet to path: \"%1\"; file already exists.").arg(path);
@@ -291,11 +291,11 @@ void WindowManager::tryCreateWalletFromDevice(const QString &path, const QString
     }
 
     m_openingWallet = true;
-    m_walletManager->createWalletFromDeviceAsync(path, password, constants::networkType, deviceName, restoreHeight);
+    m_walletManager->createWalletFromDeviceAsync(path, password, constants::networkType, deviceName, restoreHeight, subaddressLookahead);
 }
 
 void WindowManager::tryCreateWalletFromKeys(const QString &path, const QString &password, const QString &address,
-                                            const QString &viewkey, const QString &spendkey, quint64 restoreHeight) {
+                                            const QString &viewkey, const QString &spendkey, quint64 restoreHeight, const QString &subaddressLookahead) {
     if (Utils::fileExists(path)) {
         auto err = QString("Failed to write wallet to path: \"%1\"; file already exists.").arg(path);
         this->handleWalletError(err);
@@ -320,7 +320,7 @@ void WindowManager::tryCreateWalletFromKeys(const QString &path, const QString &
         return;
     }
 
-    Wallet *wallet = m_walletManager->createWalletFromKeys(path, password, constants::seedLanguage, constants::networkType, address, viewkey, spendkey, restoreHeight);
+    Wallet *wallet = m_walletManager->createWalletFromKeys(path, password, constants::seedLanguage, constants::networkType, address, viewkey, spendkey, restoreHeight, constants::kdfRounds, subaddressLookahead);
     m_openingWallet = true;
     m_walletManager->walletOpened(wallet);
 }
index c73997e552c9255e5ac6ed31d4ec0dae95cbe782..6df35db3c71f6f4ffa3bdb3579925e2f2db63ab7 100644 (file)
@@ -50,9 +50,9 @@ private slots:
     void onWalletPassphraseNeeded(bool on_device);
 
 private:
-    void tryCreateWallet(Seed seed, const QString &path, const QString &password, const QString &seedLanguage, const QString &seedOffset);
-    void tryCreateWalletFromDevice(const QString &path, const QString &password, const QString &deviceName, int restoreHeight);
-    void tryCreateWalletFromKeys(const QString &path, const QString &password, const QString &address, const QString &viewkey, const QString &spendkey, quint64 restoreHeight);
+    void tryCreateWallet(Seed seed, const QString &path, const QString &password, const QString &seedLanguage, const QString &seedOffset, const QString &subaddressLookahead);
+    void tryCreateWalletFromDevice(const QString &path, const QString &password, const QString &deviceName, int restoreHeight, const QString &subaddressLookahead);
+    void tryCreateWalletFromKeys(const QString &path, const QString &password, const QString &address, const QString &viewkey, const QString &spendkey, quint64 restoreHeight, const QString &subaddressLookahead);
 
     bool autoOpenWallet();
 
index 1f7339d415bea5a1d0c6ba1fd872e2c71979497b..f494f2aa573423e8c623b83fc1ce234f87f19be6 100644 (file)
@@ -19,6 +19,7 @@ WalletInfoDialog::WalletInfoDialog(QSharedPointer<AppContext> ctx, QWidget *pare
     ui->label_netType->setText(Utils::QtEnumToString(m_ctx->wallet->nettype()));
     ui->label_seedType->setText(QString("%1 word").arg(m_ctx->wallet->seedLength()));
     ui->label_viewOnly->setText(m_ctx->wallet->viewOnly() ? "True" : "False");
+    ui->label_subaddressLookahead->setText(m_ctx->wallet->getSubaddressLookahead());
     ui->label_keysFile->setText(m_ctx->wallet->keysPath());
     ui->label_cacheFile->setText(m_ctx->wallet->cachePath());
     ui->label_cacheSize->setText(QString("%1 MB").arg(QString::number(cache.size() / 1e6, 'f', 2)));
index aff675d322c829c44723dba1dd3730ddc2553b36..4d18a89aa9588737341b35485eccc0000925b133 100644 (file)
        </property>
       </widget>
      </item>
-     <item row="4" column="0">
+     <item row="5" column="0">
       <widget class="HelpLabel" name="label_keysFileLabel">
        <property name="text">
         <string>Keys file:</string>
        </property>
       </widget>
      </item>
-     <item row="4" column="1">
+     <item row="5" column="1">
       <widget class="QLabel" name="label_keysFile">
        <property name="text">
         <string>TextLabel</string>
        </property>
       </widget>
      </item>
-     <item row="6" column="0">
+     <item row="7" column="0">
       <widget class="QLabel" name="label_6">
        <property name="text">
         <string>Cache size:</string>
        </property>
       </widget>
      </item>
-     <item row="6" column="1">
+     <item row="7" column="1">
       <widget class="QLabel" name="label_cacheSize">
        <property name="text">
         <string>TextLabel</string>
        </property>
       </widget>
      </item>
-     <item row="5" column="0">
+     <item row="6" column="0">
       <widget class="HelpLabel" name="label_cacheFileLabel">
        <property name="text">
         <string>Cache file:</string>
        </property>
       </widget>
      </item>
-     <item row="5" column="1">
+     <item row="6" column="1">
       <widget class="QLabel" name="label_cacheFile">
        <property name="text">
         <string>TextLabel</string>
        </property>
       </widget>
      </item>
+     <item row="4" column="0">
+      <widget class="QLabel" name="label_5">
+       <property name="text">
+        <string>Lookahead:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="4" column="1">
+      <widget class="QLabel" name="label_subaddressLookahead">
+       <property name="text">
+        <string>TextLabel</string>
+       </property>
+      </widget>
+     </item>
     </layout>
    </item>
    <item>
index 935d0451de35c7225b9b78da45640d160e86a69e..6ecccdfb940631ca6800130bbd0d4e501c1ba867 100644 (file)
@@ -411,6 +411,13 @@ void Wallet::deviceShowAddressAsync(quint32 accountIndex, quint32 addressIndex,
     });
 }
 
+QString Wallet::getSubaddressLookahead() const
+{
+    auto lookahead = m_walletImpl->getSubaddressLookahead();
+
+    return QString("%1:%2").arg(QString::number(lookahead.first), QString::number(lookahead.second));
+}
+
 bool Wallet::refreshHeights()
 {
     // daemonHeight and targetHeight will be 0 if call to get_info fails
index d4c94c7de11a260cf85912a0b09ff0331760a46c..e30b4e65b324290c28cbbcd2a11fa6f1dc9564c1 100644 (file)
@@ -213,6 +213,7 @@ public:
     QString getSubaddressLabel(quint32 accountIndex, quint32 addressIndex) const;
     void setSubaddressLabel(quint32 accountIndex, quint32 addressIndex, const QString &label);
     void deviceShowAddressAsync(quint32 accountIndex, quint32 addressIndex, const QString &paymentId);
+    QString getSubaddressLookahead() const;
 
     //! hw-device backed wallets
     bool isHwBacked() const;
index 7785dbe51caf73b97b28040ac718ea55d1eb83cf..211f27a6f3577bfd978d5b2e2365d99aa2e5f7bc 100644 (file)
@@ -110,7 +110,7 @@ void WalletManager::openWalletAsync(const QString &path, const QString &password
 }
 
 
-Wallet *WalletManager::recoveryWallet(const QString &path, const QString &password, const QString &seed, const QString &seed_offset, NetworkType::Type nettype, quint64 restoreHeight, quint64 kdfRounds)
+Wallet *WalletManager::recoveryWallet(const QString &path, const QString &password, const QString &seed, const QString &seed_offset, NetworkType::Type nettype, quint64 restoreHeight, quint64 kdfRounds, const QString &subaddressLookahead)
 {
     QMutexLocker locker(&m_mutex);
 
@@ -120,20 +120,21 @@ Wallet *WalletManager::recoveryWallet(const QString &path, const QString &passwo
 
 Wallet *WalletManager::createWalletFromKeys(const QString &path, const QString &password, const QString &language,
                                             NetworkType::Type nettype, const QString &address, const QString &viewkey,
-                                            const QString &spendkey, quint64 restoreHeight, quint64 kdfRounds)
+                                            const QString &spendkey, quint64 restoreHeight, quint64 kdfRounds, const QString &subaddressLookahead)
 {
     QMutexLocker locker(&m_mutex);
     Monero::Wallet * w = m_pimpl->createWalletFromKeys(path.toStdString(), password.toStdString(), language.toStdString(), static_cast<Monero::NetworkType>(nettype), restoreHeight,
-                                                       address.toStdString(), viewkey.toStdString(), spendkey.toStdString(), kdfRounds);
+                                                       address.toStdString(), viewkey.toStdString(), spendkey.toStdString(), kdfRounds, subaddressLookahead.toStdString());
     return new Wallet(w);
 }
 
 Wallet *WalletManager::createDeterministicWalletFromSpendKey(const QString &path, const QString &password, const QString &language, NetworkType::Type nettype,
-                                                             const QString &spendkey, quint64 restoreHeight, quint64 kdfRounds, const QString &offset_passphrase)
+                                                             const QString &spendkey, quint64 restoreHeight, quint64 kdfRounds, const QString &offset_passphrase,
+                                                             const QString &subaddressLookahead)
 {
     QMutexLocker locker(&m_mutex);
     Monero::Wallet * w = m_pimpl->createDeterministicWalletFromSpendKey(path.toStdString(), password.toStdString(), language.toStdString(), static_cast<Monero::NetworkType>(nettype), restoreHeight,
-                                                                        spendkey.toStdString(), kdfRounds, offset_passphrase.toStdString());
+                                                                        spendkey.toStdString(), kdfRounds, offset_passphrase.toStdString(), subaddressLookahead.toStdString());
     return new Wallet(w);
 }
 
index 8b5fd07e03995654f9b2f16ef3af6f48ff66e2b4..ea8216aeb95c2e09e113a02a653a910a1b2fd12f 100644 (file)
@@ -44,7 +44,7 @@ public:
     void openWalletAsync(const QString &path, const QString &password, NetworkType::Type nettype = NetworkType::MAINNET, quint64 kdfRounds = 1, const QString &ringDatabasePath = "");
 
     Wallet * recoveryWallet(const QString &path, const QString &password, const QString &seed, const QString &seed_offset,
-                            NetworkType::Type nettype = NetworkType::MAINNET, quint64 restoreHeight = 0, quint64 kdfRounds = 1);
+                            NetworkType::Type nettype = NetworkType::MAINNET, quint64 restoreHeight = 0, quint64 kdfRounds = 1, const QString &subaddressLookahead = "");
 
     Wallet * createWalletFromKeys(const QString &path,
                                   const QString &password,
@@ -54,7 +54,9 @@ public:
                                   const QString &viewkey,
                                   const QString &spendkey = "",
                                   quint64 restoreHeight = 0,
-                                  quint64 kdfRounds = 1);
+                                  quint64 kdfRounds = 1,
+                                  const QString &subaddressLookahead = ""
+                                  );
 
     Wallet * createDeterministicWalletFromSpendKey(const QString &path,
                                                    const QString &password,
@@ -63,7 +65,8 @@ public:
                                                    const QString &spendkey,
                                                    quint64 restoreHeight,
                                                    quint64 kdfRounds,
-                                                   const QString &offset_passphrase = "");
+                                                   const QString &offset_passphrase = "",
+                                                   const QString &subaddressLookahead = "");
 
     Wallet * createWalletFromDevice(const QString &path,
                                     const QString &password,
index a9f282e89747ff032dcd669c5c673aadcd3a8622..bec6de02b96feb756cf1b44eb697d076755a8b36 100644 (file)
@@ -5,7 +5,10 @@
 #include "ui_PageHardwareDevice.h"
 #include "WalletWizard.h"
 
+#include <QCheckBox>
+#include <QDialogButtonBox>
 #include <QMessageBox>
+#include <QPushButton>
 
 PageHardwareDevice::PageHardwareDevice(WizardFields *fields, QWidget *parent)
         : QWizardPage(parent)
@@ -16,6 +19,8 @@ PageHardwareDevice::PageHardwareDevice(WizardFields *fields, QWidget *parent)
 
     ui->combo_deviceType->addItem("Ledger Nano S (PLUS) / X", DeviceType::LEDGER);
     ui->combo_deviceType->addItem("Trezor Model T", DeviceType::TREZOR);
+
+    connect(ui->btnOptions, &QPushButton::clicked, this, &PageHardwareDevice::onOptionsClicked);
 }
 
 void PageHardwareDevice::initializePage() {
@@ -23,18 +28,39 @@ void PageHardwareDevice::initializePage() {
 }
 
 int PageHardwareDevice::nextId() const {
-    if (ui->radioNewWallet->isChecked())
-        return WalletWizard::Page_WalletFile;
-    if (ui->radioRestoreWallet->isChecked())
+    if (m_fields->showSetRestoreHeightPage) {
         return WalletWizard::Page_SetRestoreHeight;
-    return 0;
+    }
+
+    return WalletWizard::Page_WalletFile;
 }
 
 bool PageHardwareDevice::validatePage() {
     m_fields->deviceType = static_cast<DeviceType>(ui->combo_deviceType->currentData().toInt());
+    m_fields->showSetRestoreHeightPage = ui->radioRestoreWallet->isChecked();
     return true;
 }
 
 bool PageHardwareDevice::isComplete() const {
     return true;
+}
+
+void PageHardwareDevice::onOptionsClicked() {
+    QDialog dialog(this);
+    dialog.setWindowTitle("Options");
+
+    QVBoxLayout layout;
+    QCheckBox check_subaddressLookahead("Set subaddress lookahead");
+    check_subaddressLookahead.setChecked(m_fields->showSetSubaddressLookaheadPage);
+
+    layout.addWidget(&check_subaddressLookahead);
+    QDialogButtonBox buttons(QDialogButtonBox::Ok);
+    layout.addWidget(&buttons);
+    dialog.setLayout(&layout);
+    connect(&buttons, &QDialogButtonBox::accepted, [&dialog]{
+        dialog.close();
+    });
+    dialog.exec();
+
+    m_fields->showSetSubaddressLookaheadPage = check_subaddressLookahead.isChecked();
 }
\ No newline at end of file
index d92df80ba607d456ce948ab7b1b111df214d2fe3..0e0ba65fb731b46a12572cb27b9894728c9798e8 100644 (file)
@@ -28,6 +28,8 @@ public:
     bool isComplete() const override;
 
 private:
+    void onOptionsClicked();
+
     Ui::PageHardwareDevice *ui;
     WizardFields *m_fields;
 };
index 9d2cc95162b59a0b29118b4d4724a335db3aa7df..a4f51f69b7c188dfe3468608f89bbe35b5761edc 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>558</width>
-    <height>431</height>
+    <width>968</width>
+    <height>630</height>
    </rect>
   </property>
   <property name="windowTitle">
      </property>
     </spacer>
    </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
+     <item>
+      <widget class="QPushButton" name="btnOptions">
+       <property name="text">
+        <string>Options</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_3">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
   </layout>
  </widget>
  <resources/>
index 61bde471831592f9309c0e555fbff14e8d7b6b2a..45c9ee8b6c05ee77d1701ddb971d07df84d6be5b 100644 (file)
@@ -49,6 +49,8 @@ int PageMenu::nextId() const {
 }
 
 bool PageMenu::validatePage() {
+    m_fields->clearFields();
+
     if (ui->radioCreate->isChecked()) {
         m_fields->mode = WizardMode::CreateWallet;
         m_fields->modeText = "Create wallet";
index 5ec276f76f17192ef8302c6d597dbedd05471174..25fd77bec43cd1344a409dddd6ced1b805065105 100644 (file)
@@ -46,7 +46,7 @@ void PageSetRestoreHeight::initializePage() {
     ui->frame_scanWarning->hide();
     ui->frame_walletAgeWarning->hide();
 
-    if (m_fields->seedCreationDateOverridden) {
+    if (m_fields->showSetRestoreHeightPage && m_fields->mode == WizardMode::RestoreFromSeed) {
         auto creationDate = QDateTime::fromSecsSinceEpoch(m_fields->seed.time);
         ui->line_creationDate->setText(creationDate.toString("yyyy-MM-dd"));
         this->onCreationDateEdited();
@@ -103,6 +103,14 @@ bool PageSetRestoreHeight::validatePage() {
 }
 
 int PageSetRestoreHeight::nextId() const {
+    if (m_fields->showSetSeedPassphrasePage) {
+        return WalletWizard::Page_SetSeedPassphrase;
+    }
+
+    if (m_fields->showSetSubaddressLookaheadPage) {
+        return WalletWizard::Page_SetSubaddressLookahead;
+    }
+
     return WalletWizard::Page_WalletFile;
 }
 
index 5b08f5cd329233d858e10bc5b20f69991a02c79c..cc595872230eb77d53c1a3a506f33fd51265e241 100644 (file)
@@ -25,5 +25,9 @@ bool PageSetSeedPassphrase::validatePage() {
 }
 
 int PageSetSeedPassphrase::nextId() const {
+    if (m_fields->showSetSubaddressLookaheadPage) {
+        return WalletWizard::Page_SetSubaddressLookahead;
+    }
+
     return WalletWizard::Page_WalletFile;
 }
\ No newline at end of file
diff --git a/src/wizard/PageSetSubaddressLookahead.cpp b/src/wizard/PageSetSubaddressLookahead.cpp
new file mode 100644 (file)
index 0000000..1504d05
--- /dev/null
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: BSD-3-Clause
+// SPDX-FileCopyrightText: 2020-2023 The Monero Project
+
+#include "PageSetSubaddressLookahead.h"
+#include "ui_PageSetSubaddressLookahead.h"
+#include "WalletWizard.h"
+
+#include <QIntValidator>
+
+PageSetSubaddressLookahead::PageSetSubaddressLookahead(WizardFields *fields, QWidget *parent)
+        : QWizardPage(parent)
+        , ui(new Ui::PageSetSubaddressLookahead)
+        , m_fields(fields)
+{
+    ui->setupUi(this);
+
+    // uint32_t can go up to 4294967294, but this isn't realistic
+    auto indexValidator = new QIntValidator(1, 2147483647, this);
+
+    ui->line_major->setValidator(indexValidator);
+    ui->line_minor->setValidator(indexValidator);
+
+    this->setTitle("Subaddress Lookahead");
+}
+
+void PageSetSubaddressLookahead::initializePage() {
+    if (m_fields->mode == WizardMode::CreateWalletFromDevice) {
+        ui->line_major->setText("5");
+        ui->line_minor->setText("20");
+    } else {
+        ui->line_major->setText("50");
+        ui->line_minor->setText("200");
+    }
+}
+
+bool PageSetSubaddressLookahead::validatePage() {
+    m_fields->subaddressLookahead = QString("%1:%2").arg(ui->line_major->text(), ui->line_minor->text());
+    return true;
+}
+
+int PageSetSubaddressLookahead::nextId() const {
+    return WalletWizard::Page_WalletFile;
+}
\ No newline at end of file
similarity index 50%
copy from src/wizard/PageHardwareDevice.h
copy to src/wizard/PageSetSubaddressLookahead.h
index d92df80ba607d456ce948ab7b1b111df214d2fe3..ae26f0821d7e7e1f25b1727ccaee0acb3f05102f 100644 (file)
@@ -1,36 +1,34 @@
 // SPDX-License-Identifier: BSD-3-Clause
 // SPDX-FileCopyrightText: 2020-2023 The Monero Project
 
-#ifndef FEATHER_PAGEHARDWAREDEVICE_H
-#define FEATHER_PAGEHARDWAREDEVICE_H
+#ifndef FEATHER_PAGESETSUBADDRESSLOOKAHEAD_H
+#define FEATHER_PAGESETSUBADDRESSLOOKAHEAD_H
 
-#include <QLabel>
 #include <QWizardPage>
 #include <QWidget>
-#include <QDir>
 
 #include "appcontext.h"
 #include "WalletWizard.h"
 
 namespace Ui {
-    class PageHardwareDevice;
+    class PageSetSubaddressLookahead;
 }
 
-class PageHardwareDevice : public QWizardPage
+class PageSetSubaddressLookahead : public QWizardPage
 {
 Q_OBJECT
 
 public:
-    explicit PageHardwareDevice(WizardFields *fields, QWidget *parent = nullptr);
+    explicit  PageSetSubaddressLookahead(WizardFields *fields, QWidget *parent = nullptr);
     void initializePage() override;
     bool validatePage() override;
     int nextId() const override;
-    bool isComplete() const override;
 
 private:
-    Ui::PageHardwareDevice *ui;
+    Ui::PageSetSubaddressLookahead *ui;
+
     WizardFields *m_fields;
 };
 
 
-#endif //FEATHER_PAGEHARDWAREDEVICE_H
+#endif //FEATHER_PAGESETSUBADDRESSLOOKAHEAD_H
diff --git a/src/wizard/PageSetSubaddressLookahead.ui b/src/wizard/PageSetSubaddressLookahead.ui
new file mode 100644 (file)
index 0000000..6fd4d8f
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PageSetSubaddressLookahead</class>
+ <widget class="QWizardPage" name="PageSetSubaddressLookahead">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>568</width>
+    <height>341</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>WizardPage</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QFormLayout" name="formLayout">
+     <item row="0" column="0">
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>Major (account)</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="0">
+      <widget class="QLabel" name="label_2">
+       <property name="text">
+        <string>Minor (subaddress)</string>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="1">
+      <widget class="QLineEdit" name="line_major"/>
+     </item>
+     <item row="1" column="1">
+      <widget class="QLineEdit" name="line_minor"/>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
index df1c83973be3610b89878b7a0351a3aa7f21de53..34bdbd40bd29edbcdc292c7a680d5a58fef947b3 100644 (file)
@@ -4,7 +4,10 @@
 #include "PageWalletRestoreKeys.h"
 #include "ui_PageWalletRestoreKeys.h"
 
+#include <QCheckBox>
+#include <QDialogButtonBox>
 #include <QPlainTextEdit>
+#include <QPushButton>
 
 #include "WalletWizard.h"
 #include "constants.h"
@@ -31,6 +34,8 @@ PageWalletRestoreKeys::PageWalletRestoreKeys(WizardFields *fields, QWidget *pare
     } else if (constants::networkType == NetworkType::Type::STAGENET) {
         ui->line_address->setPlaceholderText("5...");
     }
+
+    connect(ui->btnOptions, &QPushButton::clicked, this, &PageWalletRestoreKeys::onOptionsClicked);
 }
 
 void PageWalletRestoreKeys::initializePage() {
@@ -80,3 +85,23 @@ bool PageWalletRestoreKeys::validatePage() {
     m_fields->secretSpendKey = spendkey;
     return true;
 }
+
+void PageWalletRestoreKeys::onOptionsClicked() {
+    QDialog dialog(this);
+    dialog.setWindowTitle("Options");
+
+    QVBoxLayout layout;
+    QCheckBox check_subaddressLookahead("Set subaddress lookahead");
+    check_subaddressLookahead.setChecked(m_fields->showSetSubaddressLookaheadPage);
+
+    layout.addWidget(&check_subaddressLookahead);
+    QDialogButtonBox buttons(QDialogButtonBox::Ok);
+    layout.addWidget(&buttons);
+    dialog.setLayout(&layout);
+    connect(&buttons, &QDialogButtonBox::accepted, [&dialog]{
+        dialog.close();
+    });
+    dialog.exec();
+
+    m_fields->showSetSubaddressLookaheadPage = check_subaddressLookahead.isChecked();
+}
\ No newline at end of file
index 19ac3c0f5fb91a53f5bcae96b251e496f7a4c64d..36febe119566e73b3f23437c7bd7c8213f9cd382 100644 (file)
@@ -28,6 +28,8 @@ public:
     int nextId() const override;
 
 private:
+    void onOptionsClicked();
+
     Ui::PageWalletRestoreKeys *ui;
     WizardFields *m_fields;
 };
index b321cb345813d3deeca8b257e97904dc6cf33208..90227c1ef9e5dea5d21fe53ce3902c283fa38af4 100644 (file)
      </property>
     </spacer>
    </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <widget class="QPushButton" name="btnOptions">
+       <property name="text">
+        <string>Options</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_2">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
   </layout>
  </widget>
  <resources/>
index 9c123d3a1d80125fd92387bc8e1fbd04174a7ca2..83f4b3e4a09f84671551a7312cee54ae9675ac72 100644 (file)
@@ -5,7 +5,10 @@
 #include "PageWalletRestoreSeed.h"
 #include "ui_PageWalletRestoreSeed.h"
 
+#include <QCheckBox>
+#include <QDialogButtonBox>
 #include <QPlainTextEdit>
+#include <QPushButton>
 #include <QMessageBox>
 
 #include <monero_seed/wordlist.hpp>  // tevador 14 word
@@ -57,6 +60,7 @@ PageWalletRestoreSeed::PageWalletRestoreSeed(WizardFields *fields, QWidget *pare
 
     connect(ui->seedBtnGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked), this, &PageWalletRestoreSeed::onSeedTypeToggled);
     connect(ui->combo_seedLanguage, &QComboBox::currentTextChanged, this, &PageWalletRestoreSeed::onSeedLanguageChanged);
+    connect(ui->btnOptions, &QPushButton::clicked, this, &PageWalletRestoreSeed::onOptionsClicked);
 }
 
 
@@ -66,21 +70,18 @@ void PageWalletRestoreSeed::onSeedTypeToggled() {
         m_fields->seedType = Seed::Type::POLYSEED;
         ui->seedEdit->setPlaceholderText("Enter 16 word seed..");
         ui->group_seedLanguage->hide();
-        ui->check_overrideCreationDate->setVisible(true);
     }
     if (ui->radio14->isChecked()) {
         m_mode = &m_tevador;
         m_fields->seedType = Seed::Type::TEVADOR;
         ui->seedEdit->setPlaceholderText("Enter 14 word seed..");
         ui->group_seedLanguage->hide();
-        ui->check_overrideCreationDate->setVisible(true);
     }
     else if (ui->radio25->isChecked()) {
         m_mode = &m_legacy;
         m_fields->seedType = Seed::Type::MONERO;
         ui->seedEdit->setPlaceholderText("Enter 25 word seed..");
         ui->group_seedLanguage->show();
-        ui->check_overrideCreationDate->setVisible(false);
     }
 
     ui->label_errorString->hide();
@@ -95,10 +96,18 @@ void PageWalletRestoreSeed::onSeedLanguageChanged(const QString &language) {
 }
 
 int PageWalletRestoreSeed::nextId() const {
-    if (m_mode == &m_legacy || ui->check_overrideCreationDate->isChecked()) {
+    if (m_mode == &m_legacy || m_fields->showSetRestoreHeightPage) {
         return WalletWizard::Page_SetRestoreHeight;
     }
 
+    if (m_fields->showSetSeedPassphrasePage) {
+        return WalletWizard::Page_SetSeedPassphrase;
+    }
+
+    if (m_fields->showSetSubaddressLookaheadPage) {
+        return WalletWizard::Page_SetSubaddressLookahead;
+    }
+
     return WalletWizard::Page_WalletFile;
 }
 
@@ -107,9 +116,6 @@ void PageWalletRestoreSeed::initializePage() {
     ui->seedEdit->setText("");
     ui->seedEdit->setStyleSheet("");
     ui->label_errorString->hide();
-    ui->line_seedOffset->setText("");
-    ui->check_overrideCreationDate->setVisible(false);
-    ui->check_overrideCreationDate->setChecked(false);
     ui->radio16->isChecked();
     this->onSeedTypeToggled();
 }
@@ -161,8 +167,36 @@ bool PageWalletRestoreSeed::validatePage() {
     }
 
     m_fields->seed = _seed;
-    m_fields->seedOffsetPassphrase = ui->line_seedOffset->text();
-    m_fields->seedCreationDateOverridden = ui->check_overrideCreationDate->isChecked();
 
     return true;
 }
+
+void PageWalletRestoreSeed::onOptionsClicked() {
+    QDialog dialog(this);
+    dialog.setWindowTitle("Options");
+
+    QVBoxLayout layout;
+    QCheckBox check_overrideCreationDate("Override embedded wallet creation date");
+    check_overrideCreationDate.setChecked(m_fields->showSetRestoreHeightPage);
+
+    QCheckBox check_setSeedPasshprase("Extend this seed with a passphrase");
+    check_setSeedPasshprase.setChecked(m_fields->showSetSeedPassphrasePage);
+
+    QCheckBox check_subaddressLookahead("Set subaddress lookahead");
+    check_subaddressLookahead.setChecked(m_fields->showSetSubaddressLookaheadPage);
+
+    layout.addWidget(&check_overrideCreationDate);
+    layout.addWidget(&check_setSeedPasshprase);
+    layout.addWidget(&check_subaddressLookahead);
+    QDialogButtonBox buttons(QDialogButtonBox::Ok);
+    layout.addWidget(&buttons);
+    dialog.setLayout(&layout);
+    connect(&buttons, &QDialogButtonBox::accepted, [&dialog]{
+        dialog.close();
+    });
+    dialog.exec();
+
+    m_fields->showSetRestoreHeightPage = check_overrideCreationDate.isChecked();
+    m_fields->showSetSeedPassphrasePage = check_setSeedPasshprase.isChecked();
+    m_fields->showSetSubaddressLookaheadPage = check_subaddressLookahead.isChecked();
+}
\ No newline at end of file
index fac22296a532d05dd1cb48ccc9c28adc772bcd72..2aa4c00f2bf55137d93bae51d606cc8e8b75588b 100644 (file)
@@ -50,6 +50,7 @@ private:
 
     void onSeedTypeToggled();
     void onSeedLanguageChanged(const QString &language);
+    void onOptionsClicked();
 
     Ui::PageWalletRestoreSeed *ui;
     WizardFields *m_fields;
index 3a82f7fc3304d7c00529be4f283738fa1bd891a7..0efe960f6017cc340d06105ebeea954451caa66e 100644 (file)
      </property>
     </spacer>
    </item>
-   <item>
-    <widget class="QLabel" name="label_2">
-     <property name="text">
-      <string>Seed offset passphrase:</string>
-     </property>
-    </widget>
-   </item>
-   <item>
-    <widget class="QLineEdit" name="line_seedOffset">
-     <property name="echoMode">
-      <enum>QLineEdit::Normal</enum>
-     </property>
-     <property name="placeholderText">
-      <string>Leave blank if in doubt</string>
-     </property>
-    </widget>
-   </item>
-   <item>
-    <widget class="QCheckBox" name="check_overrideCreationDate">
-     <property name="text">
-      <string>Override embedded wallet creation date</string>
-     </property>
-    </widget>
-   </item>
    <item>
     <widget class="QLabel" name="label_errorString">
      <property name="text">
      </property>
     </spacer>
    </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QPushButton" name="btnOptions">
+       <property name="text">
+        <string>Options</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
   </layout>
  </widget>
  <customwidgets>
index 0044ed0372076c007d23034774bc1c656d7a6437..18e7693a7343bdf2f76da4942dd7dc8855b1e5f0 100644 (file)
@@ -94,9 +94,10 @@ void PageWalletSeed::displaySeed(const QString &seed){
 
 void PageWalletSeed::onOptionsClicked() {
     QDialog dialog(this);
+    dialog.setWindowTitle("Options");
     QVBoxLayout layout;
     QCheckBox checkbox("Extend this seed with a passphrase");
-    checkbox.setChecked(m_fields->seedOffsetPassphraseEnabled);
+    checkbox.setChecked(m_fields->showSetSeedPassphrasePage);
     layout.addWidget(&checkbox);
     QDialogButtonBox buttons(QDialogButtonBox::Ok);
     layout.addWidget(&buttons);
@@ -105,11 +106,11 @@ void PageWalletSeed::onOptionsClicked() {
         dialog.close();
     });
     dialog.exec();
-    m_fields->seedOffsetPassphraseEnabled = checkbox.isChecked();
+    m_fields->showSetSeedPassphrasePage = checkbox.isChecked();
 }
 
 int PageWalletSeed::nextId() const {
-    if (m_fields->seedOffsetPassphraseEnabled) {
+    if (m_fields->showSetSeedPassphrasePage) {
         return WalletWizard::Page_SetSeedPassphrase;
     }
     return WalletWizard::Page_WalletFile;
index 99e4512f24fae425ce688c3e1b4c46d1c118d526..a0750b648e4cf1eb132fea10494c39a0651f7e7e 100644 (file)
         <item>
          <widget class="QLabel" name="label_14">
           <property name="text">
-           <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Feather recently switched to a new seed scheme called &lt;span style=&quot; font-weight:600;&quot;&gt;Polyseed&lt;/span&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
-          </property>
-          <property name="wordWrap">
-           <bool>true</bool>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QLabel" name="label_12">
-          <property name="text">
-           <string>For more information visit: docs.featherwallet.org/guides/seed-scheme</string>
+           <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Feather uses &lt;span style=&quot; font-weight:600;&quot;&gt;Polyseed&lt;/span&gt;. For more information visit: docs.featherwallet.org/guides/seed-scheme&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
           </property>
           <property name="wordWrap">
            <bool>true</bool>
         <enum>Qt::NoFocus</enum>
        </property>
        <property name="text">
-        <string>Generate</string>
+        <string>Generate new</string>
        </property>
       </widget>
      </item>
index 250437c980c81240cbcc40ea6e383b4d3d696915..91e689351338cad2345f38603112b21225bd0390 100644 (file)
@@ -14,6 +14,7 @@
 #include "PageSetPassword.h"
 #include "PageSetRestoreHeight.h"
 #include "PageSetSeedPassphrase.h"
+#include "PageSetSubaddressLookahead.h"
 #include "PageHardwareDevice.h"
 #include "PageNetworkTor.h"
 #include "PageNetworkWebsocket.h"
@@ -41,6 +42,7 @@ WalletWizard::WalletWizard(QWidget *parent)
     auto createWalletSeed = new PageWalletSeed(&m_wizardFields, this);
     auto walletSetPasswordPage = new PageSetPassword(&m_wizardFields, this);
     auto walletSetSeedPassphrasePage = new PageSetSeedPassphrase(&m_wizardFields, this);
+    auto walletSetSubaddressLookaheadPage = new PageSetSubaddressLookahead(&m_wizardFields, this);
     setPage(Page_Menu, menuPage);
     setPage(Page_WalletFile, createWallet);
     setPage(Page_OpenWallet, openWalletPage);
@@ -54,6 +56,7 @@ WalletWizard::WalletWizard(QWidget *parent)
     setPage(Page_SetRestoreHeight, new PageSetRestoreHeight(&m_wizardFields, this));
     setPage(Page_HardwareDevice, new PageHardwareDevice(&m_wizardFields, this));
     setPage(Page_SetSeedPassphrase, walletSetSeedPassphrasePage);
+    setPage(Page_SetSubaddressLookahead, walletSetSubaddressLookaheadPage);
 
     setStartId(Page_Menu);
 
@@ -112,7 +115,7 @@ void WalletWizard::onCreateWallet() {
                 deviceName = "Trezor";
         }
 
-        emit createWalletFromDevice(walletPath, m_wizardFields.password, deviceName, restoreHeight);
+        emit createWalletFromDevice(walletPath, m_wizardFields.password, deviceName, restoreHeight, m_wizardFields.subaddressLookahead);
         return;
     }
 
@@ -122,7 +125,8 @@ void WalletWizard::onCreateWallet() {
                                   m_wizardFields.address,
                                   m_wizardFields.secretViewKey,
                                   m_wizardFields.secretSpendKey,
-                                  m_wizardFields.restoreHeight);
+                                  m_wizardFields.restoreHeight,
+                                  m_wizardFields.subaddressLookahead);
         return;
     }
 
@@ -132,9 +136,9 @@ void WalletWizard::onCreateWallet() {
         m_wizardFields.seed.restoreHeight = currentBlockHeight;
     }
 
-    if (m_wizardFields.mode == WizardMode::RestoreFromSeed && (m_wizardFields.seedType == Seed::Type::MONERO || m_wizardFields.seedCreationDateOverridden)) {
+    if (m_wizardFields.mode == WizardMode::RestoreFromSeed && (m_wizardFields.seedType == Seed::Type::MONERO || m_wizardFields.showSetRestoreHeightPage)) {
         m_wizardFields.seed.setRestoreHeight(m_wizardFields.restoreHeight);
     }
 
-    emit createWallet(m_wizardFields.seed, walletPath, m_wizardFields.password, m_wizardFields.seedLanguage, m_wizardFields.seedOffsetPassphrase);
+    emit createWallet(m_wizardFields.seed, walletPath, m_wizardFields.password, m_wizardFields.seedLanguage, m_wizardFields.seedOffsetPassphrase, m_wizardFields.subaddressLookahead);
 }
\ No newline at end of file
index 5a88f08ab2095a89a8ef86f5ef0eff7ebdbc6100..04d31a6dc15300e307877560dd126b0191a0ee6f 100644 (file)
@@ -31,8 +31,9 @@ struct WizardFields {
     QString walletName;
     QString walletDir;
     Seed seed;
-    bool seedOffsetPassphraseEnabled = false;
-    bool seedCreationDateOverridden = false;
+    bool showSetSeedPassphrasePage = false;
+    bool showSetRestoreHeightPage = false;
+    bool showSetSubaddressLookaheadPage = false;
     QString seedOffsetPassphrase;
     QString seedLanguage = constants::seedLanguage;
     QString password;
@@ -44,9 +45,23 @@ struct WizardFields {
     int restoreHeight = 0;
     Seed::Type seedType;
     DeviceType deviceType;
+    QString subaddressLookahead;
+
+    void clearFields() {
+        showSetSeedPassphrasePage = false;
+        showSetRestoreHeightPage = false;
+        showSetSubaddressLookaheadPage = false;
+        seedOffsetPassphrase = "";
+        password = "";
+        address = "";
+        secretViewKey = "";
+        secretSpendKey = "";
+        restoreHeight = 0;
+        subaddressLookahead = "";
+    }
 
     WizardFields(): deviceType(DeviceType::LEDGER), mode(WizardMode::CreateWallet),
-    seedType(Seed::POLYSEED), seedOffsetPassphraseEnabled(false), restoreHeight(0) {}
+                    seedType(Seed::POLYSEED), restoreHeight(0) {}
 };
 
 class WalletWizard : public QWizard
@@ -55,11 +70,12 @@ class WalletWizard : public QWizard
 
 public:
     enum Page {
-        Page_Menu,
+        Page_Menu = 0,
         Page_WalletFile,
         Page_CreateWalletSeed,
         Page_SetSeedPassphrase,
         Page_SetPasswordPage,
+        Page_SetSubaddressLookahead,
         Page_OpenWallet,
         Page_Network,
         Page_WalletRestoreSeed,
@@ -79,9 +95,9 @@ signals:
     void openWallet(QString path, QString password);
     void defaultWalletDirChanged(QString walletDir);
 
-    void createWalletFromDevice(const QString &path, const QString &password, const QString &deviceName, int restoreHeight);
-    void createWalletFromKeys(const QString &path, const QString &password, const QString &address, const QString &viewkey, const QString &spendkey, quint64 restoreHeight, bool deterministic = false);
-    void createWallet(Seed seed, const QString &path, const QString &password, const QString &seedLanguage, const QString &seedOffset = "");
+    void createWalletFromDevice(const QString &path, const QString &password, const QString &deviceName, int restoreHeight, const QString &subaddressLookahead);
+    void createWalletFromKeys(const QString &path, const QString &password, const QString &address, const QString &viewkey, const QString &spendkey, quint64 restoreHeight, const QString subaddressLookahead = "");
+    void createWallet(Seed seed, const QString &path, const QString &password, const QString &seedLanguage, const QString &seedOffset = "", const QString &subaddressLookahead = "");
 
 private slots:
     void onCreateWallet();