Skip to content

Commit c767821

Browse files
author
Atif Nazir
committed
add witness_v1 output test
1 parent 6026b18 commit c767821

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

block_io/bitcoinutils_patches.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ def get_output_script(address):
101101
output_script = Script(['OP_DUP', 'OP_HASH160', address_hash160, 'OP_EQUALVERIFY', 'OP_CHECKSIG'])
102102
else:
103103
raise Exception("Invalid address provided")
104-
elif decoded_bech32[0] == 0:
105-
# only support witness v0 addresses for now
106-
# it's a bech32 address
104+
elif (decoded_bech32[0] == 0 or decoded_bech32[0] == 1):
105+
# only support witness v0 and witness v1 addresses for now
106+
# it's a bech32/bech32m address
107107
output_script = Script(["OP_" + str(decoded_bech32[0]), hexlify(bytearray(decoded_bech32[1]))])
108108
else:
109109
raise Exception("Unsupported address provided")

tests/test_blockio_prepare_transactions.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,13 @@ def test_prepare_transaction(self):
161161

162162
self.assertDictEqual(create_and_sign_transaction_response, response)
163163

164+
def test_prepare_transaction_witness_v1_output(self):
165+
# WITNESS_V1 output
166+
167+
prepare_transaction_response = self.load_json_file("data/json/prepare_transaction_response_witness_v1_output.json")
168+
create_and_sign_transaction_response = self.load_json_file("data/json/create_and_sign_transaction_response_witness_v1_output.json")
169+
170+
response = self.blockio.create_and_sign_transaction(prepare_transaction_response)
171+
172+
self.assertDictEqual(create_and_sign_transaction_response, response)
173+

0 commit comments

Comments
 (0)