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
|
|
|
|
2019-08-27 14:58:59 +00:00
|
|
|
import pytest
|
|
|
|
|
2019-08-06 13:08:48 +00:00
|
|
|
from trezorlib import btc, ckd_public as bip32, messages as proto
|
2018-08-13 16:21:24 +00:00
|
|
|
|
2019-09-11 12:43:32 +00:00
|
|
|
from ..common import MNEMONIC12
|
2017-06-23 19:31:42 +00:00
|
|
|
|
2014-12-10 14:42:38 +00:00
|
|
|
|
2019-09-11 12:29:39 +00:00
|
|
|
class TestMsgGetaddressShow:
|
2019-08-27 14:58:59 +00:00
|
|
|
@pytest.mark.setup_client(mnemonic=MNEMONIC12)
|
|
|
|
def test_show(self, client):
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
2019-08-27 14:58:59 +00:00
|
|
|
btc.get_address(client, "Bitcoin", [1], show_display=True)
|
2018-08-13 16:21:24 +00:00
|
|
|
== "1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb"
|
|
|
|
)
|
|
|
|
assert (
|
2019-08-27 14:58:59 +00:00
|
|
|
btc.get_address(client, "Bitcoin", [2], show_display=True)
|
2018-08-13 16:21:24 +00:00
|
|
|
== "15AeAhtNJNKyowK8qPHwgpXkhsokzLtUpG"
|
|
|
|
)
|
|
|
|
assert (
|
2019-08-27 14:58:59 +00:00
|
|
|
btc.get_address(client, "Bitcoin", [3], show_display=True)
|
2018-08-13 16:21:24 +00:00
|
|
|
== "1CmzyJp9w3NafXMSEFH4SLYUPAVCSUrrJ5"
|
|
|
|
)
|
2014-12-10 14:42:38 +00:00
|
|
|
|
2019-08-27 14:58:59 +00:00
|
|
|
@pytest.mark.setup_client(mnemonic=MNEMONIC12)
|
|
|
|
def test_show_multisig_3(self, client):
|
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(
|
2019-08-27 14:58:59 +00:00
|
|
|
client, "Bitcoin", [i], show_display=True, multisig=multisig
|
2018-08-13 16:21:24 +00:00
|
|
|
)
|
|
|
|
== "3E7GDtuHqnqPmDgwH59pVC7AvySiSkbibz"
|
|
|
|
)
|
2014-12-10 18:53:24 +00:00
|
|
|
|
2019-08-27 14:58:59 +00:00
|
|
|
@pytest.mark.setup_client(mnemonic=MNEMONIC12)
|
|
|
|
def test_show_multisig_15(self, client):
|
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(
|
2019-08-27 14:58:59 +00:00
|
|
|
client, "Bitcoin", [i], show_display=True, multisig=multisig
|
2018-08-13 16:21:24 +00:00
|
|
|
)
|
|
|
|
== "3QaKF8zobqcqY8aS6nxCD5ZYdiRfL3RCmU"
|
|
|
|
)
|