From cb913addaee8273ab877946f76e4e3d530d549da Mon Sep 17 00:00:00 2001 From: obrusvit Date: Wed, 11 Dec 2024 16:46:40 +0100 Subject: [PATCH] feat(nostr): extend GetPublicKey with show_display --- common/protob/messages-nostr.proto | 3 +- core/src/trezor/messages.py | 2 + python/src/trezorlib/messages.py | 3 + .../src/protos/generated/messages_nostr.rs | 60 +++++++++++++++---- 4 files changed, 56 insertions(+), 12 deletions(-) diff --git a/common/protob/messages-nostr.proto b/common/protob/messages-nostr.proto index d6957b8858..d839e8e415 100644 --- a/common/protob/messages-nostr.proto +++ b/common/protob/messages-nostr.proto @@ -15,7 +15,8 @@ option (include_in_bitcoin_only) = true; * @next NostrMessageSignature */ message NostrGetPubkey { - repeated uint32 address_n = 1; // used to derive the key + repeated uint32 address_n = 1; // used to derive the key + optional bool show_display = 2; // optionally show on display before sending the result } /** diff --git a/core/src/trezor/messages.py b/core/src/trezor/messages.py index 817ca1b376..703a828352 100644 --- a/core/src/trezor/messages.py +++ b/core/src/trezor/messages.py @@ -5194,11 +5194,13 @@ if TYPE_CHECKING: class NostrGetPubkey(protobuf.MessageType): address_n: "list[int]" + show_display: "bool | None" def __init__( self, *, address_n: "list[int] | None" = None, + show_display: "bool | None" = None, ) -> None: pass diff --git a/python/src/trezorlib/messages.py b/python/src/trezorlib/messages.py index 50968c5708..f3f78e238d 100644 --- a/python/src/trezorlib/messages.py +++ b/python/src/trezorlib/messages.py @@ -6771,14 +6771,17 @@ class NostrGetPubkey(protobuf.MessageType): MESSAGE_WIRE_TYPE = 2001 FIELDS = { 1: protobuf.Field("address_n", "uint32", repeated=True, required=False, default=None), + 2: protobuf.Field("show_display", "bool", repeated=False, required=False, default=None), } def __init__( self, *, address_n: Optional[Sequence["int"]] = None, + show_display: Optional["bool"] = None, ) -> None: self.address_n: Sequence["int"] = address_n if address_n is not None else [] + self.show_display = show_display class NostrPubkey(protobuf.MessageType): diff --git a/rust/trezor-client/src/protos/generated/messages_nostr.rs b/rust/trezor-client/src/protos/generated/messages_nostr.rs index f1c7f8be96..e2fc1a74b0 100644 --- a/rust/trezor-client/src/protos/generated/messages_nostr.rs +++ b/rust/trezor-client/src/protos/generated/messages_nostr.rs @@ -31,6 +31,8 @@ pub struct NostrGetPubkey { // message fields // @@protoc_insertion_point(field:hw.trezor.messages.nostr.NostrGetPubkey.address_n) pub address_n: ::std::vec::Vec, + // @@protoc_insertion_point(field:hw.trezor.messages.nostr.NostrGetPubkey.show_display) + pub show_display: ::std::option::Option, // special fields // @@protoc_insertion_point(special_field:hw.trezor.messages.nostr.NostrGetPubkey.special_fields) pub special_fields: ::protobuf::SpecialFields, @@ -47,14 +49,38 @@ impl NostrGetPubkey { ::std::default::Default::default() } + // optional bool show_display = 2; + + pub fn show_display(&self) -> bool { + self.show_display.unwrap_or(false) + } + + pub fn clear_show_display(&mut self) { + self.show_display = ::std::option::Option::None; + } + + pub fn has_show_display(&self) -> bool { + self.show_display.is_some() + } + + // Param is passed by value, moved + pub fn set_show_display(&mut self, v: bool) { + self.show_display = ::std::option::Option::Some(v); + } + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { - let mut fields = ::std::vec::Vec::with_capacity(1); + let mut fields = ::std::vec::Vec::with_capacity(2); let mut oneofs = ::std::vec::Vec::with_capacity(0); fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( "address_n", |m: &NostrGetPubkey| { &m.address_n }, |m: &mut NostrGetPubkey| { &mut m.address_n }, )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "show_display", + |m: &NostrGetPubkey| { &m.show_display }, + |m: &mut NostrGetPubkey| { &mut m.show_display }, + )); ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( "NostrGetPubkey", fields, @@ -79,6 +105,9 @@ impl ::protobuf::Message for NostrGetPubkey { 8 => { self.address_n.push(is.read_uint32()?); }, + 16 => { + self.show_display = ::std::option::Option::Some(is.read_bool()?); + }, tag => { ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; }, @@ -94,6 +123,9 @@ impl ::protobuf::Message for NostrGetPubkey { for value in &self.address_n { my_size += ::protobuf::rt::uint32_size(1, *value); }; + if let Some(v) = self.show_display { + my_size += 1 + 1; + } my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); self.special_fields.cached_size().set(my_size as u32); my_size @@ -103,6 +135,9 @@ impl ::protobuf::Message for NostrGetPubkey { for v in &self.address_n { os.write_uint32(1, *v)?; }; + if let Some(v) = self.show_display { + os.write_bool(2, v)?; + } os.write_unknown_fields(self.special_fields.unknown_fields())?; ::std::result::Result::Ok(()) } @@ -121,12 +156,14 @@ impl ::protobuf::Message for NostrGetPubkey { fn clear(&mut self) { self.address_n.clear(); + self.show_display = ::std::option::Option::None; self.special_fields.clear(); } fn default_instance() -> &'static NostrGetPubkey { static instance: NostrGetPubkey = NostrGetPubkey { address_n: ::std::vec::Vec::new(), + show_display: ::std::option::Option::None, special_fields: ::protobuf::SpecialFields::new(), }; &instance @@ -859,16 +896,17 @@ impl ::protobuf::reflect::ProtobufValue for NostrEventSignature { static file_descriptor_proto_data: &'static [u8] = b"\ \n\x14messages-nostr.proto\x12\x18hw.trezor.messages.nostr\x1a\roptions.\ - proto\"-\n\x0eNostrGetPubkey\x12\x1b\n\taddress_n\x18\x01\x20\x03(\rR\ - \x08addressN\"%\n\x0bNostrPubkey\x12\x16\n\x06pubkey\x18\x01\x20\x02(\ - \x0cR\x06pubkey\"\x8e\x01\n\x0eNostrSignEvent\x12\x1b\n\taddress_n\x18\ - \x01\x20\x03(\rR\x08addressN\x12\x1d\n\ncreated_at\x18\x02\x20\x01(\rR\t\ - createdAt\x12\x12\n\x04kind\x18\x03\x20\x01(\rR\x04kind\x12\x12\n\x04tag\ - s\x18\x04\x20\x03(\tR\x04tags\x12\x18\n\x07content\x18\x05\x20\x01(\tR\ - \x07content\"[\n\x13NostrEventSignature\x12\x16\n\x06pubkey\x18\x01\x20\ - \x02(\x0cR\x06pubkey\x12\x0e\n\x02id\x18\x02\x20\x02(\x0cR\x02id\x12\x1c\ - \n\tsignature\x18\x03\x20\x02(\x0cR\tsignatureB=\n#com.satoshilabs.trezo\ - r.lib.protobufB\x12TrezorMessageNostr\x80\xa6\x1d\x01\ + proto\"P\n\x0eNostrGetPubkey\x12\x1b\n\taddress_n\x18\x01\x20\x03(\rR\ + \x08addressN\x12!\n\x0cshow_display\x18\x02\x20\x01(\x08R\x0bshowDisplay\ + \"%\n\x0bNostrPubkey\x12\x16\n\x06pubkey\x18\x01\x20\x02(\x0cR\x06pubkey\ + \"\x8e\x01\n\x0eNostrSignEvent\x12\x1b\n\taddress_n\x18\x01\x20\x03(\rR\ + \x08addressN\x12\x1d\n\ncreated_at\x18\x02\x20\x01(\rR\tcreatedAt\x12\ + \x12\n\x04kind\x18\x03\x20\x01(\rR\x04kind\x12\x12\n\x04tags\x18\x04\x20\ + \x03(\tR\x04tags\x12\x18\n\x07content\x18\x05\x20\x01(\tR\x07content\"[\ + \n\x13NostrEventSignature\x12\x16\n\x06pubkey\x18\x01\x20\x02(\x0cR\x06p\ + ubkey\x12\x0e\n\x02id\x18\x02\x20\x02(\x0cR\x02id\x12\x1c\n\tsignature\ + \x18\x03\x20\x02(\x0cR\tsignatureB=\n#com.satoshilabs.trezor.lib.protobu\ + fB\x12TrezorMessageNostr\x80\xa6\x1d\x01\ "; /// `FileDescriptorProto` object which was a source for this generated file