buidl-bitcoin / buidl-python

python3 bitcoin library with no dependencies and extensive test coverage
https://pypi.org/project/buidl/
MIT License
83 stars 26 forks source link

WIP: fix p2sh redeemscript parsing #124

Closed mflaxman closed 2 years ago

mflaxman commented 2 years ago

This PR makes it possible to accurately parse() a p2sh redeemscript, but you have to opt into the new parse_hex() method.

It's the fewest lines of code to make this change, but it feels a little hackey. Also, moving the existing codebase over to use the new parsing logic will throw a ton of errors.

Any thoughts @jimmysong @dhruvbansal?

This is a proposed fix for https://github.com/buidl-bitcoin/buidl-python/issues/123

mflaxman commented 2 years ago

Update: I thought I might be able to read the first byte and see if it was OP_1-OP_15 and then use that to infer is_p2sh_multisig. But when I tried that it threw other errors. I think it's possible for a non RedeemScript to start with those same bytes.

The current PR still feels ugly, but I don't have a better solution.

jimmysong commented 2 years ago

added a PR for this PR in #126