1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

tests: update to use parse_path

This commit is contained in:
matejcik 2018-04-18 15:53:40 +02:00
parent d106869061
commit 579adb1871
19 changed files with 187 additions and 143 deletions

View File

@ -22,6 +22,8 @@ from hashlib import sha256
from .common import TrezorTest
from ..support import ed25519cosi, ed25519raw
from trezorlib.tools import parse_path
@pytest.mark.skip_t2
class TestCosi(TrezorTest):
@ -31,9 +33,9 @@ class TestCosi(TrezorTest):
digest = sha256(b'this is a message').digest()
c0 = self.client.cosi_commit(self.client.expand_path("10018'/0'"), digest)
c1 = self.client.cosi_commit(self.client.expand_path("10018'/1'"), digest)
c2 = self.client.cosi_commit(self.client.expand_path("10018'/2'"), digest)
c0 = self.client.cosi_commit(parse_path("10018'/0'"), digest)
c1 = self.client.cosi_commit(parse_path("10018'/1'"), digest)
c2 = self.client.cosi_commit(parse_path("10018'/2'"), digest)
assert c0.pubkey != c1.pubkey
assert c0.pubkey != c2.pubkey
@ -45,9 +47,9 @@ class TestCosi(TrezorTest):
digestb = sha256(b'this is a different message').digest()
c0b = self.client.cosi_commit(self.client.expand_path("10018'/0'"), digestb)
c1b = self.client.cosi_commit(self.client.expand_path("10018'/1'"), digestb)
c2b = self.client.cosi_commit(self.client.expand_path("10018'/2'"), digestb)
c0b = self.client.cosi_commit(parse_path("10018'/0'"), digestb)
c1b = self.client.cosi_commit(parse_path("10018'/1'"), digestb)
c2b = self.client.cosi_commit(parse_path("10018'/2'"), digestb)
assert c0.pubkey == c0b.pubkey
assert c1.pubkey == c1b.pubkey
@ -62,16 +64,16 @@ class TestCosi(TrezorTest):
digest = sha256(b'this is a message').digest()
c0 = self.client.cosi_commit(self.client.expand_path("10018'/0'"), digest)
c1 = self.client.cosi_commit(self.client.expand_path("10018'/1'"), digest)
c2 = self.client.cosi_commit(self.client.expand_path("10018'/2'"), digest)
c0 = self.client.cosi_commit(parse_path("10018'/0'"), digest)
c1 = self.client.cosi_commit(parse_path("10018'/1'"), digest)
c2 = self.client.cosi_commit(parse_path("10018'/2'"), digest)
global_pk = ed25519cosi.combine_keys([c0.pubkey, c1.pubkey, c2.pubkey])
global_R = ed25519cosi.combine_keys([c0.commitment, c1.commitment, c2.commitment])
sig0 = self.client.cosi_sign(self.client.expand_path("10018'/0'"), digest, global_R, global_pk)
sig1 = self.client.cosi_sign(self.client.expand_path("10018'/1'"), digest, global_R, global_pk)
sig2 = self.client.cosi_sign(self.client.expand_path("10018'/2'"), digest, global_R, global_pk)
sig0 = self.client.cosi_sign(parse_path("10018'/0'"), digest, global_R, global_pk)
sig1 = self.client.cosi_sign(parse_path("10018'/1'"), digest, global_R, global_pk)
sig2 = self.client.cosi_sign(parse_path("10018'/2'"), digest, global_R, global_pk)
sig = ed25519cosi.combine_sig(global_R, [sig0.signature, sig1.signature, sig2.signature])

View File

@ -22,6 +22,8 @@ from .common import TrezorTest
from ..support import ckd_public as bip32
from trezorlib import messages as proto
from trezorlib.tools import parse_path
class TestMsgGetaddress(TrezorTest):
@ -48,15 +50,15 @@ class TestMsgGetaddress(TrezorTest):
@pytest.mark.skip_t2
def test_bch(self):
self.setup_mnemonic_allallall()
assert self.client.get_address('Bcash', self.client.expand_path("44'/145'/0'/0/0")) == 'bitcoincash:qr08q88p9etk89wgv05nwlrkm4l0urz4cyl36hh9sv'
assert self.client.get_address('Bcash', self.client.expand_path("44'/145'/0'/0/1")) == 'bitcoincash:qr23ajjfd9wd73l87j642puf8cad20lfmqdgwvpat4'
assert self.client.get_address('Bcash', self.client.expand_path("44'/145'/0'/1/0")) == 'bitcoincash:qzc5q87w069lzg7g3gzx0c8dz83mn7l02scej5aluw'
assert self.client.get_address('Bcash', parse_path("44'/145'/0'/0/0")) == 'bitcoincash:qr08q88p9etk89wgv05nwlrkm4l0urz4cyl36hh9sv'
assert self.client.get_address('Bcash', parse_path("44'/145'/0'/0/1")) == 'bitcoincash:qr23ajjfd9wd73l87j642puf8cad20lfmqdgwvpat4'
assert self.client.get_address('Bcash', parse_path("44'/145'/0'/1/0")) == 'bitcoincash:qzc5q87w069lzg7g3gzx0c8dz83mn7l02scej5aluw'
@pytest.mark.skip_t2
def test_bch_multisig(self):
self.setup_mnemonic_allallall()
xpubs = []
for n in map(lambda index: self.client.get_public_node(self.client.expand_path("44'/145'/" + str(index) + "'")), range(1, 4)):
for n in map(lambda index: self.client.get_public_node(parse_path("44'/145'/" + str(index) + "'")), range(1, 4)):
xpubs.append(n.xpub)
def getmultisig(chain, nr, signatures=[b'', b'', b''], xpubs=xpubs):
@ -66,8 +68,8 @@ class TestMsgGetaddress(TrezorTest):
m=2,
)
for nr in range(1, 4):
assert self.client.get_address('Bcash', self.client.expand_path("44'/145'/" + str(nr) + "'/0/0"), show_display=(nr == 1), multisig=getmultisig(0, 0)) == 'bitcoincash:pqguz4nqq64jhr5v3kvpq4dsjrkda75hwy86gq0qzw'
assert self.client.get_address('Bcash', self.client.expand_path("44'/145'/" + str(nr) + "'/1/0"), show_display=(nr == 1), multisig=getmultisig(1, 0)) == 'bitcoincash:pp6kcpkhua7789g2vyj0qfkcux3yvje7euhyhltn0a'
assert self.client.get_address('Bcash', parse_path("44'/145'/" + str(nr) + "'/0/0"), show_display=(nr == 1), multisig=getmultisig(0, 0)) == 'bitcoincash:pqguz4nqq64jhr5v3kvpq4dsjrkda75hwy86gq0qzw'
assert self.client.get_address('Bcash', parse_path("44'/145'/" + str(nr) + "'/1/0"), show_display=(nr == 1), multisig=getmultisig(1, 0)) == 'bitcoincash:pp6kcpkhua7789g2vyj0qfkcux3yvje7euhyhltn0a'
def test_public_ckd(self):
self.setup_mnemonic_nopin_nopassphrase()

View File

