2018-06-21 14:28:34 +00:00
|
|
|
# This file is part of the Trezor project.
|
2017-12-19 18:24:18 +00:00
|
|
|
#
|
2019-05-29 16:44:09 +00:00
|
|
|
# Copyright (C) 2012-2019 SatoshiLabs and contributors
|
2017-12-19 18:24:18 +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-12-19 18:24:18 +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-12-19 18:24:18 +00:00
|
|
|
|
2019-08-22 16:55:20 +00:00
|
|
|
import pytest
|
|
|
|
|
2018-08-13 16:21:24 +00:00
|
|
|
from trezorlib import btc, messages as proto
|
2018-04-18 13:53:40 +00:00
|
|
|
from trezorlib.tools import parse_path
|
2018-08-13 16:21:24 +00:00
|
|
|
|
2017-06-23 19:31:42 +00:00
|
|
|
|
2019-09-11 12:29:39 +00:00
|
|
|
class TestMsgGetaddressSegwit:
|
2019-08-27 14:58:59 +00:00
|
|
|
def test_show_segwit(self, client):
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
btc.get_address(
|
2019-08-27 14:58:59 +00:00
|
|
|
client,
|
2018-08-13 16:21:24 +00:00
|
|
|
"Testnet",
|
|
|
|
parse_path("49'/1'/0'/1/0"),
|
|
|
|
True,
|
|
|
|
None,
|
|
|
|
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
|
|
|
)
|
|
|
|
== "2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
btc.get_address(
|
2019-08-27 14:58:59 +00:00
|
|
|
client,
|
2018-08-13 16:21:24 +00:00
|
|
|
"Testnet",
|
|
|
|
parse_path("49'/1'/0'/0/0"),
|
|
|
|
False,
|
|
|
|
None,
|
|
|
|
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
|
|
|
)
|
|
|
|
== "2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
btc.get_address(
|
2019-08-27 14:58:59 +00:00
|
|
|
client,
|
2018-08-13 16:21:24 +00:00
|
|
|
"Testnet",
|
|
|
|
parse_path("44'/1'/0'/0/0"),
|
|
|
|
False,
|
|
|
|
None,
|
|
|
|
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
|
|
|
)
|
|
|
|
== "2N6UeBoqYEEnybg4cReFYDammpsyDw8R2Mc"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
btc.get_address(
|
2019-08-27 14:58:59 +00:00
|
|
|
client,
|
2018-08-13 16:21:24 +00:00
|
|
|
"Testnet",
|
|
|
|
parse_path("44'/1'/0'/0/0"),
|
|
|
|
False,
|
|
|
|
None,
|
|
|
|
script_type=proto.InputScriptType.SPENDADDRESS,
|
|
|
|
)
|
|
|
|
== "mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q"
|
|
|
|
)
|
2019-08-22 16:47:01 +00:00
|
|
|
|
|
|
|
@pytest.mark.altcoin
|
2019-08-27 14:58:59 +00:00
|
|
|
def test_show_segwit_altcoin(self, client):
|
2019-03-15 13:44:06 +00:00
|
|
|
assert (
|
|
|
|
btc.get_address(
|
2019-08-27 14:58:59 +00:00
|
|
|
client,
|
2019-03-15 13:44:06 +00:00
|
|
|
"Groestlcoin Testnet",
|
|
|
|
parse_path("49'/1'/0'/0/0"),
|
|
|
|
False,
|
|
|
|
None,
|
|
|
|
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
|
|
|
)
|
|
|
|
== "2N4Q5FhU2497BryFfUgbqkAJE87aKDv3V3e"
|
|
|
|
)
|
2019-06-08 14:39:12 +00:00
|
|
|
assert (
|
|
|
|
btc.get_address(
|
2019-08-27 14:58:59 +00:00
|
|
|
client,
|
2019-06-08 14:39:12 +00:00
|
|
|
"Elements",
|
|
|
|
parse_path("m/49'/1'/0'/0/0"),
|
|
|
|
False,
|
|
|
|
None,
|
|
|
|
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
|
|
|
)
|
|
|
|
== "XNW67ZQA9K3AuXPBWvJH4zN2y5QBDTwy2Z"
|
|
|
|
)
|
2017-05-12 22:59:39 +00:00
|
|
|
|
2019-10-22 14:32:00 +00:00
|
|
|
@pytest.mark.multisig
|
2019-08-27 14:58:59 +00:00
|
|
|
def test_show_multisig_3(self, client):
|
2019-08-06 13:08:48 +00:00
|
|
|
nodes = [
|
2019-08-27 14:58:59 +00:00
|
|
|
btc.get_public_node(client, parse_path("999'/1'/%d'" % i)).node
|
2019-08-06 13:08:48 +00:00
|
|
|
for i in range(1, 4)
|
|
|
|
]
|
|
|
|
|
2017-12-12 15:40:11 +00:00
|
|
|
multisig1 = proto.MultisigRedeemScriptType(
|
2019-08-06 13:08:48 +00:00
|
|
|
nodes=nodes, address_n=[2, 0], signatures=[b"", b"", b""], m=2
|
2017-01-07 16:50:40 +00:00
|
|
|
)
|
2017-12-12 15:40:11 +00:00
|
|
|
# multisig2 = proto.MultisigRedeemScriptType(
|
|
|
|
# pubkeys=map(lambda n: proto.HDNodePathType(node=bip32.deserialize(n.xpub), address_n=[2, 1]), nodes),
|
2017-06-23 19:31:42 +00:00
|
|
|
# signatures=[b'', b'', b''],
|
|
|
|
# m=2,
|
|
|
|
# )
|
2017-01-07 16:50:40 +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,
|
2018-08-13 16:21:24 +00:00
|
|
|
"Testnet",
|
|
|
|
parse_path("999'/1'/%d'/2/0" % i),
|
|
|
|
False,
|
|
|
|
multisig1,
|
|
|
|
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
|
|
|
)
|
|
|
|
== "2N2MxyAfifVhb3AMagisxaj3uij8bfXqf4Y"
|
|
|
|
)
|