From edb1243f6493baac531c61928d1b7a9696b7d0fa Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Sat, 21 Nov 2020 11:11:53 +0100 Subject: [PATCH] feat(proto): add descriptors related fields to GetPublicKey/PublicKey --- common/protob/messages-bitcoin.proto | 4 +++- core/src/trezor/messages/GetPublicKey.py | 3 +++ core/src/trezor/messages/PublicKey.py | 3 +++ python/src/trezorlib/messages/GetPublicKey.py | 3 +++ python/src/trezorlib/messages/PublicKey.py | 3 +++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/common/protob/messages-bitcoin.proto b/common/protob/messages-bitcoin.proto index 098cfeab10..877b83a83c 100644 --- a/common/protob/messages-bitcoin.proto +++ b/common/protob/messages-bitcoin.proto @@ -62,6 +62,7 @@ message GetPublicKey { optional bool show_display = 3; // optionally show on display before sending the result optional string coin_name = 4 [default='Bitcoin']; // coin to use for verifying optional InputScriptType script_type = 5 [default=SPENDADDRESS]; // used to distinguish between various address formats (non-segwit, segwit, etc.) + optional bool ignore_xpub_magic = 6; // ignore SLIP-0132 XPUB magic, use xpub/tpub prefix for all account types } /** @@ -70,7 +71,8 @@ message GetPublicKey { */ message PublicKey { optional common.HDNodeType node = 1; // BIP32 public node - optional string xpub = 2; // serialized form of public node + optional string xpub = 2; // serialized form of public node + optional uint32 root_fingerprint = 3; // master root node fingerprint } /** diff --git a/core/src/trezor/messages/GetPublicKey.py b/core/src/trezor/messages/GetPublicKey.py index 30bdc0da3e..4ebb8036dd 100644 --- a/core/src/trezor/messages/GetPublicKey.py +++ b/core/src/trezor/messages/GetPublicKey.py @@ -22,12 +22,14 @@ class GetPublicKey(p.MessageType): show_display: bool = None, coin_name: str = "Bitcoin", script_type: EnumTypeInputScriptType = 0, + ignore_xpub_magic: bool = None, ) -> None: self.address_n = address_n if address_n is not None else [] self.ecdsa_curve_name = ecdsa_curve_name self.show_display = show_display self.coin_name = coin_name self.script_type = script_type + self.ignore_xpub_magic = ignore_xpub_magic @classmethod def get_fields(cls) -> Dict: @@ -37,4 +39,5 @@ class GetPublicKey(p.MessageType): 3: ('show_display', p.BoolType, None), 4: ('coin_name', p.UnicodeType, "Bitcoin"), # default=Bitcoin 5: ('script_type', p.EnumType("InputScriptType", (0, 1, 2, 3, 4)), 0), # default=SPENDADDRESS + 6: ('ignore_xpub_magic', p.BoolType, None), } diff --git a/core/src/trezor/messages/PublicKey.py b/core/src/trezor/messages/PublicKey.py index d0de749ee8..05387cac81 100644 --- a/core/src/trezor/messages/PublicKey.py +++ b/core/src/trezor/messages/PublicKey.py @@ -20,13 +20,16 @@ class PublicKey(p.MessageType): *, node: HDNodeType = None, xpub: str = None, + root_fingerprint: int = None, ) -> None: self.node = node self.xpub = xpub + self.root_fingerprint = root_fingerprint @classmethod def get_fields(cls) -> Dict: return { 1: ('node', HDNodeType, None), 2: ('xpub', p.UnicodeType, None), + 3: ('root_fingerprint', p.UVarintType, None), } diff --git a/python/src/trezorlib/messages/GetPublicKey.py b/python/src/trezorlib/messages/GetPublicKey.py index c6a7a309b4..0c358237d8 100644 --- a/python/src/trezorlib/messages/GetPublicKey.py +++ b/python/src/trezorlib/messages/GetPublicKey.py @@ -22,12 +22,14 @@ class GetPublicKey(p.MessageType): show_display: bool = None, coin_name: str = "Bitcoin", script_type: EnumTypeInputScriptType = 0, + ignore_xpub_magic: bool = None, ) -> None: self.address_n = address_n if address_n is not None else [] self.ecdsa_curve_name = ecdsa_curve_name self.show_display = show_display self.coin_name = coin_name self.script_type = script_type + self.ignore_xpub_magic = ignore_xpub_magic @classmethod def get_fields(cls) -> Dict: @@ -37,4 +39,5 @@ class GetPublicKey(p.MessageType): 3: ('show_display', p.BoolType, None), 4: ('coin_name', p.UnicodeType, "Bitcoin"), # default=Bitcoin 5: ('script_type', p.EnumType("InputScriptType", (0, 1, 2, 3, 4)), 0), # default=SPENDADDRESS + 6: ('ignore_xpub_magic', p.BoolType, None), } diff --git a/python/src/trezorlib/messages/PublicKey.py b/python/src/trezorlib/messages/PublicKey.py index 5efaf5092e..09294b9046 100644 --- a/python/src/trezorlib/messages/PublicKey.py +++ b/python/src/trezorlib/messages/PublicKey.py @@ -20,13 +20,16 @@ class PublicKey(p.MessageType): *, node: HDNodeType = None, xpub: str = None, + root_fingerprint: int = None, ) -> None: self.node = node self.xpub = xpub + self.root_fingerprint = root_fingerprint @classmethod def get_fields(cls) -> Dict: return { 1: ('node', HDNodeType, None), 2: ('xpub', p.UnicodeType, None), + 3: ('root_fingerprint', p.UVarintType, None), }