@ -18,20 +18,21 @@
from .common import TrezorTest
from ..support import ckd_public as bip32
from trezorlib import messages as proto
from trezorlib.tools import parse_path
class TestMsgGetaddressSegwit(TrezorTest):
def test_show_segwit(self):
self.setup_mnemonic_allallall()
assert self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/1/0"), True, None, script_type=proto.InputScriptType.SPENDP2SHWITNESS) == '2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX'
assert self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/0/0"), False, None, script_type=proto.InputScriptType.SPENDP2SHWITNESS) == '2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp'
assert self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"), False, None, script_type=proto.InputScriptType.SPENDP2SHWITNESS) == '2N6UeBoqYEEnybg4cReFYDammpsyDw8R2Mc'
assert self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"), False, None, script_type=proto.InputScriptType.SPENDADDRESS) == 'mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q'
assert self.client.get_address("Testnet", parse_path("49'/1'/0'/1/0"), True, None, script_type=proto.InputScriptType.SPENDP2SHWITNESS) == '2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX'
assert self.client.get_address("Testnet", parse_path("49'/1'/0'/0/0"), False, None, script_type=proto.InputScriptType.SPENDP2SHWITNESS) == '2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp'
assert self.client.get_address("Testnet", parse_path("44'/1'/0'/0/0"), False, None, script_type=proto.InputScriptType.SPENDP2SHWITNESS) == '2N6UeBoqYEEnybg4cReFYDammpsyDw8R2Mc'
assert self.client.get_address("Testnet", parse_path("44'/1'/0'/0/0"), False, None, script_type=proto.InputScriptType.SPENDADDRESS) == 'mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q'
def test_show_multisig_3(self):
self.setup_mnemonic_allallall()
nodes = map(lambda index: self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)), range(1, 4))
nodes = map(lambda index: self.client.get_public_node(parse_path("999'/1'/%d'" % index)), range(1, 4))
multisig1 = proto.MultisigRedeemScriptType(
pubkeys=list(map(lambda n: proto.HDNodePathType(node=bip32.deserialize(n.xpub), address_n=[2, 0]), nodes)),
signatures=[b'', b'', b''],
@ -43,4 +44,4 @@ class TestMsgGetaddressSegwit(TrezorTest):
# m=2,
# )
for i in [1, 2, 3]:
assert self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/0" % i), False, multisig1, script_type=proto.InputScriptType.SPENDP2SHWITNESS) == '2N2MxyAfifVhb3AMagisxaj3uij8bfXqf4Y'
assert self.client.get_address("Testnet", parse_path("999'/1'/%d'/2/0" % i), False, multisig1, script_type=proto.InputScriptType.SPENDP2SHWITNESS) == '2N2MxyAfifVhb3AMagisxaj3uij8bfXqf4Y'

View File

@ -18,20 +18,21 @@
from .common import TrezorTest
from ..support import ckd_public as bip32
from trezorlib import messages as proto
from trezorlib.tools import parse_path
class TestMsgGetaddressSegwitNative(TrezorTest):
def test_show_segwit(self):
self.setup_mnemonic_allallall()
assert self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/0/0"), True, None, script_type=proto.InputScriptType.SPENDWITNESS) == 'tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s'
assert self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/1/0"), False, None, script_type=proto.InputScriptType.SPENDWITNESS) == 'tb1q694ccp5qcc0udmfwgp692u2s2hjpq5h407urtu'
assert self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"), False, None, script_type=proto.InputScriptType.SPENDWITNESS) == 'tb1q54un3q39sf7e7tlfq99d6ezys7qgc62a6rxllc'
assert self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"), False, None, script_type=proto.InputScriptType.SPENDADDRESS) == 'mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q'
assert self.client.get_address("Testnet", parse_path("49'/1'/0'/0/0"), True, None, script_type=proto.InputScriptType.SPENDWITNESS) == 'tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s'
assert self.client.get_address("Testnet", parse_path("49'/1'/0'/1/0"), False, None, script_type=proto.InputScriptType.SPENDWITNESS) == 'tb1q694ccp5qcc0udmfwgp692u2s2hjpq5h407urtu'
assert self.client.get_address("Testnet", parse_path("44'/1'/0'/0/0"), False, None, script_type=proto.InputScriptType.SPENDWITNESS) == 'tb1q54un3q39sf7e7tlfq99d6ezys7qgc62a6rxllc'
assert self.client.get_address("Testnet", parse_path("44'/1'/0'/0/0"), False, None, script_type=proto.InputScriptType.SPENDADDRESS) == 'mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q'
def test_show_multisig_3(self):
self.setup_mnemonic_allallall()
nodes = [self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)) for index in range(1, 4)]
nodes = [self.client.get_public_node(parse_path("999'/1'/%d'" % index)) for index in range(1, 4)]
multisig1 = proto.MultisigRedeemScriptType(
pubkeys=list(map(lambda n: proto.HDNodePathType(node=bip32.deserialize(n.xpub), address_n=[2, 0]), nodes)),
signatures=[b'', b'', b''],
@ -43,5 +44,5 @@ class TestMsgGetaddressSegwitNative(TrezorTest):
m=2,
)
for i in [1, 2, 3]:
assert self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/1" % i), False, multisig2, script_type=proto.InputScriptType.SPENDWITNESS) == 'tb1qch62pf820spe9mlq49ns5uexfnl6jzcezp7d328fw58lj0rhlhasge9hzy'
assert self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/0" % i), False, multisig1, script_type=proto.InputScriptType.SPENDWITNESS) == 'tb1qr6xa5v60zyt3ry9nmfew2fk5g9y3gerkjeu6xxdz7qga5kknz2ssld9z2z'
assert self.client.get_address("Testnet", parse_path("999'/1'/%d'/2/1" % i), False, multisig2, script_type=proto.InputScriptType.SPENDWITNESS) == 'tb1qch62pf820spe9mlq49ns5uexfnl6jzcezp7d328fw58lj0rhlhasge9hzy'
assert self.client.get_address("Testnet", parse_path("999'/1'/%d'/2/0" % i), False, multisig1, script_type=proto.InputScriptType.SPENDWITNESS) == 'tb1qr6xa5v60zyt3ry9nmfew2fk5g9y3gerkjeu6xxdz7qga5kknz2ssld9z2z'

View File

@ -16,6 +16,9 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
from binascii import hexlify
import pytest
from .common import TrezorTest
from trezorlib.client import CallException

View File

