-
Notifications
You must be signed in to change notification settings - Fork 27
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
RedeemScript parse bug #123
Comments
@jimmysong any thoughts? |
The original example is strange/nonstandard, this one is worse:
However,
Note that this address DOES NOT match the bitcoin core address: You can also verify this with caravan:
|
I'm not sure I understand what the issue is. Is it the front byte that's the problem? What's the hash preimage that gives the p2sh address that buidl gives vs the one that core uses? |
buidl (on current main branch) gives
bitcoin core returns
Does that make sense? Definitely seems like a buidl issue that this doesn't match. |
If I work backwards using the data from bitcoin core, I can create a Redeem Script that is very close to the correct one from bitcoin core, but incorrectly prepends a
If I then take this RedeemScript with two extra chars, I can successfully call
|
And just to further confirm, if you parse this incorrect
|
the length in bytes of a standard 2-of-3 multisig p2sh redeemscript is ... a valid opcode heh
afaict |
h/t @roshii ^ |
TLDR: the confusion comes from the method's name, there is no bug, implementation is correct It's a bit more tricky than that: for serializing/parsing transaction, script must be prefixed with its length in order to determine what belongs to the script. The name of the method may be confusing as one expect the script and only the script to be serialized when calling named method. Imho and to avoid confusion, the length prefix should be added when constructing a transaction. The |
From bitcoin core v0.22:
However, in the test case we parse this hex to get a testnet address of
2MxEZNps15dAnGX5XaVwZWgoDvjvsDE5XSx
, which is not found in the bitcoin core output.The text was updated successfully, but these errors were encountered: