Repository navigation
Conversation
A P2SH redeem script is pushed in the scriptSig, where a push is limited to 520 bytes, so an output paying to a longer one cannot be spent. Bitcoin Core rejects sh(multi()) and sh(sortedmulti()) beyond it: 15 compressed keys (513 bytes) are accepted, 16 (547 bytes) are not. Check the compiled script of every sh() descriptor without wsh. The length is taken from compile(), because len() counts every key as 34 bytes and so underestimates uncompressed ones.
Collaborator
|
Code looks good at 169caad: One thing to fix before merging:
CI only runs pytest, so this doesn't show up there. A plain loop and |
The tests/unittest.py shim has no subTest or assertLessEqual. Use a plain loop and assertTrue instead, and hexlify in place of bytes.hex(), as the rest of the code that runs on MicroPython does.
Author
|
Fixed in 1778faa as suggested. |
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Descriptoracceptssh(multi(...))andsh(sortedmulti(...))with 16 or more compressed keys. The redeem script is then 547 bytes or more, over the 520-byte push limit of the scriptSig, so the output cannot be spent. Bitcoin Core rejects it ("P2SH script is too large"); 15 compressed keys (513 bytes) are still accepted.This checks the compiled script of any
sh()descriptor withoutwsh, with the same limit. The length comes fromcompile(), sincelen()counts every key as 34 bytes and underestimates uncompressed ones. Tests covermultiandsortedmultiat the boundary, with 15 and 16 compressed keys and 7 and 8 uncompressed ones, and check thatwsh()andsh(wsh())still accept the compressed cases. I compared thesh()cases with Bitcoin Core v31.1.0getdescriptorinfo, before and after.