def test_zip243(self): coin = coins.by_name("Zcash") for v in self.VECTORS: tx = SignTx( coin_name="Zcash", inputs_count=len(v["inputs"]), outputs_count=len(v["outputs"]), version=v["version"], lock_time=v["lock_time"], expiry=v["expiry"], overwintered=(v["version"] >= 3), version_group_id=v["version_group_id"], ) zip243 = Zip243() for i in v["inputs"]: txi = TxInputType() txi.amount = i["amount"] txi.prev_hash = unhexlify(i["prevout"][0]) txi.prev_index = i["prevout"][1] txi.script_type = i["script_type"] txi.sequence = i["sequence"] zip243.add_prevouts(txi) zip243.add_sequence(txi) for o in v["outputs"]: txo = TxOutputBinType() txo.amount = o["amount"] txo.script_pubkey = unhexlify(o["script_pubkey"]) zip243.add_output(txo) self.assertEqual(hexlify(zip243.get_prevouts_hash()), v["prevouts_hash"]) self.assertEqual(hexlify(zip243.get_sequence_hash()), v["sequence_hash"]) self.assertEqual(hexlify(zip243.get_outputs_hash()), v["outputs_hash"]) self.assertEqual( hexlify( zip243.preimage_hash(coin, tx, txi, unhexlify(i["pubkeyhash"]), v["hash_type"])), v["preimage_hash"], )
def test_zip143(self): coin = coins.by_name("Zcash") for v in self.VECTORS: tx = SignTx( coin_name="Zcash", inputs_count=len(v["inputs"]), outputs_count=len(v["outputs"]), version=v["version"], lock_time=v["lock_time"], expiry=v["expiry"], version_group_id=v["version_group_id"], ) zip143 = Overwintered(tx, None, coin) for i in v["inputs"]: txi = TxInputType() txi.amount = i["amount"] txi.prev_hash = unhexlify(i["prevout"][0]) txi.prev_index = i["prevout"][1] txi.script_type = i["script_type"] txi.sequence = i["sequence"] zip143.hash143_add_input(txi) for o in v["outputs"]: txo = TxOutputBinType() txo.amount = o["amount"] txo.script_pubkey = unhexlify(o["script_pubkey"]) zip143.hash143_add_output(txo, txo.script_pubkey) self.assertEqual(hexlify(get_tx_hash(zip143.h_prevouts)), v["prevouts_hash"]) self.assertEqual(hexlify(get_tx_hash(zip143.h_sequence)), v["sequence_hash"]) self.assertEqual(hexlify(get_tx_hash(zip143.h_outputs)), v["outputs_hash"]) self.assertEqual( hexlify( zip143.hash143_preimage_hash(txi, unhexlify(i["pubkeyhash"]))), v["preimage_hash"], )