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
@@ -27,14 +28,39 @@ CreateWalletDialog::CreateWalletDialog(QWidget* parent) :
2728 });
2829
2930 connect (ui->encrypt_wallet_checkbox , &QCheckBox::toggled, [this ](bool checked) {
30- // Disable the disable_privkeys_checkbox when isEncryptWalletChecked is
31+ // Disable the disable_privkeys_checkbox and external_signer_checkbox when isEncryptWalletChecked is
3132 // set to true, enable it when isEncryptWalletChecked is false.
3233 ui->disable_privkeys_checkbox ->setEnabled (!checked);
34+ ui->external_signer_checkbox ->setEnabled (!checked);
3335
3436 // When the disable_privkeys_checkbox is disabled, uncheck it.
3537 if (!ui->disable_privkeys_checkbox ->isEnabled ()) {
3638 ui->disable_privkeys_checkbox ->setChecked (false );
3739 }
40+
41+ // When the external_signer_checkbox box is disabled, uncheck it.
42+ if (!ui->external_signer_checkbox ->isEnabled ()) {
43+ ui->external_signer_checkbox ->setChecked (false );
44+ }
45+
46+ });
47+
48+ connect (ui->external_signer_checkbox , &QCheckBox::toggled, [this ](bool checked) {
49+ ui->encrypt_wallet_checkbox ->setEnabled (!checked);
50+ ui->blank_wallet_checkbox ->setEnabled (!checked);
51+ ui->disable_privkeys_checkbox ->setEnabled (!checked);
52+ ui->descriptor_checkbox ->setEnabled (!checked);
53+
54+ // The external signer checkbox is only enabled when a device is detected.
55+ // In that case it is checked by default. Toggling it restores the other
56+ // options to their default.
57+ ui->descriptor_checkbox ->setChecked (checked);
58+ ui->encrypt_wallet_checkbox ->setChecked (false );
59+ ui->disable_privkeys_checkbox ->setChecked (checked);
60+ // The blank check box is ambiguous. This flag is always true for a
61+ // watch-only wallet, even though we immedidately fetch keys from the
62+ // external signer.
63+ ui->blank_wallet_checkbox ->setChecked (checked);
3864 });
3965
4066 connect (ui->disable_privkeys_checkbox , &QCheckBox::toggled, [this ](bool checked) {
@@ -63,18 +89,51 @@ CreateWalletDialog::CreateWalletDialog(QWidget* parent) :
6389 ui->descriptor_checkbox ->setToolTip (tr (" Compiled without sqlite support (required for descriptor wallets)" ));
6490 ui->descriptor_checkbox ->setEnabled (false );
6591 ui->descriptor_checkbox ->setChecked (false );
92+ ui->external_signer_checkbox ->setEnabled (false );
93+ ui->external_signer_checkbox ->setChecked (false );
6694#endif
95+
6796#ifndef USE_BDB
6897 ui->descriptor_checkbox ->setEnabled (false );
6998 ui->descriptor_checkbox ->setChecked (true );
7099#endif
100+
101+ #ifndef ENABLE_EXTERNAL_SIGNER
102+ // : "External signing" means using devices such as hardware wallets.
103+ ui->external_signer_checkbox ->setToolTip (tr (" Compiled without external signing support (required for external signing)" ));
104+ ui->external_signer_checkbox ->setEnabled (false );
105+ ui->external_signer_checkbox ->setChecked (false );
106+ #endif
107+
71108}
72109
73110CreateWalletDialog::~CreateWalletDialog ()
74111{
75112 delete ui;
76113}
77114
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+
78137QString CreateWalletDialog::walletName () const
79138{
80139 return ui->wallet_name_line_edit ->text ();
@@ -99,3 +158,8 @@ bool CreateWalletDialog::isDescriptorWalletChecked() const
99158{
100159 return ui->descriptor_checkbox ->isChecked ();
101160}
161+
162+ bool CreateWalletDialog::isExternalSignerChecked () const
163+ {
164+ return ui->external_signer_checkbox ->isChecked ();
165+ }
0 commit comments