Skip to content
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

Length of P2SH redeem script is incorrectly prepended prior to parsing via Script.parse #293

Open
salmonberry7 opened this issue Jan 13, 2025 · 0 comments

Comments

@salmonberry7
Copy link

salmonberry7 commented Jan 13, 2025

In Tx.verify_input in Chap. 13, the length of the redeem script is computed using int_to_little_endian(len(cmd), 1). As stated in the code comment 'prepend the length of the RedeemScript using encode_varint' in Chap. 8 it should be computed using encode_varint(len(cmd)), to be compatible with Script.parse.

According to BIP16 '520-byte limitation on serialized script size' a P2SH redeem script can have a serialized script length of up to 520 bytes. Thus the present code will cause failure for a redeem script length >= 253. For example a CHECKMULTISIG redeem script with 8 or more compressed public keys (=> length >= 3 + 8*34 = 275 bytes) will raise an OverflowError exception as int_to_little_endian fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant