Add CreateWalletDialog to create wallets from the GUI
Co-authored-by: João Barbosa <joao.paulo.barbosa@gmail.com>
This commit is contained in:
parent
60adb21c7a
commit
78863e2900
5 changed files with 252 additions and 0 deletions
|
@ -16,6 +16,7 @@ FORMS += \
|
||||||
../src/qt/forms/sendcoinsentry.ui \
|
../src/qt/forms/sendcoinsentry.ui \
|
||||||
../src/qt/forms/signverifymessagedialog.ui \
|
../src/qt/forms/signverifymessagedialog.ui \
|
||||||
../src/qt/forms/transactiondescdialog.ui \
|
../src/qt/forms/transactiondescdialog.ui \
|
||||||
|
../src/qt/forms/createwalletdialog.ui
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
../src/qt/bitcoin.qrc
|
../src/qt/bitcoin.qrc
|
||||||
|
|
|
@ -98,6 +98,7 @@ QT_FORMS_UI = \
|
||||||
qt/forms/addressbookpage.ui \
|
qt/forms/addressbookpage.ui \
|
||||||
qt/forms/askpassphrasedialog.ui \
|
qt/forms/askpassphrasedialog.ui \
|
||||||
qt/forms/coincontroldialog.ui \
|
qt/forms/coincontroldialog.ui \
|
||||||
|
qt/forms/createwalletdialog.ui \
|
||||||
qt/forms/editaddressdialog.ui \
|
qt/forms/editaddressdialog.ui \
|
||||||
qt/forms/helpmessagedialog.ui \
|
qt/forms/helpmessagedialog.ui \
|
||||||
qt/forms/intro.ui \
|
qt/forms/intro.ui \
|
||||||
|
@ -117,6 +118,7 @@ QT_MOC_CPP = \
|
||||||
qt/moc_addressbookpage.cpp \
|
qt/moc_addressbookpage.cpp \
|
||||||
qt/moc_addresstablemodel.cpp \
|
qt/moc_addresstablemodel.cpp \
|
||||||
qt/moc_askpassphrasedialog.cpp \
|
qt/moc_askpassphrasedialog.cpp \
|
||||||
|
qt/moc_createwalletdialog.cpp \
|
||||||
qt/moc_bantablemodel.cpp \
|
qt/moc_bantablemodel.cpp \
|
||||||
qt/moc_bitcoinaddressvalidator.cpp \
|
qt/moc_bitcoinaddressvalidator.cpp \
|
||||||
qt/moc_bitcoinamountfield.cpp \
|
qt/moc_bitcoinamountfield.cpp \
|
||||||
|
@ -202,6 +204,7 @@ BITCOIN_QT_H = \
|
||||||
qt/clientmodel.h \
|
qt/clientmodel.h \
|
||||||
qt/coincontroldialog.h \
|
qt/coincontroldialog.h \
|
||||||
qt/coincontroltreewidget.h \
|
qt/coincontroltreewidget.h \
|
||||||
|
qt/createwalletdialog.h \
|
||||||
qt/csvmodelwriter.h \
|
qt/csvmodelwriter.h \
|
||||||
qt/editaddressdialog.h \
|
qt/editaddressdialog.h \
|
||||||
qt/guiconstants.h \
|
qt/guiconstants.h \
|
||||||
|
@ -328,6 +331,7 @@ BITCOIN_QT_WALLET_CPP = \
|
||||||
qt/askpassphrasedialog.cpp \
|
qt/askpassphrasedialog.cpp \
|
||||||
qt/coincontroldialog.cpp \
|
qt/coincontroldialog.cpp \
|
||||||
qt/coincontroltreewidget.cpp \
|
qt/coincontroltreewidget.cpp \
|
||||||
|
qt/createwalletdialog.cpp \
|
||||||
qt/editaddressdialog.cpp \
|
qt/editaddressdialog.cpp \
|
||||||
qt/openuridialog.cpp \
|
qt/openuridialog.cpp \
|
||||||
qt/overviewpage.cpp \
|
qt/overviewpage.cpp \
|
||||||
|
|
61
src/qt/createwalletdialog.cpp
Normal file
61
src/qt/createwalletdialog.cpp
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
// Copyright (c) 2019 The Bitcoin Core developers
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#if defined(HAVE_CONFIG_H)
|
||||||
|
#include <config/bitcoin-config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <qt/createwalletdialog.h>
|
||||||
|
#include <qt/forms/ui_createwalletdialog.h>
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
CreateWalletDialog::CreateWalletDialog(QWidget* parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::CreateWalletDialog)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
ui->buttonBox->button(QDialogButtonBox::Ok)->setText("Create");
|
||||||
|
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||||
|
ui->wallet_name_line_edit->setFocus(Qt::ActiveWindowFocusReason);
|
||||||
|
|
||||||
|
connect(ui->wallet_name_line_edit, &QLineEdit::textEdited, [this](const QString& text) {
|
||||||
|
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!text.isEmpty());
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ui->encrypt_wallet_checkbox, &QCheckBox::toggled, [this](bool checked) {
|
||||||
|
// Disable disable_privkeys_checkbox when encrypt is set to true, enable it when encrypt is false
|
||||||
|
ui->disable_privkeys_checkbox->setEnabled(!checked);
|
||||||
|
|
||||||
|
// When the disable_privkeys_checkbox is disabled, uncheck it.
|
||||||
|
if (!ui->disable_privkeys_checkbox->isEnabled()) {
|
||||||
|
ui->disable_privkeys_checkbox->setChecked(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateWalletDialog::~CreateWalletDialog()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CreateWalletDialog::walletName() const
|
||||||
|
{
|
||||||
|
return ui->wallet_name_line_edit->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CreateWalletDialog::encrypt() const
|
||||||
|
{
|
||||||
|
return ui->encrypt_wallet_checkbox->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CreateWalletDialog::disablePrivateKeys() const
|
||||||
|
{
|
||||||
|
return ui->disable_privkeys_checkbox->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CreateWalletDialog::blank() const
|
||||||
|
{
|
||||||
|
return ui->blank_wallet_checkbox->isChecked();
|
||||||
|
}
|
35
src/qt/createwalletdialog.h
Normal file
35
src/qt/createwalletdialog.h
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
// Copyright (c) 2019 The Bitcoin Core developers
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#ifndef BITCOIN_QT_CREATEWALLETDIALOG_H
|
||||||
|
#define BITCOIN_QT_CREATEWALLETDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
class WalletModel;
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class CreateWalletDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Dialog for creating wallets
|
||||||
|
*/
|
||||||
|
class CreateWalletDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit CreateWalletDialog(QWidget* parent);
|
||||||
|
virtual ~CreateWalletDialog();
|
||||||
|
|
||||||
|
QString walletName() const;
|
||||||
|
bool encrypt() const;
|
||||||
|
bool disablePrivateKeys() const;
|
||||||
|
bool blank() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::CreateWalletDialog *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BITCOIN_QT_CREATEWALLETDIALOG_H
|
151
src/qt/forms/createwalletdialog.ui
Normal file
151
src/qt/forms/createwalletdialog.ui
Normal file
|
@ -0,0 +1,151 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CreateWalletDialog</class>
|
||||||
|
<widget class="QDialog" name="CreateWalletDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>364</width>
|
||||||
|
<height>185</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Create Wallet</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>140</y>
|
||||||
|
<width>341</width>
|
||||||
|
<height>32</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" name="wallet_name_line_edit">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>120</x>
|
||||||
|
<y>20</y>
|
||||||
|
<width>231</width>
|
||||||
|
<height>24</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>20</x>
|
||||||
|
<y>20</y>
|
||||||
|
<width>101</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Wallet Name</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QCheckBox" name="encrypt_wallet_checkbox">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>20</x>
|
||||||
|
<y>50</y>
|
||||||
|
<width>171</width>
|
||||||
|
<height>22</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Encrypt the wallet. The wallet will be encrypted with a password of your choice.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Encrypt Wallet</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QCheckBox" name="disable_privkeys_checkbox">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>20</x>
|
||||||
|
<y>80</y>
|
||||||
|
<width>171</width>
|
||||||
|
<height>22</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Disable private keys for this wallet. Wallets with private keys disabled will have no private keys and cannot have an HD seed or imported private keys. This is ideal for watch-only wallets.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Disable Private Keys</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QCheckBox" name="blank_wallet_checkbox">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>20</x>
|
||||||
|
<y>110</y>
|
||||||
|
<width>171</width>
|
||||||
|
<height>22</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Make a blank wallet. Blank wallets do not initially have private keys or scripts. Private keys and addresses can be imported, or an HD seed can be set, at a later time.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Make Blank Wallet</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>wallet_name_line_edit</tabstop>
|
||||||
|
<tabstop>encrypt_wallet_checkbox</tabstop>
|
||||||
|
<tabstop>disable_privkeys_checkbox</tabstop>
|
||||||
|
<tabstop>blank_wallet_checkbox</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>CreateWalletDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>CreateWalletDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
Loading…
Reference in a new issue