def test_sequence(self):
     coin = coins.by_name(self.tx.coin_name)
     bip143 = Bitcoin(self.tx, None, coin, BasicApprover(self.tx, coin))
     bip143.hash143_add_input(self.inp1)
     bip143.hash143_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_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 = Bitcoin(self.tx, None, coin)
        bip143.hash143_add_input(self.inp1)
        bip143.hash143_add_input(self.inp2)

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

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

        # test data public key hash
        # only for input 2 - input 1 is not segwit
        result = bip143.hash143_preimage_hash(self.inp2, [node.public_key()],
                                              1)
        self.assertEqual(
            hexlify(result),
            b'2fa3f1351618b2532228d7182d3221d95c21fd3d496e7e22e9ded873cf022a8b'
        )
 def test_prevouts(self):
     coin = coins.by_name(self.tx.coin_name)
     bip143 = Bitcoin(self.tx, None, coin, BasicApprover(self.tx, coin))
     bip143.hash143_add_input(self.inp1)
     bip143.hash143_add_input(self.inp2)
     prevouts_hash = get_tx_hash(bip143.h_prevouts, double=coin.sign_hash_double)
     self.assertEqual(hexlify(prevouts_hash), b'96b827c8483d4e9b96712b6713a7b68d6e8003a781feba36c31143470b4efd37')
 def test_bip143_sequence(self):
     coin = coins.by_name(self.tx.coin_name)
     bip143 = Bitcoin(self.tx, None, coin)
     bip143.hash143_add_input(self.inp1)
     sequence_hash = get_tx_hash(bip143.h_sequence,
                                 double=coin.sign_hash_double)
     self.assertEqual(
         hexlify(sequence_hash),
         b'18606b350cd8bf565266bc352f0caddcf01e8fa789dd8a15386327cf8cabe198'
     )
 def test_bip143_prevouts(self):
     coin = coins.by_name(self.tx.coin_name)
     bip143 = Bitcoin(self.tx, None, coin)
     bip143.hash143_add_input(self.inp1)
     prevouts_hash = get_tx_hash(bip143.h_prevouts,
                                 double=coin.sign_hash_double)
     self.assertEqual(
         hexlify(prevouts_hash),
         b'b0287b4a252ac05af83d2dcef00ba313af78a3e9c329afa216eb3aa2a7b4613a'
     )
Exemple #6
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 = Bitcoin(self.tx, None, coin)
        bip143.hash143_add_input(self.inp1)
        for txo in [self.out1, self.out2]:
            txo_bin = TxOutputBinType()
            txo_bin.amount = txo.amount
            script_pubkey = output_derive_script(txo.address, coin)
            bip143.hash143_add_output(txo_bin, script_pubkey)

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

        # test data public key hash
        result = bip143.hash143_preimage_hash(self.inp1, [node.public_key()], 1)
        self.assertEqual(hexlify(result), b'6e28aca7041720995d4acf59bbda64eef5d6f23723d23f2e994757546674bbd9')
    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 = Bitcoin(self.tx, None, coin)
        bip143.hash143_add_input(self.inp1)
        for txo in [self.out1, self.out2]:
            txo_bin = TxOutputBinType()
            txo_bin.amount = txo.amount
            script_pubkey = output_derive_script(txo, coin)
            bip143.hash143_add_output(txo_bin, script_pubkey)

        # test data public key hash
        result = bip143.hash143_preimage_hash(
            self.inp1, unhexlify('79091972186c449eb1ded22b78e40d009bdf0089'))
        self.assertEqual(
            hexlify(result),
            b'64f3b0f4dd2bb3aa1ce8566d220cc74dda9df97d8490cc81d89d735c92e59fb6'
        )
    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 = Bitcoin(self.tx, None, coin)
        bip143.hash143_add_input(self.inp1)
        bip143.hash143_add_input(self.inp2)

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

        # test data public key hash
        # only for input 2 - input 1 is not segwit
        result = bip143.hash143_preimage_hash(
            self.inp2, unhexlify('1d0f172a0ecb48aee1be1f2687d2963ae33f71a1'))
        self.assertEqual(
            hexlify(result),
            b'c37af31116d1b27caf68aae9e3ac82f1477929014d5b917657d0eb49478cb670'
        )