-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CreateWalletDialog to create wallets from the GUI
Co-authored-by: João Barbosa <[email protected]>
- Loading branch information
Showing
5 changed files
with
252 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |