Skip to content
Snippets Groups Projects
Commit 803172d1 authored by matograine's avatar matograine
Browse files

[enh] #301 : make `authfile` command display <pubkey:checksum> format

parent d19bd261
No related branches found
No related tags found
2 merge requests!146Merge dev into master branch to complete v0.8.0 development cycle,!143#301: Generalize pubkey checksum display and check
Checking pipeline status
...@@ -23,9 +23,12 @@ from pathlib import Path ...@@ -23,9 +23,12 @@ from pathlib import Path
from duniterpy.key import SigningKey from duniterpy.key import SigningKey
from duniterpy.key.scrypt_params import ScryptParams from duniterpy.key.scrypt_params import ScryptParams
# had to import display_pubkey_and_checksum from wot to avoid loop dependency.
from silkaj.wot import display_pubkey_and_checksum
from silkaj.tools import message_exit from silkaj.tools import message_exit
from silkaj.constants import PUBKEY_PATTERN from silkaj.constants import PUBKEY_PATTERN
SEED_HEX_PATTERN = "^[0-9a-fA-F]{64}$" SEED_HEX_PATTERN = "^[0-9a-fA-F]{64}$"
PUBSEC_PUBKEY_PATTERN = "pub: ({0})".format(PUBKEY_PATTERN) PUBSEC_PUBKEY_PATTERN = "pub: ({0})".format(PUBKEY_PATTERN)
PUBSEC_SIGNKEY_PATTERN = "sec: ([1-9A-HJ-NP-Za-km-z]{87,90})" PUBSEC_SIGNKEY_PATTERN = "sec: ([1-9A-HJ-NP-Za-km-z]{87,90})"
...@@ -48,12 +51,13 @@ def auth_method(ctx): ...@@ -48,12 +51,13 @@ def auth_method(ctx):
def generate_auth_file(file): def generate_auth_file(file):
key = auth_method() key = auth_method()
authfile = Path(file) authfile = Path(file)
pubkey_cksum = display_pubkey_and_checksum(key.pubkey)
if authfile.is_file(): if authfile.is_file():
confirm( confirm(
"Would you like to erase " "Would you like to erase "
+ file + file
+ " by an authfile corresponding to following pubkey `" + " by an authfile corresponding to following pubkey `"
+ key.pubkey + pubkey_cksum
+ "`?", + "`?",
abort=True, abort=True,
) )
...@@ -61,7 +65,7 @@ def generate_auth_file(file): ...@@ -61,7 +65,7 @@ def generate_auth_file(file):
print( print(
"Authentication file 'authfile' generated and stored in current\ "Authentication file 'authfile' generated and stored in current\
folder for following public key:", folder for following public key:",
key.pubkey, pubkey_cksum,
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment