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'
        )
Пример #2
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'
        )