-
Notifications
You must be signed in to change notification settings - Fork 37.7k
psbt: handle unspendable psbts #17524
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
Conversation
Invalid PSBTs need to be re-created, so the next role is the Creator (new PSBTRole). Additionally, we need to know what went wrong so an error field was added to PSBTAnalysis. A PSBTAnalysis indicating invalid will have empty everything, next will be set to PSBTRole::CREATOR, and an error message.
Concept ACK Thanks for fixing this! |
Concept ACK |
Note to reviewers: This is the issue (#17149 (comment)) fixed by this PR:
|
@@ -416,5 +416,10 @@ def test_psbt_input_keys(psbt_input, keys): | |||
analyzed = self.nodes[0].analyzepsbt(signed) | |||
assert analyzed['inputs'][0]['has_utxo'] and analyzed['inputs'][0]['is_final'] and analyzed['next'] == 'extractor' | |||
|
|||
self.log.info("PSBT spending unspendable outputs should have error message and Creator as next") | |||
analysis = self.nodes[0].analyzepsbt('cHNidP8BAJoCAAAAAljoeiG1ba8MI76OcHBFbDNvfLqlyHV5JPVFiHuyq911AAAAAAD/////g40EJ9DsZQpoqka7CwmK6kQiwHGyyng1Kgd5WdB86h0BAAAAAP////8CcKrwCAAAAAAWAEHYXCtx0AYLCcmIauuBXlCZHdoSTQDh9QUAAAAAFv8/wADXYP/7//////8JxOh0LR2HAI8AAAAAAAEBIADC6wsAAAAAF2oUt/X69ELjeX2nTof+fZ10l+OyAokDAQcJAwEHEAABAACAAAEBIADC6wsAAAAAF2oUt/X69ELjeX2nTof+fZ10l+OyAokDAQcJAwEHENkMak8AAAAA') |
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.
damnit you should have warned me this crashes Core, lol
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.
"final_scriptSig": {
"asm": "1050369 0 0 0 OP_LEFT",
"hex": "030107100001000080"
}
why does this PSBT have scriptsigs for OP_RETURN inputs? Can't this PSBT be generated dynamically for better readability? Even if not, we should assert some things using decodepsbt
to make sure we know the scriptpubkeys.
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 PSBT was created by a coverage-guided fuzzer using the fuzzing harness that I added in PR #17136 ("tests: Add fuzzing harness for various PSBT related functions"). The only post-processing done was a test-case minimisation run :)
@practicalswift 2 minutes too late bro 😂 |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
ACK 773d457 The new This should be back-ported. |
The removal of the input field in case of error would break the API, wouldn't be better to push an empty array instead ? |
I don't think this really breaks the api since this error condition would cause a crash rather than return any sort of result previously. |
After some thought ACK 773d457 |
773d457 Mark PSBTs spending unspendable outputs as invalid in analysis (Andrew Chow) 638e40c Have a PSBTAnalysis state that indicates invalid PSBT (Andrew Chow) Pull request description: When analyzing an unspendable PSBT, report that it is unspendable and exit analysis early. ACKs for top commit: Sjors: ACK 773d457 instagibbs: After some thought ACK 773d457 Tree-SHA512: 99b0cb2fa1ea37593fc65a20effe881639d69ddeeecf5197bc87bc7f2220cbeb40f1d429d517e4d27f2e9fb563a00cd845d2b4b1ce05246a75a6cb56fb9b0ba5
773d457 Mark PSBTs spending unspendable outputs as invalid in analysis (Andrew Chow) 638e40c Have a PSBTAnalysis state that indicates invalid PSBT (Andrew Chow) Pull request description: When analyzing an unspendable PSBT, report that it is unspendable and exit analysis early. ACKs for top commit: Sjors: ACK 773d457 instagibbs: After some thought ACK bitcoin@773d457 Tree-SHA512: 99b0cb2fa1ea37593fc65a20effe881639d69ddeeecf5197bc87bc7f2220cbeb40f1d429d517e4d27f2e9fb563a00cd845d2b4b1ce05246a75a6cb56fb9b0ba5
7e8b4de rpc: add missing newline in analyzepsbt rpcresult (Jon Atack) Pull request description: follow-up to 638e40c in #17524 before ``` "error" : "error" (string) Error message if there is one} ``` after ``` "error" : "error" (string) Error message if there is one } ``` ACKs for top commit: practicalswift: ACK 7e8b4de promag: ACK 7e8b4de. emilengler: ACK 7e8b4de Tree-SHA512: 4cdd365e39d15b7925ea277b7ff3e9bfdc22f5845aa41ca547343b4dabdf319579843a1c7f11fb0edd6abbc31bae2ec96236b83e84f8872bd662848723725e4c
Invalid PSBTs need to be re-created, so the next role is the Creator (new PSBTRole). Additionally, we need to know what went wrong so an error field was added to PSBTAnalysis. A PSBTAnalysis indicating invalid will have empty everything, next will be set to PSBTRole::CREATOR, and an error message. Github-Pull: bitcoin#17524 Rebased-From: 638e40c
Github-Pull: bitcoin#17524 Rebased-From: 773d457
ca5f8de Mark PSBTs spending unspendable outputs as invalid in analysis (Andrew Chow) 5515833 Have a PSBTAnalysis state that indicates invalid PSBT (Andrew Chow) Pull request description: Backport of #17524 ACKs for top commit: achow101: ACK ca5f8de Tree-SHA512: b5f2b951beb9477ac3176a0aade845654d2108ca3a9fbc72097ba4b4797df5419053d6b489bbaa03be08cb8cfdc37a83db8b7642ffa52d42b7aa8ea14aff39cc
- [0.19] wallet: Reset reused transactions cache bitcoin#18083 - 0.19: Backports bitcoin#17792 - psbt: handle unspendable psbts bitcoin#17524 - qt: Fix comparison function signature bitcoin#17634 - psbt: check that various indexes and amounts are within bounds bitcoin#17156 - [0.19] psbt: check that various indexes and amounts are within bounds bitcoin#18079 - [0.19] Final backports for 0.19.1 bitcoin#17988 - Bug: IsUsedDestination shouldn't use key id as script id for ScriptHash bitcoin#17924 - qt: Fix deprecated QCharRef usage bitcoin#18101 - gui: Throttle GUI update pace when -reindex bitcoin#18121 - gui: Fix race in WalletModel::pollBalanceChanged bitcoin#18123 - gui: Fix unintialized WalletView::progressDialog bitcoin#18062 - Bugfix: GUI: Hide the HD/encrypt icons earlier so they get re-shown if another wallet is open bitcoin#18007 - bug-fix macos: give free bytes to F_PREALLOCATE bitcoin#17887 - test: add missing #include to fix compiler errors bitcoin#17980 - zmq: Fix due to invalid argument and multiple notifiers bitcoin#17445
Summary: * Have a PSBTAnalysis state that indicates invalid PSBT Invalid PSBTs need to be re-created, so the next role is the Creator (new PSBTRole). Additionally, we need to know what went wrong so an error field was added to PSBTAnalysis. A PSBTAnalysis indicating invalid will have empty everything, next will be set to PSBTRole::CREATOR, and an error message. * Mark PSBTs spending unspendable outputs as invalid in analysis This is a backport of Core [[bitcoin/bitcoin#17524 | PR17524]] Test Plan: ninja all check-all Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D8065
773d457 Mark PSBTs spending unspendable outputs as invalid in analysis (Andrew Chow) 638e40c Have a PSBTAnalysis state that indicates invalid PSBT (Andrew Chow) Pull request description: When analyzing an unspendable PSBT, report that it is unspendable and exit analysis early. ACKs for top commit: Sjors: ACK 773d457 instagibbs: After some thought ACK bitcoin@773d457 Tree-SHA512: 99b0cb2fa1ea37593fc65a20effe881639d69ddeeecf5197bc87bc7f2220cbeb40f1d429d517e4d27f2e9fb563a00cd845d2b4b1ce05246a75a6cb56fb9b0ba5
When analyzing an unspendable PSBT, report that it is unspendable and exit analysis early.