wizard: allow setting subaddress lookahead

This commit is contained in:
tobtoht 2023-01-24 22:35:47 +01:00
parent 11aabba8a0
commit a7a06d8413
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
28 changed files with 402 additions and 90 deletions

2
monero

@ -1 +1 @@
Subproject commit 7f9d4b9b21d776551dd3809bfc4f9e11d7c7b933
Subproject commit 18bdad879d9f25f35f065354aedf1236e6b0a60b

View 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);
}

View 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();

View 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)));

View file

@ -84,14 +84,14 @@
</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>
@ -101,14 +101,14 @@
</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>
@ -118,14 +118,14 @@
</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>
@ -135,6 +135,20 @@
</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>

View 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

View 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;

View 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);
}

View 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,

View 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();
}

View file

@ -28,6 +28,8 @@ public:
bool isComplete() const override;
private:
void onOptionsClicked();
Ui::PageHardwareDevice *ui;
WizardFields *m_fields;
};

View 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">
@ -118,6 +118,30 @@
</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/>

View 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";

View 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;
}

View file

@ -25,5 +25,9 @@ bool PageSetSeedPassphrase::validatePage() {
}
int PageSetSeedPassphrase::nextId() const {
if (m_fields->showSetSubaddressLookaheadPage) {
return WalletWizard::Page_SetSubaddressLookahead;
}
return WalletWizard::Page_WalletFile;
}

View file

@ -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;
}

View file

@ -0,0 +1,34 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: 2020-2023 The Monero Project
#ifndef FEATHER_PAGESETSUBADDRESSLOOKAHEAD_H
#define FEATHER_PAGESETSUBADDRESSLOOKAHEAD_H
#include <QWizardPage>
#include <QWidget>
#include "appcontext.h"
#include "WalletWizard.h"
namespace Ui {
class PageSetSubaddressLookahead;
}
class PageSetSubaddressLookahead : public QWizardPage
{
Q_OBJECT
public:
explicit PageSetSubaddressLookahead(WizardFields *fields, QWidget *parent = nullptr);
void initializePage() override;
bool validatePage() override;
int nextId() const override;
private:
Ui::PageSetSubaddressLookahead *ui;
WizardFields *m_fields;
};
#endif //FEATHER_PAGESETSUBADDRESSLOOKAHEAD_H

View file

@ -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>

View 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();
}

View file

@ -28,6 +28,8 @@ public:
int nextId() const override;
private:
void onOptionsClicked();
Ui::PageWalletRestoreKeys *ui;
WizardFields *m_fields;
};

View file

@ -217,6 +217,30 @@
</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/>

View 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();
}

View file

@ -50,6 +50,7 @@ private:
void onSeedTypeToggled();
void onSeedLanguageChanged(const QString &language);
void onOptionsClicked();
Ui::PageWalletRestoreSeed *ui;
WizardFields *m_fields;

View file

@ -94,30 +94,6 @@
</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">
@ -138,6 +114,30 @@
</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>

View 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;

View file

@ -122,17 +122,7 @@
<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>
@ -935,7 +925,7 @@
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Generate</string>
<string>Generate new</string>
</property>
</widget>
</item>

View 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);
}

View 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();