From fba80d6e54a5152f0c545912bd5b1c89d1f0e568 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/4351.added | 1 + python/src/trezorlib/cli/btc.py | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 python/.changelog.d/4351.added diff --git a/python/.changelog.d/4351.added b/python/.changelog.d/4351.added new file mode 100644 index 0000000000..72b264b78e --- /dev/null +++ b/python/.changelog.d/4351.added @@ -0,0 +1 @@ +Added support for lexicographic sorting of pubkeys in multisig. 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