def test_scripthash_to_address_with_alternative_version(self): default_address_version = Helper.ADDRESS_VERSION Helper.ADDRESS_VERSION = 42 scripthash = binascii.unhexlify( '42112378ffa32c4c65d513aa350689dff6381154') expected_address = 'J1DfV2jS511SMtP6dH5ckr3Nwf26kbFx7s' address = Helper.scripthash_to_address(scripthash) self.assertEqual(address, expected_address) Helper.ADDRESS_VERSION = default_address_version
def test_publickey_to_redeemscript_to_scripthash_to_address(self): # NEP 2 testvector expected_redeemscript = binascii.unhexlify( '21026241e7e26b38bb7154b8ad49458b97fb1c4797443dc921c5ca5774f511a2bbfcac' ) expected_scripthash = binascii.unhexlify( '79ecf967a02f9bdbd147fc97b18efd7877d27f78') expected_address = 'AStZHy8E6StCqYQbzMqi4poH7YNDHQKxvt' priv_key = KeyPair.PrivateKeyFromWIF( 'L44B5gGEpqEDRS9vVPz7QT35jcBG2r3CZwSwQ4fCewXAhAhqGVpP') kp = KeyPair(priv_key=priv_key) pub_bytes = kp.PublicKey.encode_point(True) redeemscript = Helper.pubkey_to_redeem(pub_bytes) scripthash = Helper.redeem_to_scripthash(redeemscript) address = Helper.scripthash_to_address(scripthash) self.assertEqual(redeemscript, expected_redeemscript) self.assertEqual(scripthash, expected_scripthash) self.assertEqual(address, expected_address)