@ -21,6 +21,7 @@ import pytest
from .common import TrezorTest
from trezorlib import messages as proto
from trezorlib.tools import parse_path
PUBLIC_KEY = unhexlify('eb56d7bbb5e8ea9269405f7a8527fe126023d1db2c973cfac6f760b60ae27294')
@ -41,7 +42,7 @@ class TestMsgLiskSignTx(TrezorTest):
)
])
self.client.lisk_sign_tx(self.client.expand_path("m/44'/134'/0'/0'"), {
self.client.lisk_sign_tx(parse_path("m/44'/134'/0'/0'"), {
"amount": "10000000",
"recipientId": "9971262264659915921L",
"timestamp": 57525937,
@ -62,7 +63,7 @@ class TestMsgLiskSignTx(TrezorTest):
)
])
self.client.lisk_sign_tx(self.client.expand_path("m/44'/134'/0'/0'"), {
self.client.lisk_sign_tx(parse_path("m/44'/134'/0'/0'"), {
"amount": "10000000",
"recipientId": "9971262264659915921L",
"timestamp": 57525937,
@ -85,7 +86,7 @@ class TestMsgLiskSignTx(TrezorTest):
)
])
self.client.lisk_sign_tx(self.client.expand_path("m/44'/134'/0'/0'"), {
self.client.lisk_sign_tx(parse_path("m/44'/134'/0'/0'"), {
"amount": "0",
"timestamp": 57525937,
"type": 1,
@ -109,7 +110,7 @@ class TestMsgLiskSignTx(TrezorTest):
)
])
self.client.lisk_sign_tx(self.client.expand_path("m/44'/134'/0'/0'"), {
self.client.lisk_sign_tx(parse_path("m/44'/134'/0'/0'"), {
"amount": "0",
"timestamp": 57525937,
"type": 2,
@ -133,7 +134,7 @@ class TestMsgLiskSignTx(TrezorTest):
)
])
self.client.lisk_sign_tx(self.client.expand_path("m/44'/134'/0'/0'"), {
self.client.lisk_sign_tx(parse_path("m/44'/134'/0'/0'"), {
"amount": "0",
"timestamp": 57525937,
"type": 3,
@ -158,7 +159,7 @@ class TestMsgLiskSignTx(TrezorTest):
)
])
self.client.lisk_sign_tx(self.client.expand_path("m/44'/134'/0'/0'"), {
self.client.lisk_sign_tx(parse_path("m/44'/134'/0'/0'"), {
"amount": "0",
"timestamp": 57525937,
"type": 4,

View File

@ -15,7 +15,10 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
from .common import *
import pytest
from .common import TrezorTest
from trezorlib.tools import parse_path
@pytest.mark.xfail # to be removed when nem is merged
@ -23,5 +26,5 @@ class TestMsgNEMGetaddress(TrezorTest):
def test_nem_getaddress(self):
self.setup_mnemonic_nopin_nopassphrase()
assert self.client.nem_get_address(self.client.expand_path("m/44'/1'/0'/0'/0'"), 0x68) == "NB3JCHVARQNGDS3UVGAJPTFE22UQFGMCQGHUBWQN"
assert self.client.nem_get_address(self.client.expand_path("m/44'/1'/0'/0'/0'"), 0x98) == "TB3JCHVARQNGDS3UVGAJPTFE22UQFGMCQHSBNBMF"
assert self.client.nem_get_address(parse_path("m/44'/1'/0'/0'/0'"), 0x68) == "NB3JCHVARQNGDS3UVGAJPTFE22UQFGMCQGHUBWQN"
assert self.client.nem_get_address(parse_path("m/44'/1'/0'/0'/0'"), 0x98) == "TB3JCHVARQNGDS3UVGAJPTFE22UQFGMCQHSBNBMF"

View File

@ -15,8 +15,12 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
from .common import *
import pytest
from binascii import hexlify
from .common import TrezorTest
from trezorlib import nem
from trezorlib.tools import parse_path
# assertion data from T1
@ -26,7 +30,7 @@ class TestMsgNEMSignTxMosaics(TrezorTest):
def test_nem_signtx_mosaic_supply_change(self):
self.setup_mnemonic_nopin_nopassphrase()
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
tx = self.client.nem_sign_tx(parse_path("m/44'/1'/0'/0'/0'"), {
"timeStamp": 74649215,
"fee": 2000000,
"type": nem.TYPE_MOSAIC_SUPPLY_CHANGE,
@ -50,7 +54,7 @@ class TestMsgNEMSignTxMosaics(TrezorTest):
def test_nem_signtx_mosaic_creation(self):
self.setup_mnemonic_nopin_nopassphrase()
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
tx = self.client.nem_sign_tx(parse_path("m/44'/1'/0'/0'/0'"), {
"timeStamp": 74649215,
"fee": 2000000,
"type": nem.TYPE_MOSAIC_CREATION,
@ -77,7 +81,7 @@ class TestMsgNEMSignTxMosaics(TrezorTest):
def test_nem_signtx_mosaic_creation_properties(self):
self.setup_mnemonic_nopin_nopassphrase()
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
tx = self.client.nem_sign_tx(parse_path("m/44'/1'/0'/0'/0'"), {
"timeStamp": 74649215,
"fee": 2000000,
"type": nem.TYPE_MOSAIC_CREATION,
@ -121,7 +125,7 @@ class TestMsgNEMSignTxMosaics(TrezorTest):
def test_nem_signtx_mosaic_creation_levy(self):
self.setup_mnemonic_nopin_nopassphrase()
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
tx = self.client.nem_sign_tx(parse_path("m/44'/1'/0'/0'/0'"), {
"timeStamp": 74649215,
"fee": 2000000,
"type": nem.TYPE_MOSAIC_CREATION,

View File

@ -15,11 +15,14 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
from .common import *
from binascii import hexlify
import pytest
import time
from .common import TrezorTest
from trezorlib import messages as proto
from trezorlib import nem
import time
from trezorlib.tools import parse_path
# assertion data from T1
@ -31,7 +34,7 @@ class TestMsgNEMSignTxMosaics(TrezorTest):
self.setup_mnemonic_nopin_nopassphrase()
with self.client:
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
tx = self.client.nem_sign_tx(parse_path("m/44'/1'/0'/0'/0'"), {
"timeStamp": 74649215,
"fee": 2000000,
"type": nem.TYPE_MOSAIC_SUPPLY_CHANGE,
@ -181,7 +184,7 @@ class TestMsgNEMSignTxMosaics(TrezorTest):
assert hexlify(tx.signature) == b'b87aac1ddf146d35e6a7f3451f57e2fe504ac559031e010a51261257c37bd50fcfa7b2939dd7a3203b54c4807d458475182f5d3dc135ec0d1d4a9cd42159fd0a'
def _nem_sign(self, num_of_swipes, test_suite):
n = self.client.expand_path("m/44'/1'/0'/0'/0'")
n = parse_path("m/44'/1'/0'/0'/0'")
n = self.client._convert_prime(n)
msg = nem.create_sign_tx(test_suite)
assert msg.transaction is not None

View File

@ -15,7 +15,11 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
from .common import *
from binascii import hexlify
import pytest
from .common import TrezorTest
from trezorlib.tools import parse_path
from trezorlib import nem
@ -27,7 +31,7 @@ class TestMsgNEMSignTxMultisig(TrezorTest):
def test_nem_signtx_aggregate_modification(self):
self.setup_mnemonic_nopin_nopassphrase()
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
tx = self.client.nem_sign_tx(parse_path("m/44'/1'/0'/0'/0'"), {
"timeStamp": 74649215,
"fee": 2000000,
"type": nem.TYPE_AGGREGATE_MODIFICATION,
@ -51,7 +55,7 @@ class TestMsgNEMSignTxMultisig(TrezorTest):
def test_nem_signtx_multisig(self):
self.setup_mnemonic_nopin_nopassphrase()
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
tx = self.client.nem_sign_tx(parse_path("m/44'/1'/0'/0'/0'"), {
"timeStamp": 1,
"fee": 10000,
"type": nem.TYPE_MULTISIG,
@ -76,7 +80,7 @@ class TestMsgNEMSignTxMultisig(TrezorTest):
assert hexlify(tx.data) == b'04100000010000980100000020000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b40620841027000000000000ff5f74049900000001010000010000980200000020000000c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844983a000000000000320901002800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324a80841e000000000025000000010000001d000000746573745f6e656d5f7472616e73616374696f6e5f7472616e73666572'
assert hexlify(tx.signature) == b'0cab2fddf2f02b5d7201675b9a71869292fe25ed33a366c7d2cbea7676fed491faaa03310079b7e17884b6ba2e3ea21c4f728d1cca8f190b8288207f6514820a'
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
tx = self.client.nem_sign_tx(parse_path("m/44'/1'/0'/0'/0'"), {
"timeStamp": 74649215,
"fee": 150,
"type": nem.TYPE_MULTISIG,
@ -104,7 +108,7 @@ class TestMsgNEMSignTxMultisig(TrezorTest):
def test_nem_signtx_multisig_signer(self):
self.setup_mnemonic_nopin_nopassphrase()
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
tx = self.client.nem_sign_tx(parse_path("m/44'/1'/0'/0'/0'"), {
"timeStamp": 333,
"fee": 200,
"type": nem.TYPE_MULTISIG_SIGNATURE,
@ -129,7 +133,7 @@ class TestMsgNEMSignTxMultisig(TrezorTest):
assert hexlify(tx.data) == b'02100000010000984d01000020000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b4062084c800000000000000bc010000240000002000000087923cd4805f3babe6b5af9cbb2b08be4458e39531618aed73c911f160c8e38528000000544444324354364c514c49595135364b49584933454e544d36454b3344343450354b5a50464d4b32'
assert hexlify(tx.signature) == b'286358a16ae545bff798feab93a713440c7c2f236d52ac0e995669d17a1915b0903667c97fa04418eccb42333cba95b19bccc8ac1faa8224dcfaeb41890ae807'
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
tx = self.client.nem_sign_tx(parse_path("m/44'/1'/0'/0'/0'"), {
"timeStamp": 900000,
"fee": 200000,
"type": nem.TYPE_MULTISIG_SIGNATURE,

View File

@ -15,9 +15,13 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
from .common import *
from binascii import hexlify
import pytest
from .common import TrezorTest
from trezorlib import nem
from trezorlib.tools import parse_path
# assertion data from T1
@ -28,7 +32,7 @@ class TestMsgNEMSignTxOther(TrezorTest):
self.setup_mnemonic_nopin_nopassphrase()
with self.client:
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
tx = self.client.nem_sign_tx(parse_path("m/44'/1'/0'/0'/0'"), {
"timeStamp": 12349215,
"fee": 9900,
"type": nem.TYPE_IMPORTANCE_TRANSFER,
@ -49,7 +53,7 @@ class TestMsgNEMSignTxOther(TrezorTest):
self.setup_mnemonic_nopin_nopassphrase()
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
tx = self.client.nem_sign_tx(parse_path("m/44'/1'/0'/0'/0'"), {
"timeStamp": 74649215,
"fee": 2000000,
"type": nem.TYPE_PROVISION_NAMESPACE,

View File

@ -15,10 +15,14 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
from .common import *
from binascii import hexlify, unhexlify
import pytest
from .common import TrezorTest
from trezorlib import messages as proto
from trezorlib import nem
from trezorlib.tools import parse_path
# assertion data from T1
@ -43,7 +47,7 @@ class TestMsgNEMSignTx(TrezorTest):
proto.NEMSignedTx(),
])
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
tx = self.client.nem_sign_tx(parse_path("m/44'/1'/0'/0'/0'"), {
"timeStamp": 74649215,
"amount": 2000000,
"fee": 2000000,
@ -74,7 +78,7 @@ class TestMsgNEMSignTx(TrezorTest):
proto.NEMSignedTx(),
])
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
tx = self.client.nem_sign_tx(parse_path("m/44'/1'/0'/0'/0'"), {
"timeStamp": 74649215,
"amount": 2000000,
"fee": 2000000,
@ -100,7 +104,7 @@ class TestMsgNEMSignTx(TrezorTest):
def test_nem_signtx_xem_as_mosaic(self):
self.setup_mnemonic_nopin_nopassphrase()
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
tx = self.client.nem_sign_tx(parse_path("m/44'/1'/0'/0'/0'"), {
"timeStamp": 76809215,
"amount": 5000000,
"fee": 1000000,
@ -128,7 +132,7 @@ class TestMsgNEMSignTx(TrezorTest):
def test_nem_signtx_unknown_mosaic(self):
self.setup_mnemonic_nopin_nopassphrase()
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
tx = self.client.nem_sign_tx(parse_path("m/44'/1'/0'/0'/0'"), {
"timeStamp": 76809215,
"amount": 2000000,
"fee": 1000000,

View File

@ -16,11 +16,14 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
from .common import *
from binascii import hexlify, unhexlify
from .common import TrezorTest
from trezorlib import coins
from trezorlib import messages as proto
from trezorlib.client import CallException
from trezorlib.tools import parse_path
TxApiTestnet = coins.tx_api['Testnet']
@ -88,7 +91,7 @@ class TestMsgSigntx(TrezorTest):
# tx: e5040e1bc1ae7667ffb9e5248e90b2fb93cd9150234151ce90e14ab2f5933bcd
# input 0: 0.31 BTC
inp1 = proto.TxInputType(
address_n=self.client.expand_path("44'/1'/0'/0/0"),
address_n=parse_path("44'/1'/0'/0/0"),
# amount=31000000,
prev_hash=TXHASH_e5040e,
prev_index=0,
@ -101,7 +104,7 @@ class TestMsgSigntx(TrezorTest):
)
out2 = proto.TxOutputType(
address_n=self.client.expand_path("44'/1'/0'/1/0"),
address_n=parse_path("44'/1'/0'/1/0"),
amount=900000,
script_type=proto.OutputScriptType.PAYTOADDRESS,
)
@ -185,14 +188,14 @@ class TestMsgSigntx(TrezorTest):
# tx: c275c333fd1b36bef4af316226c66a8b3693fbfcc081a5e16a2ae5fcb09e92bf
inp1 = proto.TxInputType(
address_n=self.client.expand_path("m/44'/0'/0'/0/5"), # 1GA9u9TfCG7SWmKCveBumdA1TZpfom6ZdJ
address_n=parse_path("m/44'/0'/0'/0/5"), # 1GA9u9TfCG7SWmKCveBumdA1TZpfom6ZdJ
# amount=50000,
prev_hash=TXHASH_50f6f1,
prev_index=1,
)
out1 = proto.TxOutputType(
address_n=self.client.expand_path("m/44'/0'/0'/1/3"), # 1EcL6AyfQTyWKGvXwNSfsWoYnD3whzVFdu
address_n=parse_path("m/44'/0'/0'/1/3"), # 1EcL6AyfQTyWKGvXwNSfsWoYnD3whzVFdu
amount=30000,
script_type=proto.OutputScriptType.PAYTOADDRESS,
)
@ -639,7 +642,7 @@ class TestMsgSigntx(TrezorTest):
self.client.set_tx_api(TxApiTestnet)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("44'/1'/4'/0/0"),
address_n=parse_path("44'/1'/4'/0/0"),
# moUJnmge8SRXuediK7bW6t4YfrPqbE6hD7
prev_hash=TXHASH_d2dcda,
prev_index=1,
@ -653,7 +656,7 @@ class TestMsgSigntx(TrezorTest):
)
out2 = proto.TxOutputType(
address_n=self.client.expand_path("44'/1'/12345'/1/0"),
address_n=parse_path("44'/1'/12345'/1/0"),
amount=123400000 - 5000 - 100000,
script_type=proto.OutputScriptType.PAYTOADDRESS,
)
@ -756,7 +759,7 @@ class TestMsgSigntx(TrezorTest):
# tx: e5040e1bc1ae7667ffb9e5248e90b2fb93cd9150234151ce90e14ab2f5933bcd
# input 0: 0.31 BTC
inp1 = proto.TxInputType(
address_n=self.client.expand_path("44'/1'/0'/0/0"),
address_n=parse_path("44'/1'/0'/0/0"),
# amount=31000000,
prev_hash=TXHASH_e5040e,
prev_index=0,
@ -769,13 +772,13 @@ class TestMsgSigntx(TrezorTest):
)
out_change1 = proto.TxOutputType(
address_n=self.client.expand_path("44'/1'/0'/1/0"),
address_n=parse_path("44'/1'/0'/1/0"),
amount=900000,
script_type=proto.OutputScriptType.PAYTOADDRESS,
)
out_change2 = proto.TxOutputType(
address_n=self.client.expand_path("44'/1'/0'/1/1"),
address_n=parse_path("44'/1'/0'/1/1"),
amount=10000,
script_type=proto.OutputScriptType.PAYTOADDRESS,
)
@ -815,7 +818,7 @@ class TestMsgSigntx(TrezorTest):
# tx: e5040e1bc1ae7667ffb9e5248e90b2fb93cd9150234151ce90e14ab2f5933bcd
# input 0: 0.31 BTC
inp1 = proto.TxInputType(
address_n=self.client.expand_path("44'/1'/0'/0/0"),
address_n=parse_path("44'/1'/0'/0/0"),
# amount=31000000,
prev_hash=TXHASH_e5040e,
prev_index=0,
@ -829,7 +832,7 @@ class TestMsgSigntx(TrezorTest):
# change on main chain is allowed => treated as a change
out_change = proto.TxOutputType(
address_n=self.client.expand_path("44'/1'/0'/0/0"),
address_n=parse_path("44'/1'/0'/0/0"),
amount=900000,
script_type=proto.OutputScriptType.PAYTOADDRESS,
)

View File

@ -23,6 +23,8 @@ from ..support.ckd_public import deserialize
from trezorlib import coins
from trezorlib import messages as proto
from trezorlib.client import CallException
from trezorlib.tools import parse_path
TxApiBcash = coins.tx_api['Bcash']
@ -34,7 +36,7 @@ class TestMsgSigntxBch(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiBcash)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("44'/145'/0'/0/0"),
address_n=parse_path("44'/145'/0'/0/0"),
# bitcoincash:qr08q88p9etk89wgv05nwlrkm4l0urz4cyl36hh9sv
amount=1995344,
prev_hash=unhexlify('bc37c28dfb467d2ecb50261387bf752a3977d7e5337915071bb4151e6b711a78'),
@ -42,7 +44,7 @@ class TestMsgSigntxBch(TrezorTest):
script_type=proto.InputScriptType.SPENDADDRESS,
)
out1 = proto.TxOutputType(
address_n=self.client.expand_path("44'/145'/0'/1/0"),
address_n=parse_path("44'/145'/0'/1/0"),
amount=1896050,
script_type=proto.OutputScriptType.PAYTOADDRESS,
)
@ -71,7 +73,7 @@ class TestMsgSigntxBch(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiBcash)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("44'/145'/0'/1/0"),
address_n=parse_path("44'/145'/0'/1/0"),
# bitcoincash:qzc5q87w069lzg7g3gzx0c8dz83mn7l02scej5aluw
amount=1896050,
prev_hash=unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
@ -79,7 +81,7 @@ class TestMsgSigntxBch(TrezorTest):
script_type=proto.InputScriptType.SPENDADDRESS,
)
inp2 = proto.TxInputType(
address_n=self.client.expand_path("44'/145'/0'/0/1"),
address_n=parse_path("44'/145'/0'/0/1"),
# bitcoincash:qr23ajjfd9wd73l87j642puf8cad20lfmqdgwvpat4
amount=73452,
prev_hash=unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
@ -111,7 +113,7 @@ class TestMsgSigntxBch(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiBcash)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("44'/145'/0'/1/0"),
address_n=parse_path("44'/145'/0'/1/0"),
# bitcoincash:qzc5q87w069lzg7g3gzx0c8dz83mn7l02scej5aluw
amount=1896050,
prev_hash=unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
@ -119,7 +121,7 @@ class TestMsgSigntxBch(TrezorTest):
script_type=proto.InputScriptType.SPENDADDRESS,
)
inp2 = proto.TxInputType(
address_n=self.client.expand_path("44'/145'/0'/0/1"),
address_n=parse_path("44'/145'/0'/0/1"),
# bitcoincash:qr23ajjfd9wd73l87j642puf8cad20lfmqdgwvpat4
amount=73452,
prev_hash=unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
@ -151,7 +153,7 @@ class TestMsgSigntxBch(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiBcash)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("44'/145'/0'/1/0"),
address_n=parse_path("44'/145'/0'/1/0"),
# bitcoincash:qzc5q87w069lzg7g3gzx0c8dz83mn7l02scej5aluw
amount=300,
prev_hash=unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
@ -159,7 +161,7 @@ class TestMsgSigntxBch(TrezorTest):
script_type=proto.InputScriptType.SPENDADDRESS,
)
inp2 = proto.TxInputType(
address_n=self.client.expand_path("44'/145'/0'/0/1"),
address_n=parse_path("44'/145'/0'/0/1"),
# bitcoincash:qr23ajjfd9wd73l87j642puf8cad20lfmqdgwvpat4
amount=70,
prev_hash=unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
@ -237,7 +239,7 @@ class TestMsgSigntxBch(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiBcash)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("44'/145'/1000'/0/0"),
address_n=parse_path("44'/145'/1000'/0/0"),
# bitcoincash:qr08q88p9etk89wgv05nwlrkm4l0urz4cyl36hh9sv
amount=1995344,
prev_hash=unhexlify('bc37c28dfb467d2ecb50261387bf752a3977d7e5337915071bb4151e6b711a78'),
@ -245,7 +247,7 @@ class TestMsgSigntxBch(TrezorTest):
script_type=proto.InputScriptType.SPENDADDRESS,
)
out1 = proto.TxOutputType(
address_n=self.client.expand_path("44'/145'/1000'/1/0"),
address_n=parse_path("44'/145'/1000'/1/0"),
amount=1896050,
script_type=proto.OutputScriptType.PAYTOADDRESS,
)
@ -291,7 +293,7 @@ class TestMsgSigntxBch(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiBcash)
xpubs = []
for n in map(lambda index: self.client.get_public_node(self.client.expand_path("44'/145'/" + str(index) + "'")), range(1, 4)):
for n in map(lambda index: self.client.get_public_node(parse_path("44'/145'/" + str(index) + "'")), range(1, 4)):
xpubs.append(n.xpub)
def getmultisig(chain, nr, signatures=[b'', b'', b''], xpubs=xpubs):
@ -306,7 +308,7 @@ class TestMsgSigntxBch(TrezorTest):
public_key=unhexlify('0378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71'))
sig = unhexlify(b'304402207274b5a4d15e75f3df7319a375557b0efba9b27bc63f9f183a17da95a6125c94022000efac57629f1522e2d3958430e2ef073b0706cfac06cce492651b79858f09ae')
inp1 = proto.TxInputType(
address_n=self.client.expand_path("44'/145'/1'/1/0"),
address_n=parse_path("44'/145'/1'/1/0"),
multisig=getmultisig(1, 0, [b'', sig, b'']),
# bitcoincash:pp6kcpkhua7789g2vyj0qfkcux3yvje7euhyhltn0a
amount=24000,
@ -315,7 +317,7 @@ class TestMsgSigntxBch(TrezorTest):
script_type=proto.InputScriptType.SPENDMULTISIG,
)
out1 = proto.TxOutputType(
address_n=self.client.expand_path("44'/145'/1'/1/1"),
address_n=parse_path("44'/145'/1'/1/1"),
multisig=proto.MultisigRedeemScriptType(
pubkeys=[proto.HDNodePathType(node=deserialize(xpubs[0]), address_n=[1, 1]),
proto.HDNodePathType(node=correcthorse, address_n=[]),
@ -344,7 +346,7 @@ class TestMsgSigntxBch(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiBcash)
xpubs = []
for n in map(lambda index: self.client.get_public_node(self.client.expand_path("44'/145'/" + str(index) + "'")), range(1, 4)):
for n in map(lambda index: self.client.get_public_node(parse_path("44'/145'/" + str(index) + "'")), range(1, 4)):
xpubs.append(n.xpub)
def getmultisig(chain, nr, signatures=[b'', b'', b''], xpubs=xpubs):
@ -354,7 +356,7 @@ class TestMsgSigntxBch(TrezorTest):
m=2,
)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("44'/145'/3'/0/0"),
address_n=parse_path("44'/145'/3'/0/0"),
multisig=getmultisig(0, 0),
# bitcoincash:pqguz4nqq64jhr5v3kvpq4dsjrkda75hwy86gq0qzw
amount=48490,
@ -368,7 +370,7 @@ class TestMsgSigntxBch(TrezorTest):
script_type=proto.OutputScriptType.PAYTOADDRESS,
)
out2 = proto.TxOutputType(
address_n=self.client.expand_path("44'/145'/3'/1/0"),
address_n=parse_path("44'/145'/3'/1/0"),
multisig=getmultisig(1, 0),
script_type=proto.OutputScriptType.PAYTOMULTISIG,
amount=24000
@ -390,7 +392,7 @@ class TestMsgSigntxBch(TrezorTest):
assert hexlify(signatures1[0]) == b'3045022100bcb1a7134a13025a06052546ee1c6ac3640a0abd2d130190ed13ed7fcb43e9cd02207c381478e2ee123c850425bfbf6d3c691230eb37e333832cb32a1ed3f2cd9e85'
inp1 = proto.TxInputType(
address_n=self.client.expand_path("44'/145'/1'/0/0"),
address_n=parse_path("44'/145'/1'/0/0"),
multisig=getmultisig(0, 0, [b'', b'', signatures1[0]]),
# bitcoincash:pqguz4nqq64jhr5v3kvpq4dsjrkda75hwy86gq0qzw
amount=48490,

View File

@ -24,6 +24,7 @@ from ..support.ckd_public import deserialize
from trezorlib import coins
from trezorlib import messages as proto
from trezorlib.client import CallException
from trezorlib.tools import parse_path
TxApiBitcoinGold = coins.tx_api["Bitcoin Gold"]
@ -35,14 +36,14 @@ class TestMsgSigntxBitcoinGold(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiBitcoinGold)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("44'/156'/0'/0/0"),
address_n=parse_path("44'/156'/0'/0/0"),
amount=1995344,
prev_hash=unhexlify('25526bf06c76ad3082bba930cf627cdd5f1b3cd0b9907dd7ff1a07e14addc985'),
prev_index=0,
script_type=proto.InputScriptType.SPENDADDRESS,
)
out1 = proto.TxOutputType(
address_n=self.client.expand_path("44'/156'/0'/1/0"),
address_n=parse_path("44'/156'/0'/1/0"),
amount=1896050,
script_type=proto.OutputScriptType.PAYTOADDRESS,
)
@ -71,14 +72,14 @@ class TestMsgSigntxBitcoinGold(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiBitcoinGold)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("44'/156'/0'/1/0"),
address_n=parse_path("44'/156'/0'/1/0"),
amount=1896050,
prev_hash=unhexlify('25526bf06c76ad3082bba930cf627cdd5f1b3cd0b9907dd7ff1a07e14addc985'),
prev_index=0,
script_type=proto.InputScriptType.SPENDADDRESS,
)
inp2 = proto.TxInputType(
address_n=self.client.expand_path("44'/156'/0'/0/1"),
address_n=parse_path("44'/156'/0'/0/1"),
# 1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3
amount=73452,
prev_hash=unhexlify('db77c2461b840e6edbe7f9280043184a98e020d9795c1b65cb7cef2551a8fb18'),
@ -110,7 +111,7 @@ class TestMsgSigntxBitcoinGold(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiBitcoinGold)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("44'/156'/1000'/0/0"),
address_n=parse_path("44'/156'/1000'/0/0"),
# 1MH9KKcvdCTY44xVDC2k3fjBbX5Cz29N1q
amount=1995344,
prev_hash=unhexlify('25526bf06c76ad3082bba930cf627cdd5f1b3cd0b9907dd7ff1a07e14addc985'),
@ -118,7 +119,7 @@ class TestMsgSigntxBitcoinGold(TrezorTest):
script_type=proto.InputScriptType.SPENDADDRESS,
)
out1 = proto.TxOutputType(
address_n=self.client.expand_path("44'/156'/1000'/1/0"),
address_n=parse_path("44'/156'/1000'/1/0"),
amount=1896050,
script_type=proto.OutputScriptType.PAYTOADDRESS,
)
@ -164,7 +165,7 @@ class TestMsgSigntxBitcoinGold(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiBitcoinGold)
xpubs = []
for n in map(lambda index: self.client.get_public_node(self.client.expand_path("44'/156'/" + str(index) + "'")), range(1, 4)):
for n in map(lambda index: self.client.get_public_node(parse_path("44'/156'/" + str(index) + "'")), range(1, 4)):
xpubs.append(n.xpub)
def getmultisig(chain, nr, signatures=[b'', b'', b''], xpubs=xpubs):
@ -174,7 +175,7 @@ class TestMsgSigntxBitcoinGold(TrezorTest):
m=2,
)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("44'/156'/3'/0/0"),
address_n=parse_path("44'/156'/3'/0/0"),
multisig=getmultisig(0, 0),
# 33Ju286QvonBz5N1V754ZekQv4GLJqcc5R
amount=48490,
@ -188,7 +189,7 @@ class TestMsgSigntxBitcoinGold(TrezorTest):
script_type=proto.OutputScriptType.PAYTOADDRESS,
)
out2 = proto.TxOutputType(
address_n=self.client.expand_path("44'/156'/3'/1/0"),
address_n=parse_path("44'/156'/3'/1/0"),
multisig=getmultisig(1, 0),
script_type=proto.OutputScriptType.PAYTOMULTISIG,
amount=24000
@ -210,7 +211,7 @@ class TestMsgSigntxBitcoinGold(TrezorTest):
assert hexlify(signatures1[0]) == b'3045022100b1594f3b186d0dedbf61e53a1c407b1e0747098b7375941df85af045040f578e022013ba1893eb9e2fd854dd07073a83b261cf4beba76f66b07742e462b4088a7e4a'
inp1 = proto.TxInputType(
address_n=self.client.expand_path("44'/156'/1'/0/0"),
address_n=parse_path("44'/156'/1'/0/0"),
multisig=getmultisig(0, 0, [b'', b'', signatures1[0]]),
# 33Ju286QvonBz5N1V754ZekQv4GLJqcc5R
amount=48490,
@ -241,7 +242,7 @@ class TestMsgSigntxBitcoinGold(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiBitcoinGold)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("49'/156'/0'/1/0"),
address_n=parse_path("49'/156'/0'/1/0"),
amount=123456789,
prev_hash=unhexlify('25526bf06c76ad3082bba930cf627cdd5f1b3cd0b9907dd7ff1a07e14addc985'),
prev_index=0,
@ -279,7 +280,7 @@ class TestMsgSigntxBitcoinGold(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiBitcoinGold)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("49'/156'/0'/1/0"),
address_n=parse_path("49'/156'/0'/1/0"),
amount=123456789,
prev_hash=unhexlify('25526bf06c76ad3082bba930cf627cdd5f1b3cd0b9907dd7ff1a07e14addc985'),
prev_index=0,
@ -291,7 +292,7 @@ class TestMsgSigntxBitcoinGold(TrezorTest):
script_type=proto.OutputScriptType.PAYTOADDRESS,
)
out2 = proto.TxOutputType(
address_n=self.client.expand_path("49'/156'/0'/1/0"),
address_n=parse_path("49'/156'/0'/1/0"),
script_type=proto.OutputScriptType.PAYTOP2SHWITNESS,
amount=123456789 - 11000 - 12300000,
)
@ -317,7 +318,7 @@ class TestMsgSigntxBitcoinGold(TrezorTest):
def test_send_multisig_1(self):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiBitcoinGold)
nodes = map(lambda index: self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)), range(1, 4))
nodes = map(lambda index: self.client.get_public_node(parse_path("999'/1'/%d'" % index)), range(1, 4))
multisig = proto.MultisigRedeemScriptType(
pubkeys=list(map(lambda n: proto.HDNodePathType(node=deserialize(n.xpub), address_n=[2, 0]), nodes)),
signatures=[b'', b'', b''],
@ -325,7 +326,7 @@ class TestMsgSigntxBitcoinGold(TrezorTest):
)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("999'/1'/1'/2/0"),
address_n=parse_path("999'/1'/1'/2/0"),
prev_hash=unhexlify('25526bf06c76ad3082bba930cf627cdd5f1b3cd0b9907dd7ff1a07e14addc985'),
prev_index=1,
script_type=proto.InputScriptType.SPENDP2SHWITNESS,

View File

@ -15,10 +15,14 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
from .common import *
from binascii import hexlify, unhexlify
import pytest
from .common import TrezorTest
from trezorlib import coins
from trezorlib import messages as proto
from trezorlib.tools import parse_path
TxApiDecredTestnet = coins.tx_api['Decred Testnet']
@ -41,7 +45,7 @@ class TestMsgSigntxDecred(TrezorTest):
inp1 = proto.TxInputType(
# TscqTv1he8MZrV321SfRghw7LFBCJDKB3oz
address_n=self.client.expand_path("m/44'/1'/0'/0/0"),
address_n=parse_path("m/44'/1'/0'/0/0"),
prev_hash=TXHASH_e16248,
prev_index=1,
script_type=proto.InputScriptType.SPENDADDRESS,
@ -80,7 +84,7 @@ class TestMsgSigntxDecred(TrezorTest):
inp1 = proto.TxInputType(
# TscqTv1he8MZrV321SfRghw7LFBCJDKB3oz
address_n=self.client.expand_path("m/44'/1'/0'/0/0"),
address_n=parse_path("m/44'/1'/0'/0/0"),
prev_hash=TXHASH_5e6e35,
prev_index=0,
script_type=proto.InputScriptType.SPENDADDRESS,
@ -89,7 +93,7 @@ class TestMsgSigntxDecred(TrezorTest):
inp2 = proto.TxInputType(
# TscqTv1he8MZrV321SfRghw7LFBCJDKB3oz
address_n=self.client.expand_path("m/44'/1'/0'/0/0"),
address_n=parse_path("m/44'/1'/0'/0/0"),
prev_hash=TXHASH_ccf95b,
prev_index=1,
script_type=proto.InputScriptType.SPENDADDRESS,
@ -98,7 +102,7 @@ class TestMsgSigntxDecred(TrezorTest):
inp3 = proto.TxInputType(
# Tskt39YEvzoJ5KBDH4f1auNzG3jViVjZ2RV
address_n=self.client.expand_path("m/44'/1'/0'/0/1"),
address_n=parse_path("m/44'/1'/0'/0/1"),
prev_hash=TXHASH_f395ef,
prev_index=0,
script_type=proto.InputScriptType.SPENDADDRESS,
@ -114,7 +118,7 @@ class TestMsgSigntxDecred(TrezorTest):
out2 = proto.TxOutputType(
# TsaSFRwfN9muW5F6ZX36iSksc9hruiC5F97
address_n=self.client.expand_path("m/44'/1'/0'/1/0"),
address_n=parse_path("m/44'/1'/0'/1/0"),
amount=100000000,
script_type=proto.OutputScriptType.PAYTOADDRESS,
decred_script_version=0,
@ -154,7 +158,7 @@ class TestMsgSigntxDecred(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiDecredTestnet)
paths = [self.client.expand_path("m/48'/1'/%d'" % index) for index in range(3)]
paths = [parse_path("m/48'/1'/%d'" % index) for index in range(3)]
nodes = [self.client.get_public_node(address_n, coin_name="Decred Testnet").node for address_n in paths]
signatures = [
@ -163,7 +167,7 @@ class TestMsgSigntxDecred(TrezorTest):
]
def create_multisig(index, address, signatures=None):
address_n = self.client.expand_path(address)
address_n = parse_path(address)
multisig = proto.MultisigRedeemScriptType(
pubkeys=[proto.HDNodePathType(node=node, address_n=address_n) for node in nodes],
signatures=signatures,

View File

@ -22,6 +22,7 @@ from ..support.ckd_public import deserialize
from trezorlib import coins
from trezorlib import messages as proto
from trezorlib.client import CallException
from trezorlib.tools import parse_path
TxApiTestnet = coins.tx_api["Testnet"]
@ -32,7 +33,7 @@ class TestMsgSigntxSegwit(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiTestnet)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("49'/1'/0'/1/0"),
address_n=parse_path("49'/1'/0'/1/0"),
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
amount=123456789,
prev_hash=unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
@ -71,7 +72,7 @@ class TestMsgSigntxSegwit(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiTestnet)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("49'/1'/0'/1/0"),
address_n=parse_path("49'/1'/0'/1/0"),
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
amount=123456789,
prev_hash=unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
@ -84,7 +85,7 @@ class TestMsgSigntxSegwit(TrezorTest):
script_type=proto.OutputScriptType.PAYTOADDRESS,
)
out2 = proto.TxOutputType(
address_n=self.client.expand_path("49'/1'/0'/1/0"),
address_n=parse_path("49'/1'/0'/1/0"),
script_type=proto.OutputScriptType.PAYTOP2SHWITNESS,
amount=123456789 - 11000 - 12300000,
)
@ -108,7 +109,7 @@ class TestMsgSigntxSegwit(TrezorTest):
def test_send_multisig_1(self):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiTestnet)
nodes = map(lambda index: self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)), range(1, 4))
nodes = map(lambda index: self.client.get_public_node(parse_path("999'/1'/%d'" % index)), range(1, 4))
multisig = proto.MultisigRedeemScriptType(
pubkeys=list(map(lambda n: proto.HDNodePathType(node=deserialize(n.xpub), address_n=[2, 0]), nodes)),
signatures=[b'', b'', b''],
@ -116,7 +117,7 @@ class TestMsgSigntxSegwit(TrezorTest):
)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("999'/1'/1'/2/0"),
address_n=parse_path("999'/1'/1'/2/0"),
prev_hash=unhexlify('9c31922be756c06d02167656465c8dc83bb553bf386a3f478ae65b5c021002be'),
prev_index=1,
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
@ -165,7 +166,7 @@ class TestMsgSigntxSegwit(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiTestnet)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("49'/1'/0'/1/0"),
address_n=parse_path("49'/1'/0'/1/0"),
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
amount=123456789,
prev_hash=unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
@ -178,7 +179,7 @@ class TestMsgSigntxSegwit(TrezorTest):
script_type=proto.OutputScriptType.PAYTOADDRESS,
)
out2 = proto.TxOutputType(
address_n=self.client.expand_path("49'/1'/12345'/1/0"),
address_n=parse_path("49'/1'/12345'/1/0"),
script_type=proto.OutputScriptType.PAYTOP2SHWITNESS,
amount=123456789 - 11000 - 12300000,
)

View File

@ -21,7 +21,7 @@ from .common import TrezorTest
from ..support.ckd_public import deserialize
from trezorlib import coins
from trezorlib import messages as proto
from trezorlib.client import CallException
from trezorlib.tools import parse_path
TxApiTestnet = coins.tx_api['Testnet']
@ -32,7 +32,7 @@ class TestMsgSigntxSegwitNative(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiTestnet)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("49'/1'/0'/1/0"),
address_n=parse_path("49'/1'/0'/1/0"),
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
amount=123456789,
prev_hash=unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
@ -71,7 +71,7 @@ class TestMsgSigntxSegwitNative(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiTestnet)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("49'/1'/0'/1/0"),
address_n=parse_path("49'/1'/0'/1/0"),
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
amount=123456789,
prev_hash=unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
@ -84,7 +84,7 @@ class TestMsgSigntxSegwitNative(TrezorTest):
script_type=proto.OutputScriptType.PAYTOADDRESS,
)
out2 = proto.TxOutputType(
address_n=self.client.expand_path("49'/1'/0'/1/0"),
address_n=parse_path("49'/1'/0'/1/0"),
script_type=proto.OutputScriptType.PAYTOP2SHWITNESS,
amount=123456789 - 11000 - 12300000,
)
@ -109,7 +109,7 @@ class TestMsgSigntxSegwitNative(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiTestnet)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("49'/1'/0'/0/0"),
address_n=parse_path("49'/1'/0'/0/0"),
# tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s
amount=12300000,
prev_hash=unhexlify('09144602765ce3dd8f4329445b20e3684e948709c5cdcaf12da3bb079c99448a'),
@ -148,7 +148,7 @@ class TestMsgSigntxSegwitNative(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiTestnet)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("49'/1'/0'/0/0"),
address_n=parse_path("49'/1'/0'/0/0"),
# tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s
amount=12300000,
prev_hash=unhexlify('09144602765ce3dd8f4329445b20e3684e948709c5cdcaf12da3bb079c99448a'),
@ -161,7 +161,7 @@ class TestMsgSigntxSegwitNative(TrezorTest):
script_type=proto.OutputScriptType.PAYTOADDRESS,
)
out2 = proto.TxOutputType(
address_n=self.client.expand_path("49'/1'/0'/1/0"),
address_n=parse_path("49'/1'/0'/1/0"),
script_type=proto.OutputScriptType.PAYTOWITNESS,
amount=12300000 - 11000 - 5000000,
)
@ -186,7 +186,7 @@ class TestMsgSigntxSegwitNative(TrezorTest):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiTestnet)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("49'/1'/0'/1/0"),
address_n=parse_path("49'/1'/0'/1/0"),
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
amount=111145789,
prev_hash=unhexlify('09144602765ce3dd8f4329445b20e3684e948709c5cdcaf12da3bb079c99448a'),
@ -194,7 +194,7 @@ class TestMsgSigntxSegwitNative(TrezorTest):
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
)
inp2 = proto.TxInputType(
address_n=self.client.expand_path("49'/1'/0'/1/0"),
address_n=parse_path("49'/1'/0'/1/0"),
# tb1q694ccp5qcc0udmfwgp692u2s2hjpq5h407urtu
amount=7289000,
prev_hash=unhexlify('65b811d3eca0fe6915d9f2d77c86c5a7f19bf66b1b1253c2c51cb4ae5f0c017b'),
@ -247,7 +247,7 @@ class TestMsgSigntxSegwitNative(TrezorTest):
def test_send_multisig_1(self):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiTestnet)
nodes = [self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)) for index in range(1, 4)]
nodes = [self.client.get_public_node(parse_path("999'/1'/%d'" % index)) for index in range(1, 4)]
multisig = proto.MultisigRedeemScriptType(
pubkeys=list(map(lambda n: proto.HDNodePathType(node=deserialize(n.xpub), address_n=[2, 0]), nodes)),
signatures=[b'', b'', b''],
@ -255,7 +255,7 @@ class TestMsgSigntxSegwitNative(TrezorTest):
)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("999'/1'/1'/2/0"),
address_n=parse_path("999'/1'/1'/2/0"),
prev_hash=unhexlify('9c31922be756c06d02167656465c8dc83bb553bf386a3f478ae65b5c021002be'),
prev_index=1,
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
@ -303,7 +303,7 @@ class TestMsgSigntxSegwitNative(TrezorTest):
def test_send_multisig_2(self):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiTestnet)
nodes = [self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)) for index in range(1, 4)]
nodes = [self.client.get_public_node(parse_path("999'/1'/%d'" % index)) for index in range(1, 4)]
multisig = proto.MultisigRedeemScriptType(
pubkeys=list(map(lambda n: proto.HDNodePathType(node=deserialize(n.xpub), address_n=[2, 1]), nodes)),
signatures=[b'', b'', b''],
@ -311,7 +311,7 @@ class TestMsgSigntxSegwitNative(TrezorTest):
)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("999'/1'/2'/2/1"),
address_n=parse_path("999'/1'/2'/2/1"),
prev_hash=unhexlify('f41cbedd8becee05a830f418d13aa665125464547db5c7a6cd28f21639fe1228'),
prev_index=0,
script_type=proto.InputScriptType.SPENDWITNESS,
@ -359,7 +359,7 @@ class TestMsgSigntxSegwitNative(TrezorTest):
def test_send_multisig_3_change(self):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiTestnet)
nodes = [self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)) for index in range(1, 4)]
nodes = [self.client.get_public_node(parse_path("999'/1'/%d'" % index)) for index in range(1, 4)]
multisig = proto.MultisigRedeemScriptType(
pubkeys=list(map(lambda n: proto.HDNodePathType(node=deserialize(n.xpub), address_n=[2, 0]), nodes)),
signatures=[b'', b'', b''],
@ -372,7 +372,7 @@ class TestMsgSigntxSegwitNative(TrezorTest):
)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("999'/1'/1'/2/0"),
address_n=parse_path("999'/1'/1'/2/0"),
prev_hash=unhexlify('c9348040bbc2024e12dcb4a0b4806b0398646b91acf314da028c3f03dd0179fc'),
prev_index=0,
script_type=proto.InputScriptType.SPENDWITNESS,
@ -381,7 +381,7 @@ class TestMsgSigntxSegwitNative(TrezorTest):
)
out1 = proto.TxOutputType(
address_n=self.client.expand_path("999'/1'/1'/1/1"),
address_n=parse_path("999'/1'/1'/1/1"),
amount=1603000,
multisig=multisig2,
script_type=proto.OutputScriptType.PAYTOP2SHWITNESS
@ -420,7 +420,7 @@ class TestMsgSigntxSegwitNative(TrezorTest):
def test_send_multisig_4_change(self):
self.setup_mnemonic_allallall()
self.client.set_tx_api(TxApiTestnet)
nodes = [self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)) for index in range(1, 4)]
nodes = [self.client.get_public_node(parse_path("999'/1'/%d'" % index)) for index in range(1, 4)]
multisig = proto.MultisigRedeemScriptType(
pubkeys=list(map(lambda n: proto.HDNodePathType(node=deserialize(n.xpub), address_n=[1, 1]), nodes)),
signatures=[b'', b'', b''],
@ -433,7 +433,7 @@ class TestMsgSigntxSegwitNative(TrezorTest):
)
inp1 = proto.TxInputType(
address_n=self.client.expand_path("999'/1'/1'/1/1"),
address_n=parse_path("999'/1'/1'/1/1"),
prev_hash=unhexlify('31bc1c88ce6ae337a6b3057a16d5bad0b561ad1dfc047d0a7fbb8814668f91e5'),
prev_index=0,
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
@ -442,7 +442,7 @@ class TestMsgSigntxSegwitNative(TrezorTest):
)
out1 = proto.TxOutputType(
address_n=self.client.expand_path("999'/1'/1'/1/2"),
address_n=parse_path("999'/1'/1'/1/2"),
amount=1602000,
multisig=multisig2,
script_type=proto.OutputScriptType.PAYTOWITNESS

View File

@ -22,6 +22,7 @@ from .common import TrezorTest
from ..support import ckd_public as bip32
from trezorlib import messages as proto
from trezorlib.coins import tx_api
from trezorlib.tools import parse_path
class TestMultisigChange(TrezorTest):
@ -195,7 +196,7 @@ class TestMultisigChange(TrezorTest):
)
out2 = proto.TxOutputType(
address_n=self.client.expand_path("45'/0/1/1"),
address_n=parse_path("45'/0/1/1"),
amount=44000000,
script_type=proto.OutputScriptType.PAYTOADDRESS
)
@ -211,7 +212,7 @@ class TestMultisigChange(TrezorTest):
self.setup_mnemonic_nopin_nopassphrase()
out1 = proto.TxOutputType(
address_n=self.client.expand_path("45'/0/1/0"),
address_n=parse_path("45'/0/1/0"),
amount=40000000,
script_type=proto.OutputScriptType.PAYTOADDRESS
)