Skip to content

Commit 742918c

Browse files
committed
qt: hide Create Unsigned button behind an expert mode option
1 parent 5c3b800 commit 742918c

File tree

6 files changed

+32
-2
lines changed

6 files changed

+32
-2
lines changed

src/qt/forms/optionsdialog.ui

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,16 @@
252252
</property>
253253
</widget>
254254
</item>
255+
<item>
256+
<widget class="QCheckBox" name="m_enable_psbt_controls">
257+
<property name="text">
258+
<string extracomment="An options window setting to enable PSBT controls.">Enable &amp;PSBT controls</string>
259+
</property>
260+
<property name="toolTip">
261+
<string extracomment="Tooltip text for options window setting that enables PSBT controls.">Whether to show PSBT controls.</string>
262+
</property>
263+
</widget>
264+
</item>
255265
</layout>
256266
</widget>
257267
</item>

src/qt/optionsdialog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ void OptionsDialog::setMapper()
242242
mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures);
243243
mapper->addMapping(ui->subFeeFromAmount, OptionsModel::SubFeeFromAmount);
244244
mapper->addMapping(ui->externalSignerPath, OptionsModel::ExternalSignerPath);
245+
mapper->addMapping(ui->m_enable_psbt_controls, OptionsModel::EnablePSBTControls);
245246

246247
/* Network */
247248
mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP);

src/qt/optionsmodel.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ void OptionsModel::Init(bool resetSettings)
8383
settings.setValue("fCoinControlFeatures", false);
8484
fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool();
8585

86+
if (!settings.contains("enable_psbt_controls")) {
87+
settings.setValue("enable_psbt_controls", false);
88+
}
89+
m_enable_psbt_controls = settings.value("enable_psbt_controls", false).toBool();
90+
8691
// These are shared with the core or have a command-line parameter
8792
// and we want command-line parameters to overwrite the GUI settings.
8893
//
@@ -360,6 +365,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
360365
return m_use_embedded_monospaced_font;
361366
case CoinControlFeatures:
362367
return fCoinControlFeatures;
368+
case EnablePSBTControls:
369+
return settings.value("enable_psbt_controls");
363370
case Prune:
364371
return settings.value("bPrune");
365372
case PruneSize:
@@ -507,6 +514,10 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
507514
settings.setValue("fCoinControlFeatures", fCoinControlFeatures);
508515
Q_EMIT coinControlFeaturesChanged(fCoinControlFeatures);
509516
break;
517+
case EnablePSBTControls:
518+
m_enable_psbt_controls = value.toBool();
519+
settings.setValue("enable_psbt_controls", m_enable_psbt_controls);
520+
break;
510521
case Prune:
511522
if (settings.value("bPrune") != value) {
512523
settings.setValue("bPrune", value);

src/qt/optionsmodel.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class OptionsModel : public QAbstractListModel
7070
SpendZeroConfChange, // bool
7171
Listen, // bool
7272
Server, // bool
73+
EnablePSBTControls, // bool
7374
OptionIDRowCount,
7475
};
7576

@@ -91,6 +92,7 @@ class OptionsModel : public QAbstractListModel
9192
bool getUseEmbeddedMonospacedFont() const { return m_use_embedded_monospaced_font; }
9293
bool getCoinControlFeatures() const { return fCoinControlFeatures; }
9394
bool getSubFeeFromAmount() const { return m_sub_fee_from_amount; }
95+
bool getEnablePSBTControls() const { return m_enable_psbt_controls; }
9496
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
9597

9698
/* Explicit setters */
@@ -116,6 +118,7 @@ class OptionsModel : public QAbstractListModel
116118
bool m_use_embedded_monospaced_font;
117119
bool fCoinControlFeatures;
118120
bool m_sub_fee_from_amount;
121+
bool m_enable_psbt_controls;
119122
/* settings that were overridden by command-line */
120123
QString strOverriddenByCommandLine;
121124

src/qt/sendcoinsdialog.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,11 @@ bool SendCoinsDialog::PrepareSendText(QString& question_string, QString& informa
333333
a user can only create a PSBT. This string is displayed when private keys are disabled and an external
334334
signer is not available. */
335335
question_string.append(tr("Please, review your transaction proposal. This will produce a Partially Signed Bitcoin Transaction (PSBT) which you can save or copy and then sign with e.g. an offline %1 wallet, or a PSBT-compatible hardware wallet.").arg(PACKAGE_NAME));
336+
} else if (model->getOptionsModel()->getEnablePSBTControls()) {
337+
/*: Text to inform a user attempting to create a transaction of their current options. At this stage,
338+
a user can send their transaction or create a PSBT. This string is displayed when both private keys
339+
and PSBT controls are enabled. */
340+
question_string.append(tr("Please, review your transaction. You can create and send this transaction or create a Partially Signed Bitcoin Transaction (PSBT), which you can save or copy and then sign with, e.g., an offline %1 wallet, or a PSBT-compatible hardware wallet.").arg(PACKAGE_NAME));
336341
} else {
337342
/*: Text to prompt a user to review the details of the transaction they are attempting to send. */
338343
question_string.append(tr("Please, review your transaction."));
@@ -399,7 +404,7 @@ void SendCoinsDialog::sendButtonClicked([[maybe_unused]] bool checked)
399404
assert(m_current_transaction);
400405

401406
const QString confirmation = tr("Confirm send coins");
402-
auto confirmationDialog = new SendConfirmationDialog(confirmation, question_string, informative_text, detailed_text, SEND_CONFIRM_DELAY, !model->wallet().privateKeysDisabled(), true, this);
407+
auto confirmationDialog = new SendConfirmationDialog(confirmation, question_string, informative_text, detailed_text, SEND_CONFIRM_DELAY, !model->wallet().privateKeysDisabled(), model->getOptionsModel()->getEnablePSBTControls(), this);
403408
confirmationDialog->setAttribute(Qt::WA_DeleteOnClose);
404409
// TODO: Replace QDialog::exec() with safer QDialog::show().
405410
const auto retval = static_cast<QMessageBox::StandardButton>(confirmationDialog->exec());

src/qt/walletmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
505505
questionString.append(tr("Warning: This may pay the additional fee by reducing change outputs or adding inputs, when necessary. It may add a new change output if one does not already exist. These changes may potentially leak privacy."));
506506
}
507507

508-
auto confirmationDialog = new SendConfirmationDialog(tr("Confirm fee bump"), questionString, "", "", SEND_CONFIRM_DELAY, !m_wallet->privateKeysDisabled(), true, nullptr);
508+
auto confirmationDialog = new SendConfirmationDialog(tr("Confirm fee bump"), questionString, "", "", SEND_CONFIRM_DELAY, !m_wallet->privateKeysDisabled(), getOptionsModel()->getEnablePSBTControls(), nullptr);
509509
confirmationDialog->setAttribute(Qt::WA_DeleteOnClose);
510510
// TODO: Replace QDialog::exec() with safer QDialog::show().
511511
const auto retval = static_cast<QMessageBox::StandardButton>(confirmationDialog->exec());

0 commit comments

Comments
 (0)