1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

feat(python): support sortedmulti

This commit is contained in:
Ondřej Vejpustek 2024-11-12 18:23:50 +01:00
parent 6e24c25439
commit 250c017fe3
2 changed files with 17 additions and 1 deletions

View File

@ -0,0 +1 @@
Added support for sortedmulti.

View File

@ -167,6 +167,12 @@ def cli() -> None:
type=int, type=int,
default=2, 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) @click.option("-C", "--chunkify", is_flag=True)
@with_client @with_client
def get_address( def get_address(
@ -178,6 +184,7 @@ def get_address(
multisig_xpub: List[str], multisig_xpub: List[str],
multisig_threshold: Optional[int], multisig_threshold: Optional[int],
multisig_suffix_length: int, multisig_suffix_length: int,
multisig_sort_pubkeys: bool,
chunkify: bool, chunkify: bool,
) -> str: ) -> str:
"""Get address for specified path. """Get address for specified path.
@ -211,8 +218,16 @@ def get_address(
multisig_suffix = address_n[-multisig_suffix_length:] multisig_suffix = address_n[-multisig_suffix_length:]
nodes = [xpub_deserialize(x)[1] for x in multisig_xpub] 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( 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: if script_type == messages.InputScriptType.SPENDADDRESS:
script_type = messages.InputScriptType.SPENDMULTISIG script_type = messages.InputScriptType.SPENDMULTISIG