From 7d1c4949fa76f52aa58adbc632a45bccfca9a950 Mon Sep 17 00:00:00 2001 From: derekpierre Date: Wed, 14 Aug 2024 19:01:01 -0400 Subject: [PATCH] Raise click.Abort() if mnemonic does not match when executing `audit` command. --- nucypher/cli/commands/ursula.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/nucypher/cli/commands/ursula.py b/nucypher/cli/commands/ursula.py index f0d5521c6..3694ce74d 100644 --- a/nucypher/cli/commands/ursula.py +++ b/nucypher/cli/commands/ursula.py @@ -465,12 +465,13 @@ def audit(config_file, keystore_filepath, view_mnemonic): try: correct = keystore.audit(words=collect_mnemonic(emitter), password=password) except Keystore.InvalidMnemonic: + correct = False + + if not correct: emitter.message("Mnemonic is incorrect.", color="red") - return - emitter.message( - f"Mnemonic is {'' if correct else 'in'}correct.", - color="green" if correct else "red", - ) + raise click.Abort() + + emitter.message("Mnemonic is correct.", color="green") @ursula.command()