2018-06-21 14:28:34 +00:00
|
|
|
# This file is part of the Trezor project.
|
2017-01-03 18:40:05 +00:00
|
|
|
#
|
2019-05-29 16:44:09 +00:00
|
|
|
# Copyright (C) 2012-2019 SatoshiLabs and contributors
|
2017-01-03 18:40:05 +00:00
|
|
|
#
|
|
|
|
# This library is free software: you can redistribute it and/or modify
|
2018-06-21 14:28:34 +00:00
|
|
|
# it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
# as published by the Free Software Foundation.
|
2017-01-03 18:40:05 +00:00
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Lesser General Public License for more details.
|
|
|
|
#
|
2018-06-21 14:28:34 +00:00
|
|
|
# You should have received a copy of the License along with this library.
|
|
|
|
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
2017-01-03 18:40:05 +00:00
|
|
|
|
2018-08-13 16:21:24 +00:00
|
|
|
from trezorlib import btc, messages as proto
|
|
|
|
|
2018-04-18 12:00:11 +00:00
|
|
|
from ..support import ckd_public as bip32
|
2018-08-13 16:21:24 +00:00
|
|
|
from .common import TrezorTest
|
2017-06-23 19:31:42 +00:00
|
|
|
|
2014-12-10 14:42:38 +00:00
|
|
|
|
2017-12-23 20:20:49 +00:00
|
|
|
class TestMsgGetaddressShow(TrezorTest):
|
2014-12-10 14:42:38 +00:00
|
|
|
def test_show(self):
|
|
|
|
self.setup_mnemonic_nopin_nopassphrase()
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
btc.get_address(self.client, "Bitcoin", [1], show_display=True)
|
|
|
|
== "1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
btc.get_address(self.client, "Bitcoin", [2], show_display=True)
|
|
|
|
== "15AeAhtNJNKyowK8qPHwgpXkhsokzLtUpG"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
btc.get_address(self.client, "Bitcoin", [3], show_display=True)
|
|
|
|
== "1CmzyJp9w3NafXMSEFH4SLYUPAVCSUrrJ5"
|
|
|
|
)
|
2014-12-10 14:42:38 +00:00
|
|
|
|
2014-12-10 18:53:24 +00:00
|
|
|
def test_show_multisig_3(self):
|
2014-12-10 17:03:54 +00:00
|
|
|
self.setup_mnemonic_nopin_nopassphrase()
|
|
|
|
|
2018-08-13 16:21:24 +00:00
|
|
|
node = bip32.deserialize(
|
|
|
|
"xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy"
|
|
|
|
)
|
2017-12-12 15:40:11 +00:00
|
|
|
multisig = proto.MultisigRedeemScriptType(
|
2017-06-23 19:31:42 +00:00
|
|
|
pubkeys=[
|
2017-12-12 15:40:11 +00:00
|
|
|
proto.HDNodePathType(node=node, address_n=[1]),
|
|
|
|
proto.HDNodePathType(node=node, address_n=[2]),
|
2018-08-13 16:21:24 +00:00
|
|
|
proto.HDNodePathType(node=node, address_n=[3]),
|
2017-06-23 19:31:42 +00:00
|
|
|
],
|
2018-08-13 16:21:24 +00:00
|
|
|
signatures=[b"", b"", b""],
|
2017-06-23 19:31:42 +00:00
|
|
|
m=2,
|
|
|
|
)
|
2014-12-10 17:03:54 +00:00
|
|
|
|
2014-12-10 18:53:24 +00:00
|
|
|
for i in [1, 2, 3]:
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
btc.get_address(
|
|
|
|
self.client, "Bitcoin", [i], show_display=True, multisig=multisig
|
|
|
|
)
|
|
|
|
== "3E7GDtuHqnqPmDgwH59pVC7AvySiSkbibz"
|
|
|
|
)
|
2014-12-10 18:53:24 +00:00
|
|
|
|
|
|
|
def test_show_multisig_15(self):
|
|
|
|
self.setup_mnemonic_nopin_nopassphrase()
|
|
|
|
|
2018-08-13 16:21:24 +00:00
|
|
|
node = bip32.deserialize(
|
|
|
|
"xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy"
|
|
|
|
)
|
2014-12-12 21:31:40 +00:00
|
|
|
|
|
|
|
pubs = []
|
|
|
|
for x in range(15):
|
2017-12-12 15:40:11 +00:00
|
|
|
pubs.append(proto.HDNodePathType(node=node, address_n=[x]))
|
2014-12-12 21:31:40 +00:00
|
|
|
|
2017-12-12 15:40:11 +00:00
|
|
|
multisig = proto.MultisigRedeemScriptType(
|
2018-08-13 16:21:24 +00:00
|
|
|
pubkeys=pubs, signatures=[b""] * 15, m=15
|
2017-06-23 19:31:42 +00:00
|
|
|
)
|
2014-12-10 18:53:24 +00:00
|
|
|
|
|
|
|
for i in range(15):
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
btc.get_address(
|
|
|
|
self.client, "Bitcoin", [i], show_display=True, multisig=multisig
|
|
|
|
)
|
|
|
|
== "3QaKF8zobqcqY8aS6nxCD5ZYdiRfL3RCmU"
|
|
|
|
)
|