Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion buidl/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions buidl/test/test_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down