psbt: handle unspendable psbts #17524
pull achow101 wants to merge 2 commits into bitcoin:master from achow101:analyzepsbt-invalid changing 6 files +29 −1-
achow101 commented at 8:19 pm on November 19, 2019: memberWhen analyzing an unspendable PSBT, report that it is unspendable and exit analysis early.
-
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 773d4572a4
-
fanquake added the label PSBT on Nov 19, 2019
-
practicalswift commented at 8:23 pm on November 19, 2019: contributor
Concept ACK
Thanks for fixing this!
-
Sjors commented at 8:52 pm on November 19, 2019: memberConcept ACK
-
practicalswift commented at 9:24 pm on November 19, 2019: contributor
Note to reviewers:
This is the issue (https://github.com/bitcoin/bitcoin/issues/17149#issuecomment-552202472) fixed by this PR:
0$ bitcoind & 1$ bitcoin-cli analyzepsbt "cHNidP8BAJoCAAAAAljoeiG1ba8MI76OcHBFbDNvfLqlyHV5JPVFiHuyq911AAAAAAD/////g40EJ9DsZQpoqka7CwmK6kQiwHGyyng1Kgd5WdB86h0BAAAAAP////8CcKrwCAAAAAAWAEHYXCtx0AYLCcmIauuBXlCZHdoSTQDh9QUAAAAAFv8/wADXYP/7//////8JxOh0LR2HAI8AAAAAAAEBIADC6wsAAAAAF2oUt/X69ELjeX2nTof+fZ10l+OyAokDAQcJAwEHEAABAACAAAEBIADC6wsAAAAAF2oUt/X69ELjeX2nTof+fZ10l+OyAokDAQcJAwEHENkMak8AAAAA" 2bitcoind: consensus/tx_verify.cpp:130: unsigned int 3 GetP2SHSigOpCount(const CTransaction &, const CCoinsViewCache &): 4 Assertion `!coin.IsSpent()' failed.
-
in test/functional/rpc_psbt.py:420 in 773d4572a4
415@@ -416,5 +416,10 @@ def test_psbt_input_keys(psbt_input, keys): 416 analyzed = self.nodes[0].analyzepsbt(signed) 417 assert analyzed['inputs'][0]['has_utxo'] and analyzed['inputs'][0]['is_final'] and analyzed['next'] == 'extractor' 418 419+ self.log.info("PSBT spending unspendable outputs should have error message and Creator as next") 420+ analysis = self.nodes[0].analyzepsbt('cHNidP8BAJoCAAAAAljoeiG1ba8MI76OcHBFbDNvfLqlyHV5JPVFiHuyq911AAAAAAD/////g40EJ9DsZQpoqka7CwmK6kQiwHGyyng1Kgd5WdB86h0BAAAAAP////8CcKrwCAAAAAAWAEHYXCtx0AYLCcmIauuBXlCZHdoSTQDh9QUAAAAAFv8/wADXYP/7//////8JxOh0LR2HAI8AAAAAAAEBIADC6wsAAAAAF2oUt/X69ELjeX2nTof+fZ10l+OyAokDAQcJAwEHEAABAACAAAEBIADC6wsAAAAAF2oUt/X69ELjeX2nTof+fZ10l+OyAokDAQcJAwEHENkMak8AAAAA')
instagibbs commented at 9:25 pm on November 19, 2019:damnit you should have warned me this crashes Core, lol
instagibbs commented at 9:31 pm on November 19, 2019:0 "final_scriptSig": { 1 "asm": "1050369 0 0 0 OP_LEFT", 2 "hex": "030107100001000080" 3 }
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.
practicalswift commented at 9:38 pm on November 19, 2019: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 :)instagibbs commented at 9:26 pm on November 19, 2019: member@practicalswift 2 minutes too late bro :joy:DrahtBot commented at 10:03 pm on November 19, 2019: memberThe following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #17211 (Allow fundrawtransaction and walletcreatefundedpsbt to take external inputs by achow101)
- #17156 (psbt: check that various indexes and amounts are within bounds by achow101)
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.
Sjors commented at 10:05 am on November 20, 2019: memberACK 773d457
The new
creator
role anderror
field are release note worthy.This should be back-ported.
darosior commented at 1:30 pm on November 23, 2019: memberThe removal of the input field in case of error would break the API, wouldn’t be better to push an empty array instead ?achow101 commented at 4:58 pm on November 23, 2019: memberI don’t think this really breaks the api since this error condition would cause a crash rather than return any sort of result previously.instagibbs commented at 2:15 pm on November 25, 2019: memberAfter some thought ACK https://github.com/bitcoin/bitcoin/commit/773d4572a4864ab7b6380858d07d9579ff6dd9a2MarcoFalke referenced this in commit fae94785d9 on Dec 10, 2019MarcoFalke merged this on Dec 10, 2019MarcoFalke closed this on Dec 10, 2019
sidhujag referenced this in commit f253162790 on Dec 10, 2019MarcoFalke referenced this in commit f1d3d3430e on Dec 11, 2019luke-jr referenced this in commit 551583398b on Jan 3, 2020luke-jr referenced this in commit ca5f8deefd on Jan 3, 2020fanquake referenced this in commit febf04841f on Jan 4, 2020MarkLTZ referenced this in commit d99bc96496 on Feb 13, 2020barrystyle referenced this in commit 11c68f79bc on Feb 29, 2020barrystyle referenced this in commit c9728de7f4 on Feb 29, 2020deadalnix referenced this in commit 5a49f316c1 on Oct 23, 2020sidhujag referenced this in commit 030f3da4f4 on Nov 10, 2020MarcoFalke locked this on Dec 16, 2021
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-21 15:12 UTC
More mirrored repositories can be found on mirror.b10c.me