From f5c7f339d369252c933be8af9e0f1990643df4ec Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Tue, 28 Dec 2021 11:35:24 +0000 Subject: [PATCH] Allow signmessage to work with any index Fixes #1043. Prior to this commit, only keys/scripts/addresses inside the scope of the current wallet script_map (the keys cached by sync, according to persisted index in wallet file, including gap limit) would allow a successful signing operation, otherwise an assertion was raised. After this commit, signing can be done with any arbitrary height index in the wallet (assuming a valid path for this wallet). --- jmclient/jmclient/wallet.py | 6 ++++-- jmclient/jmclient/wallet_utils.py | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/jmclient/jmclient/wallet.py b/jmclient/jmclient/wallet.py index 4c3597a..e258511 100644 --- a/jmclient/jmclient/wallet.py +++ b/jmclient/jmclient/wallet.py @@ -940,11 +940,13 @@ class BaseWallet(object): args: message: bytes path: path tuple - returns: + returns as tuple: + address of key that signed signature as base64-encoded string """ priv, engine = self._get_key_from_path(path) - return engine.sign_message(priv, message) + addr = engine.privkey_to_address(priv) + return addr, engine.sign_message(priv, message) def get_wallet_name(self): """ Returns the name used as a label for this diff --git a/jmclient/jmclient/wallet_utils.py b/jmclient/jmclient/wallet_utils.py index 6ccf5e5..7bc0683 100644 --- a/jmclient/jmclient/wallet_utils.py +++ b/jmclient/jmclient/wallet_utils.py @@ -1117,8 +1117,7 @@ def wallet_signmessage(wallet, hdpath, message, out_str=True): return "Error: no message specified" path = wallet.path_repr_to_path(hdpath) - sig = wallet.sign_message(msg, path) - addr = wallet.get_address_from_path(path) + addr, sig = wallet.sign_message(msg, path) if not out_str: return (sig, message, addr) return ("Signature: {}\nMessage: {}\nAddress: {}\n"