def test_preimage_testdata(self):

        seed = bip39.seed(
            'alcohol woman abuse must during monitor noble actual mixed trade anger aisle',
            '')
        coin = coins.by_name(self.tx.coin_name)
        bip143 = Bip143Hash()
        bip143.add_input(self.inp1)
        bip143.add_input(self.inp2)

        for txo in [self.out1, self.out2]:
            script_pubkey = output_derive_script(txo.address, coin)
            txo_bin = PrevOutput(amount=txo.amount,
                                 script_pubkey=script_pubkey)
            bip143.add_output(txo_bin, script_pubkey)

        keychain = Keychain(seed, coin.curve_name, [AlwaysMatchingSchema])
        node = keychain.derive(self.inp2.address_n)

        # test data public key hash
        # only for input 2 - input 1 is not segwit
        result = bip143.preimage_hash(self.inp2, [node.public_key()], 1,
                                      self.tx, coin, SIGHASH_ALL)
        self.assertEqual(
            hexlify(result),
            b'2fa3f1351618b2532228d7182d3221d95c21fd3d496e7e22e9ded873cf022a8b'
        )
Beispiel #2
0
 def test_bip143_sequence(self):
     coin = coins.by_name(self.tx.coin_name)
     bip143 = Bip143Hash()
     bip143.add_input(self.inp1)
     sequence_hash = get_tx_hash(bip143.h_sequence,
                                 double=coin.sign_hash_double)
     self.assertEqual(
         hexlify(sequence_hash),
         b'18606b350cd8bf565266bc352f0caddcf01e8fa789dd8a15386327cf8cabe198'
     )
Beispiel #3
0
 def test_bip143_prevouts(self):
     coin = coins.by_name(self.tx.coin_name)
     bip143 = Bip143Hash()
     bip143.add_input(self.inp1)
     prevouts_hash = get_tx_hash(bip143.h_prevouts,
                                 double=coin.sign_hash_double)
     self.assertEqual(
         hexlify(prevouts_hash),
         b'b0287b4a252ac05af83d2dcef00ba313af78a3e9c329afa216eb3aa2a7b4613a'
     )
 def test_sequence(self):
     coin = coins.by_name(self.tx.coin_name)
     bip143 = Bip143Hash()
     bip143.add_input(self.inp1)
     bip143.add_input(self.inp2)
     sequence_hash = get_tx_hash(bip143.h_sequence,
                                 double=coin.sign_hash_double)
     self.assertEqual(
         hexlify(sequence_hash),
         b'52b0a642eea2fb7ae638c36f6252b6750293dbe574a806984b8e4d8548339a3b'
     )
 def test_prevouts(self):
     coin = coins.by_name(self.tx.coin_name)
     bip143 = Bip143Hash()
     bip143.add_input(self.inp1)
     bip143.add_input(self.inp2)
     prevouts_hash = get_tx_hash(bip143.h_prevouts,
                                 double=coin.sign_hash_double)
     self.assertEqual(
         hexlify(prevouts_hash),
         b'96b827c8483d4e9b96712b6713a7b68d6e8003a781feba36c31143470b4efd37'
     )
Beispiel #6
0
    def test_bip143_outputs(self):
        seed = bip39.seed('alcohol woman abuse must during monitor noble actual mixed trade anger aisle', '')
        coin = coins.by_name(self.tx.coin_name)
        bip143 = Bip143Hash()

        for txo in [self.out1, self.out2]:
            script_pubkey = output_derive_script(txo.address, coin)
            txo_bin = PrevOutput(amount=txo.amount, script_pubkey=script_pubkey)
            bip143.add_output(txo_bin, script_pubkey)

        outputs_hash = get_tx_hash(bip143.h_outputs, double=coin.sign_hash_double)
        self.assertEqual(hexlify(outputs_hash), b'de984f44532e2173ca0d64314fcefe6d30da6f8cf27bafa706da61df8a226c83')
Beispiel #7
0
    def test_bip143_preimage_testdata(self):
        seed = bip39.seed('alcohol woman abuse must during monitor noble actual mixed trade anger aisle', '')
        coin = coins.by_name(self.tx.coin_name)
        bip143 = Bip143Hash()
        bip143.add_input(self.inp1)
        for txo in [self.out1, self.out2]:
            script_pubkey = output_derive_script(txo.address, coin)
            txo_bin = PrevOutput(amount=txo.amount, script_pubkey=script_pubkey)
            bip143.add_output(txo_bin, script_pubkey)

        keychain = Keychain(seed, coin.curve_name, [AlwaysMatchingSchema])
        node = keychain.derive(self.inp1.address_n)

        # test data public key hash
        result = bip143.preimage_hash(self.inp1, [node.public_key()], 1, self.tx, coin, SIGHASH_ALL)
        self.assertEqual(hexlify(result), b'6e28aca7041720995d4acf59bbda64eef5d6f23723d23f2e994757546674bbd9')
    def test_outputs(self):

        seed = bip39.seed(
            'alcohol woman abuse must during monitor noble actual mixed trade anger aisle',
            '')
        coin = coins.by_name(self.tx.coin_name)
        bip143 = Bip143Hash()

        for txo in [self.out1, self.out2]:
            script_pubkey = output_derive_script(txo.address, coin)
            txo_bin = PrevOutput(amount=txo.amount,
                                 script_pubkey=script_pubkey)
            bip143.add_output(txo_bin, script_pubkey)

        outputs_hash = get_tx_hash(bip143.h_outputs,
                                   double=coin.sign_hash_double)
        self.assertEqual(
            hexlify(outputs_hash),
            b'863ef3e1a92afbfdb97f31ad0fc7683ee943e9abcf2501590ff8f6551f47e5e5'
        )