Skip to content

Commit 8aec372

Browse files
committed
gui: improve user dialog when signing multisig psbts
Prior to this commit, when a psbt requiring multiple signers is signed via gui the dialog is vague/confusing. Whether the signer successfully partially signs the psbt or not the same warning is displayed "Could not sign any more inputs." After signing the tx, the only way for the user to know if their action had any effect is to inspect the psbt (unless it was the last signature that completed the psbt, in which case there is a success dialog). Now we indicate when a psbt has been partially signed, and show how many partial signatures the psbt has in the transaction description.
1 parent f66738f commit 8aec372

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

src/qt/psbtoperationsdialog.cpp

+29-4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ void PSBTOperationsDialog::signTransaction()
8383

8484
WalletModel::UnlockContext ctx(m_wallet_model->requestUnlock());
8585

86+
// For multisigs we indicate when a participant successfully signs the PSBT
87+
// even when additional signatures are required for the PSBT to be complete.
88+
// Simply check the number of partial signatures before and after signing.
89+
const size_t n_partial_sigs_before{m_transaction_data.inputs.at(0).partial_sigs.size()};
8690
const auto err{m_wallet_model->wallet().fillPSBT(SIGHASH_ALL, /*sign=*/true, /*bip32derivs=*/true, &n_signed, m_transaction_data, complete)};
8791

8892
if (err) {
@@ -93,13 +97,26 @@ void PSBTOperationsDialog::signTransaction()
9397

9498
updateTransactionDisplay();
9599

100+
const size_t n_partial_sigs_after{m_transaction_data.inputs.at(0).partial_sigs.size()};
101+
// We also indicate when the participant successfully signed every tx input.
102+
// To keep things simple we only check if this is not true, in which case
103+
// fallback to the old (vague) behavior where it's unclear if the PSBT was
104+
// successfully partially signed.
105+
const bool all_inputs_n_partial_sigs_equal{std::all_of(m_transaction_data.inputs.begin(), m_transaction_data.inputs.end(),
106+
[&](const PSBTInput& input) { return n_partial_sigs_after == input.partial_sigs.size(); })};
107+
96108
if (!complete && !ctx.isValid()) {
97109
showStatus(tr("Cannot sign inputs while wallet is locked."), StatusLevel::WARN);
98-
} else if (!complete && n_signed < 1) {
99-
showStatus(tr("Could not sign any more inputs."), StatusLevel::WARN);
100110
} else if (!complete) {
101-
showStatus(tr("Signed %1 inputs, but more signatures are still required.").arg(n_signed),
102-
StatusLevel::INFO);
111+
if (all_inputs_n_partial_sigs_equal && n_partial_sigs_after - n_partial_sigs_before > 0) {
112+
showStatus(tr("Added %1 partial signature to each input, but more signatures are still required.").arg(n_partial_sigs_after - n_partial_sigs_before),
113+
StatusLevel::INFO);
114+
} else if (n_signed < 1) {
115+
showStatus(tr("Could not sign any more inputs."), StatusLevel::WARN);
116+
} else {
117+
showStatus(tr("Signed %1 inputs, but more signatures are still required.").arg(n_signed),
118+
StatusLevel::INFO);
119+
}
103120
} else {
104121
showStatus(tr("Signed transaction successfully. Transaction is ready to broadcast."),
105122
StatusLevel::INFO);
@@ -217,9 +234,17 @@ QString PSBTOperationsDialog::renderTransaction(const PartiallySignedTransaction
217234
}
218235

219236
size_t num_unsigned = CountPSBTUnsignedInputs(psbtx);
237+
const size_t num_partial_sigs{psbtx.inputs.at(0).partial_sigs.size()};
238+
const bool all_inputs_n_partial_sigs_equal{std::all_of(psbtx.inputs.begin(), psbtx.inputs.end(),
239+
[&](const PSBTInput& input) { return num_partial_sigs == input.partial_sigs.size(); })};
240+
220241
if (num_unsigned > 0) {
221242
tx_description.append("<br><br>");
222243
tx_description.append(tr("Transaction has %1 unsigned inputs.").arg(QString::number(num_unsigned)));
244+
if (all_inputs_n_partial_sigs_equal && num_partial_sigs > 0) {
245+
tx_description.append(" ");
246+
tx_description.append(tr("Each input has %1 partial signatures.").arg(QString::number(num_partial_sigs)));
247+
}
223248
}
224249

225250
return tx_description;

0 commit comments

Comments
 (0)