Skip to content

Commit

Permalink
add witness_v1 output test
Browse files Browse the repository at this point in the history
  • Loading branch information
Atif Nazir committed Sep 27, 2021
1 parent 6026b18 commit c767821
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions block_io/bitcoinutils_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ def get_output_script(address):
output_script = Script(['OP_DUP', 'OP_HASH160', address_hash160, 'OP_EQUALVERIFY', 'OP_CHECKSIG'])
else:
raise Exception("Invalid address provided")
elif decoded_bech32[0] == 0:
# only support witness v0 addresses for now
# it's a bech32 address
elif (decoded_bech32[0] == 0 or decoded_bech32[0] == 1):
# only support witness v0 and witness v1 addresses for now
# it's a bech32/bech32m address
output_script = Script(["OP_" + str(decoded_bech32[0]), hexlify(bytearray(decoded_bech32[1]))])
else:
raise Exception("Unsupported address provided")
Expand Down
10 changes: 10 additions & 0 deletions tests/test_blockio_prepare_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,13 @@ def test_prepare_transaction(self):

self.assertDictEqual(create_and_sign_transaction_response, response)

def test_prepare_transaction_witness_v1_output(self):
# WITNESS_V1 output

prepare_transaction_response = self.load_json_file("data/json/prepare_transaction_response_witness_v1_output.json")
create_and_sign_transaction_response = self.load_json_file("data/json/create_and_sign_transaction_response_witness_v1_output.json")

response = self.blockio.create_and_sign_transaction(prepare_transaction_response)

self.assertDictEqual(create_and_sign_transaction_response, response)

0 comments on commit c767821

Please sign in to comment.