Skip to content

Commit

Permalink
gui: add external signer path to options dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjors committed Apr 30, 2021
1 parent 2b45cf0 commit 28cd645
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/qt/forms/optionsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,36 @@
</property>
</spacer>
</item>
<item>
<widget class="QGroupBox" name="groupBoxHww">
<property name="title">
<string>External Signer (e.g. hardware wallet)</string>
</property>
<layout class="QVBoxLayout" name="verticalLayoutHww">
<item>
<layout class="QHBoxLayout" name="horizontalLayoutHww">
<item>
<widget class="QLabel" name="externalSignerPathLabel">
<property name="text">
<string>&amp;External signer script path</string>
</property>
<property name="buddy">
<cstring>externalSignerPath</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="externalSignerPath">
<property name="toolTip">
<string>Full path to a Bitcoin Core compatible script (e.g. C:\Downloads\hwi.exe or /Users/you/Downloads/hwi.py). Beware: malware can steal your coins!</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabNetwork">
Expand Down
2 changes: 2 additions & 0 deletions src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ void OptionsDialog::setModel(OptionsModel *_model)
connect(ui->prune, &QCheckBox::clicked, this, &OptionsDialog::togglePruneWarning);
connect(ui->pruneSize, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &OptionsDialog::showRestartWarning);
connect(ui->databaseCache, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &OptionsDialog::showRestartWarning);
connect(ui->externalSignerPath, &QLineEdit::textChanged, [this]{ showRestartWarning(); });
connect(ui->threadsScriptVerif, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &OptionsDialog::showRestartWarning);
/* Wallet */
connect(ui->spendZeroConfChange, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
Expand Down Expand Up @@ -233,6 +234,7 @@ void OptionsDialog::setMapper()
/* Wallet */
mapper->addMapping(ui->spendZeroConfChange, OptionsModel::SpendZeroConfChange);
mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures);
mapper->addMapping(ui->externalSignerPath, OptionsModel::ExternalSignerPath);

/* Network */
mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP);
Expand Down
15 changes: 15 additions & 0 deletions src/qt/optionsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ void OptionsModel::Init(bool resetSettings)
settings.setValue("bSpendZeroConfChange", true);
if (!gArgs.SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool()))
addOverriddenOption("-spendzeroconfchange");

if (!settings.contains("strExternalSignerPath"))
settings.setValue("strExternalSignerPath", "");

if (!gArgs.SoftSetArg("-signer", settings.value("strExternalSignerPath").toString().toStdString())) {
addOverriddenOption("-signer");
}
#endif

// Network
Expand Down Expand Up @@ -325,6 +332,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
#ifdef ENABLE_WALLET
case SpendZeroConfChange:
return settings.value("bSpendZeroConfChange");
case ExternalSignerPath:
return settings.value("strExternalSignerPath");
#endif
case DisplayUnit:
return nDisplayUnit;
Expand Down Expand Up @@ -444,6 +453,12 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
setRestartRequired(true);
}
break;
case ExternalSignerPath:
if (settings.value("strExternalSignerPath") != value.toString()) {
settings.setValue("strExternalSignerPath", value.toString());
setRestartRequired(true);
}
break;
#endif
case DisplayUnit:
setDisplayUnit(value);
Expand Down
1 change: 1 addition & 0 deletions src/qt/optionsmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class OptionsModel : public QAbstractListModel
Prune, // bool
PruneSize, // int
DatabaseCache, // int
ExternalSignerPath, // QString
SpendZeroConfChange, // bool
Listen, // bool
OptionIDRowCount,
Expand Down

0 comments on commit 28cd645

Please sign in to comment.