1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-23 07:58:09 +00:00

SegWit: Display address on Trezor

This commit is contained in:
Jochen Hoenicke 2017-01-02 21:25:07 +01:00
parent 7ce7732c63
commit 3e2cccf225
2 changed files with 9 additions and 4 deletions

View File

@ -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}),
)

View File

@ -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)