Skip to content

Commit 24815c6

Browse files
committed
gui: wallet creation detects external signer
1 parent 3f845ea commit 24815c6

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

src/qt/createwalletdialog.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <config/bitcoin-config.h>
77
#endif
88

9+
#include <external_signer.h>
910
#include <qt/createwalletdialog.h>
1011
#include <qt/forms/ui_createwalletdialog.h>
1112

@@ -111,6 +112,28 @@ CreateWalletDialog::~CreateWalletDialog()
111112
delete ui;
112113
}
113114

115+
#ifdef ENABLE_EXTERNAL_SIGNER
116+
void CreateWalletDialog::setSigners(std::vector<ExternalSigner>& signers)
117+
{
118+
if (!signers.empty()) {
119+
ui->external_signer_checkbox->setEnabled(true);
120+
ui->external_signer_checkbox->setChecked(true);
121+
ui->encrypt_wallet_checkbox->setEnabled(false);
122+
ui->encrypt_wallet_checkbox->setChecked(false);
123+
// The order matters, because connect() is called when toggling a checkbox:
124+
ui->blank_wallet_checkbox->setEnabled(false);
125+
ui->blank_wallet_checkbox->setChecked(false);
126+
ui->disable_privkeys_checkbox->setEnabled(false);
127+
ui->disable_privkeys_checkbox->setChecked(true);
128+
const std::string label = signers[0].m_name;
129+
ui->wallet_name_line_edit->setText(QString::fromStdString(label));
130+
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
131+
} else {
132+
ui->external_signer_checkbox->setEnabled(false);
133+
}
134+
}
135+
#endif
136+
114137
QString CreateWalletDialog::walletName() const
115138
{
116139
return ui->wallet_name_line_edit->text();

src/qt/createwalletdialog.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
class WalletModel;
1111

12+
#ifdef ENABLE_EXTERNAL_SIGNER
13+
class ExternalSigner;
14+
#endif
15+
1216
namespace Ui {
1317
class CreateWalletDialog;
1418
}
@@ -23,6 +27,10 @@ class CreateWalletDialog : public QDialog
2327
explicit CreateWalletDialog(QWidget* parent);
2428
virtual ~CreateWalletDialog();
2529

30+
#ifdef ENABLE_EXTERNAL_SIGNER
31+
void setSigners(std::vector<ExternalSigner>& signers);
32+
#endif
33+
2634
QString walletName() const;
2735
bool isEncryptWalletChecked() const;
2836
bool isDisablePrivateKeysChecked() const;

src/qt/walletcontroller.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,17 @@ void CreateWalletActivity::finish()
291291
void CreateWalletActivity::create()
292292
{
293293
m_create_wallet_dialog = new CreateWalletDialog(m_parent_widget);
294+
295+
#ifdef ENABLE_EXTERNAL_SIGNER
296+
std::vector<ExternalSigner> signers;
297+
try {
298+
signers = node().externalSigners();
299+
} catch (const std::runtime_error& e) {
300+
QMessageBox::critical(nullptr, tr("Can't list signers"), e.what());
301+
}
302+
m_create_wallet_dialog->setSigners(signers);
303+
#endif
304+
294305
m_create_wallet_dialog->setWindowModality(Qt::ApplicationModal);
295306
m_create_wallet_dialog->show();
296307

0 commit comments

Comments
 (0)