def test_p2sh_address_creation(self): x1_first_btc_key = bip32_public_derivation(self.wallet.master_public_keys.get("x1/"), "", "/0/0/0") x2_first_btc_key = bip32_public_derivation(self.wallet.master_public_keys.get("x2/"), "", "/0/0/0") x_pubkeys = [x1_first_btc_key, x2_first_btc_key] raw_pubkeys = map( lambda x: deserialize_xkey(x)[4], x_pubkeys ) pubkeys = map( lambda x: x.encode('hex'), raw_pubkeys ) # Compare redeem script to manually calculated one redeem_script = multisig_script(sorted(pubkeys), 2) self.assertEqual('522102ee780aa224c9fe54caff984205077b7cca08ced3188a3f3c639d83deda6b9a592103124429ddbed55593d0abea0d0d3d283eca4546e40017b2945f4666c561b494ba52ae', redeem_script) p2sh_addr = hash_160_to_bc_address( hash_160(redeem_script.decode('hex')), self.wallet.active_chain.p2sh_version ) self.assertEqual('3MqemPAHZDGLr537QBvU7i4dRFY3Xvad7X', p2sh_addr) # switch chains self._switch_chain("MZC") x1_first_mzc_key = bip32_public_derivation(self.wallet.master_public_keys.get("x1/"), "", "/13/0/0") x2_first_mzc_key = bip32_public_derivation(self.wallet.master_public_keys.get("x2/"), "", "/13/0/0") x_pubkeys = [x1_first_mzc_key, x2_first_mzc_key] raw_pubkeys = map( lambda x: deserialize_xkey(x)[4], x_pubkeys ) pubkeys = map( lambda x: x.encode('hex'), raw_pubkeys ) # Compare redeem script to manually calculated one redeem_script = multisig_script(sorted(pubkeys), 2) self.assertEqual('5221027bdb7f5c42096580442e63235434bcc9ddf9689bbeb917705cd0edf9c6e264292102919725862f59a43274443ea11d7a8e25c15147213dcb6186c24d8629d37d6d8d52ae', redeem_script) p2sh_addr = hash_160_to_bc_address( hash_160(redeem_script.decode('hex')), self.wallet.active_chain.p2sh_version ) self.assertEqual('4jjXnsGuWLH3YgnagWH12kK7HjDtsBv8SQ', p2sh_addr)
def test_p2sh_address_creation(self): x1_first_btc_key = bip32_public_derivation(self.wallet.master_public_keys.get("x1/"), "", "/0/0/0") x2_first_btc_key = bip32_public_derivation(self.wallet.master_public_keys.get("x2/"), "", "/0/0/0") x_pubkeys = [x1_first_btc_key, x2_first_btc_key] raw_pubkeys = map( lambda x: deserialize_xkey(x)[4], x_pubkeys ) pubkeys = map( lambda x: x.encode('hex'), raw_pubkeys ) # Compare redeem script to manually calculated one redeem_script = Transaction.multisig_script(sorted(pubkeys), 2) self.assertEqual('522102ee780aa224c9fe54caff984205077b7cca08ced3188a3f3c639d83deda6b9a592103124429ddbed55593d0abea0d0d3d283eca4546e40017b2945f4666c561b494ba52ae', redeem_script) p2sh_addr = hash_160_to_bc_address( hash_160(redeem_script.decode('hex')), self.wallet.active_chain.p2sh_version ) self.assertEqual('3MqemPAHZDGLr537QBvU7i4dRFY3Xvad7X', p2sh_addr) # switch chains self._switch_chain("MZC") x1_first_mzc_key = bip32_public_derivation(self.wallet.master_public_keys.get("x1/"), "", "/13/0/0") x2_first_mzc_key = bip32_public_derivation(self.wallet.master_public_keys.get("x2/"), "", "/13/0/0") x_pubkeys = [x1_first_mzc_key, x2_first_mzc_key] raw_pubkeys = map( lambda x: deserialize_xkey(x)[4], x_pubkeys ) pubkeys = map( lambda x: x.encode('hex'), raw_pubkeys ) # Compare redeem script to manually calculated one redeem_script = Transaction.multisig_script(sorted(pubkeys), 2) self.assertEqual('5221027bdb7f5c42096580442e63235434bcc9ddf9689bbeb917705cd0edf9c6e264292102919725862f59a43274443ea11d7a8e25c15147213dcb6186c24d8629d37d6d8d52ae', redeem_script) p2sh_addr = hash_160_to_bc_address( hash_160(redeem_script.decode('hex')), self.wallet.active_chain.p2sh_version ) self.assertEqual('4jjXnsGuWLH3YgnagWH12kK7HjDtsBv8SQ', p2sh_addr)
def test_redeem_script(self): acc = self.wallet.accounts["0"] x1_first_btc_key = bip32_public_derivation( self.wallet.master_public_keys.get("x1/"), "", "/0/0/0") x2_first_btc_key = bip32_public_derivation( self.wallet.master_public_keys.get("x2/"), "", "/0/0/0") x3_first_btc_key = bip32_public_derivation( self.wallet.master_public_keys.get("x3/"), "", "/0/0/0") x4_first_btc_key = bip32_public_derivation( self.wallet.master_public_keys.get("x4/"), "", "/0/0/0") x_pubkeys = [ x1_first_btc_key, x2_first_btc_key, x3_first_btc_key, x4_first_btc_key ] raw_pubkeys = map(lambda x: deserialize_xkey(x)[4], x_pubkeys) pubkeys = map(lambda x: x.encode('hex'), raw_pubkeys) # Compare redeem script to manually calculated one redeem_script = multisig_script(sorted(pubkeys), acc.multisig_m) self.assertEqual( '53210278a1a7de63493a8c8e0e7f4ebb13fd2a8144db25bb3bc2e5f44127a851a389332102ee780aa224c9fe54caff984205077b7cca08ced3188a3f3c639d83deda6b9a592103124429ddbed55593d0abea0d0d3d283eca4546e40017b2945f4666c561b494ba210312872f0aa80fa1a9bc7df77fa5be310f5441f7bfec798fe19209b04954dec8da54ae', redeem_script) p2sh_addr = hash_160_to_bc_address( hash_160(redeem_script.decode('hex')), self.wallet.active_chain.p2sh_version) self.assertEqual("32Ktuh5jGEAAJyNXQE7f1LUAcMXSfvdSzE", p2sh_addr)
def test_redeem_script(self): acc = self.wallet.accounts["0"] x1_first_btc_key = bip32_public_derivation(self.wallet.master_public_keys.get("x1/"), "", "/0/0/0") x2_first_btc_key = bip32_public_derivation(self.wallet.master_public_keys.get("x2/"), "", "/0/0/0") x3_first_btc_key = bip32_public_derivation(self.wallet.master_public_keys.get("x3/"), "", "/0/0/0") x4_first_btc_key = bip32_public_derivation(self.wallet.master_public_keys.get("x4/"), "", "/0/0/0") x_pubkeys = [x1_first_btc_key, x2_first_btc_key, x3_first_btc_key, x4_first_btc_key] raw_pubkeys = map( lambda x: deserialize_xkey(x)[4], x_pubkeys ) pubkeys = map( lambda x: x.encode('hex'), raw_pubkeys ) # Compare redeem script to manually calculated one redeem_script = multisig_script(sorted(pubkeys), acc.multisig_m) self.assertEqual('53210278a1a7de63493a8c8e0e7f4ebb13fd2a8144db25bb3bc2e5f44127a851a389332102ee780aa224c9fe54caff984205077b7cca08ced3188a3f3c639d83deda6b9a592103124429ddbed55593d0abea0d0d3d283eca4546e40017b2945f4666c561b494ba210312872f0aa80fa1a9bc7df77fa5be310f5441f7bfec798fe19209b04954dec8da54ae', redeem_script) p2sh_addr = hash_160_to_bc_address( hash_160(redeem_script.decode('hex')), self.wallet.active_chain.p2sh_version ) self.assertEqual("32Ktuh5jGEAAJyNXQE7f1LUAcMXSfvdSzE", p2sh_addr)