1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 06:48:16 +00:00

add SignMessage.script_type

This commit is contained in:
Pavol Rusnak 2017-07-24 16:11:38 +02:00
parent de6402e95e
commit 8133317172
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
4 changed files with 102 additions and 87 deletions

View File

@ -437,11 +437,18 @@ def get_public_node(client, coin, address, curve, show_display):
@cli.command(help='Sign message using address of given path.') @cli.command(help='Sign message using address of given path.')
@click.option('-c', '--coin', default='Bitcoin') @click.option('-c', '--coin', default='Bitcoin')
@click.option('-n', '-address') @click.option('-n', '-address')
@click.option('-t', '--script-type', type=click.Choice(['address', 'segwit', 'p2shsegwit']), default='address')
@click.argument('message') @click.argument('message')
@click.pass_obj @click.pass_obj
def sign_message(client, coin, address, message): def sign_message(client, coin, address, message, script_type):
address_n = client.expand_path(address) address_n = client.expand_path(address)
res = client.sign_message(coin, address_n, message) typemap = {
'address': types.SPENDADDRESS,
'segwit': types.SPENDWITNESS,
'p2shsegwit': types.SPENDP2SHWITNESS,
}
script_type = typemap[script_type]
res = client.sign_message(coin, address_n, message, script_type)
return { return {
'message': message, 'message': message,
'address': res.address, 'address': res.address,

View File

@ -644,11 +644,11 @@ class ProtocolMixin(object):
return ret return ret
@expect(proto.MessageSignature) @expect(proto.MessageSignature)
def sign_message(self, coin_name, n, message): def sign_message(self, coin_name, n, message, script_type=types.SPENDADDRESS):
n = self._convert_prime(n) n = self._convert_prime(n)
# Convert message to UTF8 NFC (seems to be a bitcoin-qt standard) # Convert message to UTF8 NFC (seems to be a bitcoin-qt standard)
message = normalize_nfc(message).encode("utf-8") message = normalize_nfc(message).encode("utf-8")
return self.call(proto.SignMessage(coin_name=coin_name, address_n=n, message=message)) return self.call(proto.SignMessage(coin_name=coin_name, address_n=n, message=message, script_type=script_type))
@expect(proto.SignedIdentity) @expect(proto.SignedIdentity)
def sign_identity(self, identity, challenge_hidden, challenge_visual, ecdsa_curve_name=DEFAULT_CURVE): def sign_identity(self, identity, challenge_hidden, challenge_visual, ecdsa_curve_name=DEFAULT_CURVE):

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT! # Generated by the protocol buffer compiler. DO NOT EDIT!
# source: types.proto # source: types.proto
# libprotoc 3.3.0 # libprotoc 3.3.0
# trezor-common 2eb9c7e352f708506d910f2d5b9aac1e85cafa10 # trezor-common 00900951e072aaa2d7c48da807bb0032b6b898c1
import sys import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))