From 250c017fe3b6b110a920073bc9ecc5812ace46d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Vejpustek?= Date: Tue, 12 Nov 2024 18:23:50 +0100 Subject: [PATCH] feat(python): support sortedmulti --- python/.changelog.d/TODO.added | 1 + python/src/trezorlib/cli/btc.py | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 python/.changelog.d/TODO.added diff --git a/python/.changelog.d/TODO.added b/python/.changelog.d/TODO.added new file mode 100644 index 0000000000..a657afd431 --- /dev/null +++ b/python/.changelog.d/TODO.added @@ -0,0 +1 @@ +Added support for sortedmulti. diff --git a/python/src/trezorlib/cli/btc.py b/python/src/trezorlib/cli/btc.py index dde59a6bc6..d6a9867215 100644 --- a/python/src/trezorlib/cli/btc.py +++ b/python/src/trezorlib/cli/btc.py @@ -167,6 +167,12 @@ def cli() -> None: type=int, default=2, ) +@click.option( + "-s", + "--multisig-sort-pubkeys", + is_flag=True, + help="Sort pubkeys lexicographically using BIP-67", +) @click.option("-C", "--chunkify", is_flag=True) @with_client def get_address( @@ -178,6 +184,7 @@ def get_address( multisig_xpub: List[str], multisig_threshold: Optional[int], multisig_suffix_length: int, + multisig_sort_pubkeys: bool, chunkify: bool, ) -> str: """Get address for specified path. @@ -211,8 +218,16 @@ def get_address( multisig_suffix = address_n[-multisig_suffix_length:] nodes = [xpub_deserialize(x)[1] for x in multisig_xpub] + pubkeys_order = ( + messages.MultisigPubkeysOrder.LEXICOGRAPHIC + if multisig_sort_pubkeys + else messages.MultisigPubkeysOrder.PRESERVED + ) multisig = messages.MultisigRedeemScriptType( - nodes=nodes, address_n=multisig_suffix, m=multisig_threshold + nodes=nodes, + address_n=multisig_suffix, + m=multisig_threshold, + pubkeys_order=pubkeys_order, ) if script_type == messages.InputScriptType.SPENDADDRESS: script_type = messages.InputScriptType.SPENDMULTISIG