qt: hide Create Unsigned button behind an expert mode option

This commit is contained in:
Andrew Chow 2020-04-28 15:29:12 -04:00
parent 5c3b800acd
commit 742918c8ef
6 changed files with 32 additions and 2 deletions

View File

@ -252,6 +252,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="m_enable_psbt_controls">
<property name="text">
<string extracomment="An options window setting to enable PSBT controls.">Enable &amp;PSBT controls</string>
</property>
<property name="toolTip">
<string extracomment="Tooltip text for options window setting that enables PSBT controls.">Whether to show PSBT controls.</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -242,6 +242,7 @@ void OptionsDialog::setMapper()
mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures); mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures);
mapper->addMapping(ui->subFeeFromAmount, OptionsModel::SubFeeFromAmount); mapper->addMapping(ui->subFeeFromAmount, OptionsModel::SubFeeFromAmount);
mapper->addMapping(ui->externalSignerPath, OptionsModel::ExternalSignerPath); mapper->addMapping(ui->externalSignerPath, OptionsModel::ExternalSignerPath);
mapper->addMapping(ui->m_enable_psbt_controls, OptionsModel::EnablePSBTControls);
/* Network */ /* Network */
mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP); mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP);

View File

@ -83,6 +83,11 @@ void OptionsModel::Init(bool resetSettings)
settings.setValue("fCoinControlFeatures", false); settings.setValue("fCoinControlFeatures", false);
fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool(); fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool();
if (!settings.contains("enable_psbt_controls")) {
settings.setValue("enable_psbt_controls", false);
}
m_enable_psbt_controls = settings.value("enable_psbt_controls", false).toBool();
// These are shared with the core or have a command-line parameter // These are shared with the core or have a command-line parameter
// and we want command-line parameters to overwrite the GUI settings. // and we want command-line parameters to overwrite the GUI settings.
// //
@ -360,6 +365,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
return m_use_embedded_monospaced_font; return m_use_embedded_monospaced_font;
case CoinControlFeatures: case CoinControlFeatures:
return fCoinControlFeatures; return fCoinControlFeatures;
case EnablePSBTControls:
return settings.value("enable_psbt_controls");
case Prune: case Prune:
return settings.value("bPrune"); return settings.value("bPrune");
case PruneSize: case PruneSize:
@ -507,6 +514,10 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
settings.setValue("fCoinControlFeatures", fCoinControlFeatures); settings.setValue("fCoinControlFeatures", fCoinControlFeatures);
Q_EMIT coinControlFeaturesChanged(fCoinControlFeatures); Q_EMIT coinControlFeaturesChanged(fCoinControlFeatures);
break; break;
case EnablePSBTControls:
m_enable_psbt_controls = value.toBool();
settings.setValue("enable_psbt_controls", m_enable_psbt_controls);
break;
case Prune: case Prune:
if (settings.value("bPrune") != value) { if (settings.value("bPrune") != value) {
settings.setValue("bPrune", value); settings.setValue("bPrune", value);

View File

@ -70,6 +70,7 @@ public:
SpendZeroConfChange, // bool SpendZeroConfChange, // bool
Listen, // bool Listen, // bool
Server, // bool Server, // bool
EnablePSBTControls, // bool
OptionIDRowCount, OptionIDRowCount,
}; };
@ -91,6 +92,7 @@ public:
bool getUseEmbeddedMonospacedFont() const { return m_use_embedded_monospaced_font; } bool getUseEmbeddedMonospacedFont() const { return m_use_embedded_monospaced_font; }
bool getCoinControlFeatures() const { return fCoinControlFeatures; } bool getCoinControlFeatures() const { return fCoinControlFeatures; }
bool getSubFeeFromAmount() const { return m_sub_fee_from_amount; } bool getSubFeeFromAmount() const { return m_sub_fee_from_amount; }
bool getEnablePSBTControls() const { return m_enable_psbt_controls; }
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; } const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
/* Explicit setters */ /* Explicit setters */
@ -116,6 +118,7 @@ private:
bool m_use_embedded_monospaced_font; bool m_use_embedded_monospaced_font;
bool fCoinControlFeatures; bool fCoinControlFeatures;
bool m_sub_fee_from_amount; bool m_sub_fee_from_amount;
bool m_enable_psbt_controls;
/* settings that were overridden by command-line */ /* settings that were overridden by command-line */
QString strOverriddenByCommandLine; QString strOverriddenByCommandLine;

View File

@ -333,6 +333,11 @@ bool SendCoinsDialog::PrepareSendText(QString& question_string, QString& informa
a user can only create a PSBT. This string is displayed when private keys are disabled and an external a user can only create a PSBT. This string is displayed when private keys are disabled and an external
signer is not available. */ signer is not available. */
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)); 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));
} else if (model->getOptionsModel()->getEnablePSBTControls()) {
/*: Text to inform a user attempting to create a transaction of their current options. At this stage,
a user can send their transaction or create a PSBT. This string is displayed when both private keys
and PSBT controls are enabled. */
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));
} else { } else {
/*: Text to prompt a user to review the details of the transaction they are attempting to send. */ /*: Text to prompt a user to review the details of the transaction they are attempting to send. */
question_string.append(tr("Please, review your transaction.")); question_string.append(tr("Please, review your transaction."));
@ -399,7 +404,7 @@ void SendCoinsDialog::sendButtonClicked([[maybe_unused]] bool checked)
assert(m_current_transaction); assert(m_current_transaction);
const QString confirmation = tr("Confirm send coins"); const QString confirmation = tr("Confirm send coins");
auto confirmationDialog = new SendConfirmationDialog(confirmation, question_string, informative_text, detailed_text, SEND_CONFIRM_DELAY, !model->wallet().privateKeysDisabled(), true, this); auto confirmationDialog = new SendConfirmationDialog(confirmation, question_string, informative_text, detailed_text, SEND_CONFIRM_DELAY, !model->wallet().privateKeysDisabled(), model->getOptionsModel()->getEnablePSBTControls(), this);
confirmationDialog->setAttribute(Qt::WA_DeleteOnClose); confirmationDialog->setAttribute(Qt::WA_DeleteOnClose);
// TODO: Replace QDialog::exec() with safer QDialog::show(). // TODO: Replace QDialog::exec() with safer QDialog::show().
const auto retval = static_cast<QMessageBox::StandardButton>(confirmationDialog->exec()); const auto retval = static_cast<QMessageBox::StandardButton>(confirmationDialog->exec());

View File

@ -505,7 +505,7 @@ bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
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.")); 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."));
} }
auto confirmationDialog = new SendConfirmationDialog(tr("Confirm fee bump"), questionString, "", "", SEND_CONFIRM_DELAY, !m_wallet->privateKeysDisabled(), true, nullptr); auto confirmationDialog = new SendConfirmationDialog(tr("Confirm fee bump"), questionString, "", "", SEND_CONFIRM_DELAY, !m_wallet->privateKeysDisabled(), getOptionsModel()->getEnablePSBTControls(), nullptr);
confirmationDialog->setAttribute(Qt::WA_DeleteOnClose); confirmationDialog->setAttribute(Qt::WA_DeleteOnClose);
// TODO: Replace QDialog::exec() with safer QDialog::show(). // TODO: Replace QDialog::exec() with safer QDialog::show().
const auto retval = static_cast<QMessageBox::StandardButton>(confirmationDialog->exec()); const auto retval = static_cast<QMessageBox::StandardButton>(confirmationDialog->exec());