diff --git a/buidl/script.py b/buidl/script.py index 0952b1e..a6c9e48 100644 --- a/buidl/script.py +++ b/buidl/script.py @@ -131,7 +131,7 @@ def raw_serialize(self): # get the length in bytes length = len(command) # for large lengths, we have to use a pushdata op code - if length < 75: + if length <= 75: # turn the length into a single byte integer result += int_to_byte(length) elif length > 75 and length < 0x100: diff --git a/buidl/test/test_script.py b/buidl/test/test_script.py index c0c8de4..f08383a 100644 --- a/buidl/test/test_script.py +++ b/buidl/test/test_script.py @@ -38,6 +38,13 @@ def test_serialize(self): script_pubkey = BytesIO(bytes.fromhex(want)) script = Script.parse(script_pubkey) self.assertEqual(script.serialize().hex(), want) + + # Added to test scripts with length 75 bytes are being serialized + def test_serialize_elem_75(self): + want = "4d6a4b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + test_element_75_bytes = b'\x00' * 75 + test_script = Script([0x6a, test_element_75_bytes]) + self.assertEqual(test_script.serialize().hex(), want) class P2PKHScriptPubKeyTest(TestCase):