Skip to content

Commit 0b9499b

Browse files
committed
add cli cmd
1 parent 07b2260 commit 0b9499b

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

bittensor_cli/cli.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,9 @@ def __init__(self):
817817
self.wallet_app.command(
818818
"sign", rich_help_panel=HELP_PANELS["WALLET"]["OPERATIONS"]
819819
)(self.wallet_sign)
820+
self.wallet_app.command(
821+
"verify", rich_help_panel=HELP_PANELS["WALLET"]["OPERATIONS"]
822+
)(self.wallet_verify)
820823

821824
# stake commands
822825
self.stake_app.command(
@@ -3091,6 +3094,59 @@ def wallet_sign(
30913094

30923095
return self._run_command(wallets.sign(wallet, message, use_hotkey, json_output))
30933096

3097+
def wallet_verify(
3098+
self,
3099+
message: Optional[str] = typer.Option(
3100+
None, "--message", "-m", help="The message that was signed"
3101+
),
3102+
signature: Optional[str] = typer.Option(
3103+
None, "--signature", "-s", help="The signature to verify (hex format)"
3104+
),
3105+
public_key_or_ss58: Optional[str] = typer.Option(
3106+
None,
3107+
"--address",
3108+
"-a",
3109+
"--public-key",
3110+
"-p",
3111+
help="SS58 address or public key (hex) of the signer",
3112+
),
3113+
quiet: bool = Options.quiet,
3114+
verbose: bool = Options.verbose,
3115+
json_output: bool = Options.json_output,
3116+
):
3117+
"""
3118+
Verify a message signature using the signer's public key or SS58 address.
3119+
3120+
This command allows you to verify that a message was signed by the owner of a specific address.
3121+
3122+
USAGE
3123+
3124+
Provide the original message, the signature (in hex format), and either the SS58 address
3125+
or public key of the signer to verify the signature.
3126+
3127+
EXAMPLES
3128+
3129+
[green]$[/green] btcli wallet verify --message "Hello world" --signature "0xabc123..." --address "5GrwvaEF..."
3130+
3131+
[green]$[/green] btcli wallet verify -m "Test message" -s "0xdef456..." -p "0x1234abcd..."
3132+
"""
3133+
self.verbosity_handler(quiet, verbose, json_output)
3134+
3135+
if not public_key_or_ss58:
3136+
public_key_or_ss58 = Prompt.ask(
3137+
"Enter the [blue]address[/blue] (SS58 or hex format)"
3138+
)
3139+
3140+
if not message:
3141+
message = Prompt.ask("Enter the [blue]message[/blue]")
3142+
3143+
if not signature:
3144+
signature = Prompt.ask("Enter the [blue]signature[/blue]")
3145+
3146+
return self._run_command(
3147+
wallets.verify(message, signature, public_key_or_ss58, json_output)
3148+
)
3149+
30943150
def wallet_swap_coldkey(
30953151
self,
30963152
wallet_name: Optional[str] = Options.wallet_name,

0 commit comments

Comments
 (0)