From 9e81371e2ac8f9f4ee482feb73cea3eb3315b194 Mon Sep 17 00:00:00 2001 From: Florent Date: Tue, 30 Dec 2025 09:49:14 +0100 Subject: [PATCH] can login with pubkey_prefix --- src/meshcore_cli/meshcore_cli.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/meshcore_cli/meshcore_cli.py b/src/meshcore_cli/meshcore_cli.py index c6f3a28..1f0260f 100644 --- a/src/meshcore_cli/meshcore_cli.py +++ b/src/meshcore_cli/meshcore_cli.py @@ -2628,8 +2628,18 @@ async def next_cmd(mc, cmds, json_output=False): case "login" | "l" : argnum = 2 await mc.ensure_contacts() - contact = mc.get_contact_by_name(cmds[1]) - if contact is None: + contact = None + + # first try with key prefix + try: # try only if its a valid hex + int(cmds[1],16) + contact = mc.get_contact_by_key_prefix(cmds[1]) + except ValueError: + pass + if contact is None: # try by name + contact = mc.get_contact_by_name(cmds[1]) + + if contact is None: # still none ? contact not found if json_output : print(json.dumps({"error" : "contact unknown", "name" : cmds[1]})) else: