Skip to content

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

Open
@salmonberry7

Description

@salmonberry7

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions