|
|
|
@ -2,7 +2,7 @@ from common import *
|
|
|
|
|
|
|
|
|
|
from apps.bitcoin.common import SIGHASH_ALL
|
|
|
|
|
from apps.bitcoin.scripts import output_derive_script
|
|
|
|
|
from apps.bitcoin.sign_tx.bitcoin import Hash143
|
|
|
|
|
from apps.bitcoin.sign_tx.bitcoin import Bip143Hash
|
|
|
|
|
from apps.bitcoin.writers import get_tx_hash
|
|
|
|
|
from apps.common import coins
|
|
|
|
|
from apps.common.keychain import Keychain
|
|
|
|
@ -41,14 +41,14 @@ class TestSegwitBip143(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
def test_bip143_prevouts(self):
|
|
|
|
|
coin = coins.by_name(self.tx.coin_name)
|
|
|
|
|
bip143 = Hash143()
|
|
|
|
|
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_bip143_sequence(self):
|
|
|
|
|
coin = coins.by_name(self.tx.coin_name)
|
|
|
|
|
bip143 = Hash143()
|
|
|
|
|
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')
|
|
|
|
@ -56,7 +56,7 @@ class TestSegwitBip143(unittest.TestCase):
|
|
|
|
|
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 = Hash143()
|
|
|
|
|
bip143 = Bip143Hash()
|
|
|
|
|
|
|
|
|
|
for txo in [self.out1, self.out2]:
|
|
|
|
|
script_pubkey = output_derive_script(txo.address, coin)
|
|
|
|
@ -69,7 +69,7 @@ class TestSegwitBip143(unittest.TestCase):
|
|
|
|
|
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 = Hash143()
|
|
|
|
|
bip143 = Bip143Hash()
|
|
|
|
|
bip143.add_input(self.inp1)
|
|
|
|
|
for txo in [self.out1, self.out2]:
|
|
|
|
|
script_pubkey = output_derive_script(txo.address, coin)
|
|
|
|
|