From 3e2cccf2254cba27799502f4ee8141b11949617e Mon Sep 17 00:00:00 2001 From: Jochen Hoenicke Date: Mon, 2 Jan 2017 21:25:07 +0100 Subject: [PATCH] SegWit: Display address on Trezor --- trezorctl | 7 ++++++- trezorlib/client.py | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/trezorctl b/trezorctl index 0f617610b..fb1dea5b8 100755 --- a/trezorctl +++ b/trezorctl @@ -127,7 +127,11 @@ class Commands(object): def get_address(self, args): address_n = self.client.expand_path(args.n) - return self.client.get_address(args.coin, address_n, args.show_display) + typemap = { 'address': types.SPENDADDRESS, + 'segwit': types.SPENDWITNESS, + 'p2shsegwit': types.SPENDP2SHWITNESS } + script_type = typemap[args.script_type]; + return self.client.get_address(args.coin, address_n, args.show_display, script_type=script_type) def ethereum_get_address(self, args): address_n = self.client.expand_path(args.n) @@ -396,6 +400,7 @@ class Commands(object): get_address.arguments = ( (('-c', '--coin'), {'type': str, 'default': 'Bitcoin'}), (('-n', '-address'), {'type': str}), + (('-t', '--script-type'), {'type': str, 'choices': ['address', 'segwit', 'p2shsegwit'], 'default': 'address'}), (('-d', '--show-display'), {'action': 'store_true', 'default': False}), ) diff --git a/trezorlib/client.py b/trezorlib/client.py index 324f1728d..1ffbfe3fe 100644 --- a/trezorlib/client.py +++ b/trezorlib/client.py @@ -489,12 +489,12 @@ class ProtocolMixin(object): @field('address') @expect(proto.Address) - def get_address(self, coin_name, n, show_display=False, multisig=None): + def get_address(self, coin_name, n, show_display=False, multisig=None, script_type=types.SPENDADDRESS): n = self._convert_prime(n) if multisig: - return self.call(proto.GetAddress(address_n=n, coin_name=coin_name, show_display=show_display, multisig=multisig)) + return self.call(proto.GetAddress(address_n=n, coin_name=coin_name, show_display=show_display, multisig=multisig, script_type=script_type)) else: - return self.call(proto.GetAddress(address_n=n, coin_name=coin_name, show_display=show_display)) + return self.call(proto.GetAddress(address_n=n, coin_name=coin_name, show_display=show_display, script_type=script_type)) @field('address') @expect(proto.EthereumAddress)