New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"PSBT Operations" dialog #18027
Merged
Merged
"PSBT Operations" dialog #18027
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9e7b23b
Improve TransactionErrorString messages.
gwillen 5dd0c03
FillPSBT: report number of inputs signed (or would sign)
gwillen a6cb0b0
[gui] PSBT Operations Dialog (sign & broadcast)
gwillen 11a0ffb
[gui] Load PSBT from clipboard
gwillen 931dd47
Make lint-spelling.py happy
gwillen File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -585,8 +585,11 @@ SigningResult LegacyScriptPubKeyMan::SignMessage(const std::string& message, con | |
return SigningResult::SIGNING_FAILED; | ||
} | ||
|
||
TransactionError LegacyScriptPubKeyMan::FillPSBT(PartiallySignedTransaction& psbtx, int sighash_type, bool sign, bool bip32derivs) const | ||
TransactionError LegacyScriptPubKeyMan::FillPSBT(PartiallySignedTransaction& psbtx, int sighash_type, bool sign, bool bip32derivs, int* n_signed) const | ||
{ | ||
if (n_signed) { | ||
*n_signed = 0; | ||
} | ||
for (unsigned int i = 0; i < psbtx.tx->vin.size(); ++i) { | ||
const CTxIn& txin = psbtx.tx->vin[i]; | ||
PSBTInput& input = psbtx.inputs.at(i); | ||
|
@@ -617,6 +620,14 @@ TransactionError LegacyScriptPubKeyMan::FillPSBT(PartiallySignedTransaction& psb | |
SignatureData sigdata; | ||
input.FillSignatureData(sigdata); | ||
SignPSBTInput(HidingSigningProvider(this, !sign, !bip32derivs), psbtx, i, sighash_type); | ||
|
||
bool signed_one = PSBTInputSigned(input); | ||
if (n_signed && (signed_one || !sign)) { | ||
// If sign is false, we assume that we _could_ sign if we get here. This | ||
// will never have false negatives; it is hard to tell under what i | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: s/what i/what/ here and at line 2136 below |
||
// circumstances it could have false positives. | ||
(*n_signed)++; | ||
} | ||
} | ||
|
||
// Fill in the bip32 keypaths and redeemscripts for the outputs so that hardware wallets can identify change | ||
|
@@ -2064,8 +2075,11 @@ SigningResult DescriptorScriptPubKeyMan::SignMessage(const std::string& message, | |
return SigningResult::OK; | ||
} | ||
|
||
TransactionError DescriptorScriptPubKeyMan::FillPSBT(PartiallySignedTransaction& psbtx, int sighash_type, bool sign, bool bip32derivs) const | ||
TransactionError DescriptorScriptPubKeyMan::FillPSBT(PartiallySignedTransaction& psbtx, int sighash_type, bool sign, bool bip32derivs, int* n_signed) const | ||
{ | ||
if (n_signed) { | ||
*n_signed = 0; | ||
} | ||
for (unsigned int i = 0; i < psbtx.tx->vin.size(); ++i) { | ||
const CTxIn& txin = psbtx.tx->vin[i]; | ||
PSBTInput& input = psbtx.inputs.at(i); | ||
|
@@ -2117,6 +2131,14 @@ TransactionError DescriptorScriptPubKeyMan::FillPSBT(PartiallySignedTransaction& | |
} | ||
|
||
SignPSBTInput(HidingSigningProvider(keys.get(), !sign, !bip32derivs), psbtx, i, sighash_type); | ||
|
||
bool signed_one = PSBTInputSigned(input); | ||
if (n_signed && (signed_one || !sign)) { | ||
// If sign is false, we assume that we _could_ sign if we get here. This | ||
// will never have false negatives; it is hard to tell under what i | ||
// circumstances it could have false positives. | ||
(*n_signed)++; | ||
} | ||
} | ||
|
||
// Fill in the bip32 keypaths and redeemscripts for the outputs so that hardware wallets can identify change | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intent is to indicate whether signing happened, or whether we could sign. But this is really checking whether we could finalize, which may include signing. For instance, this wouldn't work if the input were multisig.
But that might be ok for this PR.
To reduce code duplication, maybe this should go inside
SignPSBTInput
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm very interested in a conversation about refactoring some of this stuff. Ok to save for another PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I am interested both in (1) reducing code duplication and (2) working out more precisely whether we can sign something, which I found to be very difficult to actually compute, and I definitely recognize this as a conservative approximation.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep