Merge pull request #20 from PR0M3TH3AN/codex/replace--fingerprint--with--seed-profile--in-cli

Update CLI text from fingerprint to seed profile
This commit is contained in:
thePR0M3TH3AN
2025-06-29 14:27:29 -04:00
committed by GitHub
2 changed files with 66 additions and 65 deletions

View File

@@ -79,70 +79,70 @@ def handle_switch_fingerprint(password_manager: PasswordManager):
if not fingerprints: if not fingerprints:
print( print(
colored( colored(
"No fingerprints available to switch. Please add a new fingerprint first.", "No seed profiles available to switch. Please add a new seed profile first.",
"yellow", "yellow",
) )
) )
return return
print(colored("Available Fingerprints:", "cyan")) print(colored("Available Seed Profiles:", "cyan"))
for idx, fp in enumerate(fingerprints, start=1): for idx, fp in enumerate(fingerprints, start=1):
print(colored(f"{idx}. {fp}", "cyan")) print(colored(f"{idx}. {fp}", "cyan"))
choice = input("Select a fingerprint by number to switch: ").strip() choice = input("Select a seed profile by number to switch: ").strip()
if not choice.isdigit() or not (1 <= int(choice) <= len(fingerprints)): if not choice.isdigit() or not (1 <= int(choice) <= len(fingerprints)):
print(colored("Invalid selection.", "red")) print(colored("Invalid selection.", "red"))
return return
selected_fingerprint = fingerprints[int(choice) - 1] selected_fingerprint = fingerprints[int(choice) - 1]
if password_manager.select_fingerprint(selected_fingerprint): if password_manager.select_fingerprint(selected_fingerprint):
print(colored(f"Switched to fingerprint {selected_fingerprint}.", "green")) print(colored(f"Switched to seed profile {selected_fingerprint}.", "green"))
else: else:
print(colored("Failed to switch fingerprint.", "red")) print(colored("Failed to switch seed profile.", "red"))
except Exception as e: except Exception as e:
logging.error(f"Error during fingerprint switch: {e}") logging.error(f"Error during fingerprint switch: {e}")
logging.error(traceback.format_exc()) logging.error(traceback.format_exc())
print(colored(f"Error: Failed to switch fingerprint: {e}", "red")) print(colored(f"Error: Failed to switch seed profile: {e}", "red"))
def handle_add_new_fingerprint(password_manager: PasswordManager): def handle_add_new_fingerprint(password_manager: PasswordManager):
""" """
Handles adding a new fingerprint. Handles adding a new seed profile.
:param password_manager: An instance of PasswordManager. :param password_manager: An instance of PasswordManager.
""" """
try: try:
password_manager.add_new_fingerprint() password_manager.add_new_fingerprint()
except Exception as e: except Exception as e:
logging.error(f"Error adding new fingerprint: {e}") logging.error(f"Error adding new seed profile: {e}")
logging.error(traceback.format_exc()) logging.error(traceback.format_exc())
print(colored(f"Error: Failed to add new fingerprint: {e}", "red")) print(colored(f"Error: Failed to add new seed profile: {e}", "red"))
def handle_remove_fingerprint(password_manager: PasswordManager): def handle_remove_fingerprint(password_manager: PasswordManager):
""" """
Handles removing an existing fingerprint. Handles removing an existing seed profile.
:param password_manager: An instance of PasswordManager. :param password_manager: An instance of PasswordManager.
""" """
try: try:
fingerprints = password_manager.fingerprint_manager.list_fingerprints() fingerprints = password_manager.fingerprint_manager.list_fingerprints()
if not fingerprints: if not fingerprints:
print(colored("No fingerprints available to remove.", "yellow")) print(colored("No seed profiles available to remove.", "yellow"))
return return
print(colored("Available Fingerprints:", "cyan")) print(colored("Available Seed Profiles:", "cyan"))
for idx, fp in enumerate(fingerprints, start=1): for idx, fp in enumerate(fingerprints, start=1):
print(colored(f"{idx}. {fp}", "cyan")) print(colored(f"{idx}. {fp}", "cyan"))
choice = input("Select a fingerprint by number to remove: ").strip() choice = input("Select a seed profile by number to remove: ").strip()
if not choice.isdigit() or not (1 <= int(choice) <= len(fingerprints)): if not choice.isdigit() or not (1 <= int(choice) <= len(fingerprints)):
print(colored("Invalid selection.", "red")) print(colored("Invalid selection.", "red"))
return return
selected_fingerprint = fingerprints[int(choice) - 1] selected_fingerprint = fingerprints[int(choice) - 1]
confirm = confirm_action( confirm = confirm_action(
f"Are you sure you want to remove fingerprint {selected_fingerprint}? This will delete all associated data. (Y/N): " f"Are you sure you want to remove seed profile {selected_fingerprint}? This will delete all associated data. (Y/N): "
) )
if confirm: if confirm:
if password_manager.fingerprint_manager.remove_fingerprint( if password_manager.fingerprint_manager.remove_fingerprint(
@@ -150,39 +150,39 @@ def handle_remove_fingerprint(password_manager: PasswordManager):
): ):
print( print(
colored( colored(
f"Fingerprint {selected_fingerprint} removed successfully.", f"Seed profile {selected_fingerprint} removed successfully.",
"green", "green",
) )
) )
else: else:
print(colored("Failed to remove fingerprint.", "red")) print(colored("Failed to remove seed profile.", "red"))
else: else:
print(colored("Fingerprint removal cancelled.", "yellow")) print(colored("Seed profile removal cancelled.", "yellow"))
except Exception as e: except Exception as e:
logging.error(f"Error removing fingerprint: {e}") logging.error(f"Error removing seed profile: {e}")
logging.error(traceback.format_exc()) logging.error(traceback.format_exc())
print(colored(f"Error: Failed to remove fingerprint: {e}", "red")) print(colored(f"Error: Failed to remove seed profile: {e}", "red"))
def handle_list_fingerprints(password_manager: PasswordManager): def handle_list_fingerprints(password_manager: PasswordManager):
""" """
Handles listing all available fingerprints. Handles listing all available seed profiles.
:param password_manager: An instance of PasswordManager. :param password_manager: An instance of PasswordManager.
""" """
try: try:
fingerprints = password_manager.fingerprint_manager.list_fingerprints() fingerprints = password_manager.fingerprint_manager.list_fingerprints()
if not fingerprints: if not fingerprints:
print(colored("No fingerprints available.", "yellow")) print(colored("No seed profiles available.", "yellow"))
return return
print(colored("Available Fingerprints:", "cyan")) print(colored("Available Seed Profiles:", "cyan"))
for fp in fingerprints: for fp in fingerprints:
print(colored(f"- {fp}", "cyan")) print(colored(f"- {fp}", "cyan"))
except Exception as e: except Exception as e:
logging.error(f"Error listing fingerprints: {e}") logging.error(f"Error listing seed profiles: {e}")
logging.error(traceback.format_exc()) logging.error(traceback.format_exc())
print(colored(f"Error: Failed to list fingerprints: {e}", "red")) print(colored(f"Error: Failed to list seed profiles: {e}", "red"))
def handle_display_npub(password_manager: PasswordManager): def handle_display_npub(password_manager: PasswordManager):
@@ -408,10 +408,10 @@ def display_menu(password_manager: PasswordManager):
6. Retrieve Encrypted Index from Nostr 6. Retrieve Encrypted Index from Nostr
7. Display Nostr Public Key (npub) 7. Display Nostr Public Key (npub)
8. Backup/Reveal Parent Seed 8. Backup/Reveal Parent Seed
9. Switch Fingerprint 9. Switch Seed Profile
10. Add a New Fingerprint 10. Add a New Seed Profile
11. Remove an Existing Fingerprint 11. Remove an Existing Seed Profile
12. List All Fingerprints 12. List All Seed Profiles
13. Settings 13. Settings
14. Exit 14. Exit
""" """
@@ -447,7 +447,7 @@ def display_menu(password_manager: PasswordManager):
password_manager.handle_backup_reveal_parent_seed() password_manager.handle_backup_reveal_parent_seed()
elif choice == "9": elif choice == "9":
if not password_manager.handle_switch_fingerprint(): if not password_manager.handle_switch_fingerprint():
print(colored("Failed to switch fingerprint.", "red")) print(colored("Failed to switch seed profile.", "red"))
elif choice == "10": elif choice == "10":
handle_add_new_fingerprint(password_manager) handle_add_new_fingerprint(password_manager)
elif choice == "11": elif choice == "11":

View File

@@ -122,36 +122,36 @@ class PasswordManager:
Prompts the user to select an existing fingerprint or add a new one. Prompts the user to select an existing fingerprint or add a new one.
""" """
try: try:
print(colored("\nAvailable Fingerprints:", "cyan")) print(colored("\nAvailable Seed Profiles:", "cyan"))
fingerprints = self.fingerprint_manager.list_fingerprints() fingerprints = self.fingerprint_manager.list_fingerprints()
for idx, fp in enumerate(fingerprints, start=1): for idx, fp in enumerate(fingerprints, start=1):
print(colored(f"{idx}. {fp}", "cyan")) print(colored(f"{idx}. {fp}", "cyan"))
print(colored(f"{len(fingerprints)+1}. Add a new fingerprint", "cyan")) print(colored(f"{len(fingerprints)+1}. Add a new seed profile", "cyan"))
choice = input("Select a fingerprint by number: ").strip() choice = input("Select a seed profile by number: ").strip()
if not choice.isdigit() or not (1 <= int(choice) <= len(fingerprints) + 1): if not choice.isdigit() or not (1 <= int(choice) <= len(fingerprints) + 1):
print(colored("Invalid selection. Exiting.", "red")) print(colored("Invalid selection. Exiting.", "red"))
sys.exit(1) sys.exit(1)
choice = int(choice) choice = int(choice)
if choice == len(fingerprints) + 1: if choice == len(fingerprints) + 1:
# Add a new fingerprint # Add a new seed profile
self.add_new_fingerprint() self.add_new_fingerprint()
else: else:
# Select existing fingerprint # Select existing seed profile
selected_fingerprint = fingerprints[choice - 1] selected_fingerprint = fingerprints[choice - 1]
self.select_fingerprint(selected_fingerprint) self.select_fingerprint(selected_fingerprint)
except Exception as e: except Exception as e:
logger.error(f"Error during fingerprint selection: {e}") logger.error(f"Error during seed profile selection: {e}")
logger.error(traceback.format_exc()) logger.error(traceback.format_exc())
print(colored(f"Error: Failed to select fingerprint: {e}", "red")) print(colored(f"Error: Failed to select seed profile: {e}", "red"))
sys.exit(1) sys.exit(1)
def add_new_fingerprint(self): def add_new_fingerprint(self):
""" """
Adds a new fingerprint by generating it from a seed phrase. Adds a new seed profile by generating it from a seed phrase.
""" """
try: try:
choice = input( choice = input(
@@ -169,15 +169,15 @@ class PasswordManager:
self.fingerprint_manager.current_fingerprint = fingerprint self.fingerprint_manager.current_fingerprint = fingerprint
print( print(
colored( colored(
f"New fingerprint '{fingerprint}' added and set as current.", f"New seed profile '{fingerprint}' added and set as current.",
"green", "green",
) )
) )
except Exception as e: except Exception as e:
logger.error(f"Error adding new fingerprint: {e}") logger.error(f"Error adding new seed profile: {e}")
logger.error(traceback.format_exc()) logger.error(traceback.format_exc())
print(colored(f"Error: Failed to add new fingerprint: {e}", "red")) print(colored(f"Error: Failed to add new seed profile: {e}", "red"))
sys.exit(1) sys.exit(1)
def select_fingerprint(self, fingerprint: str) -> None: def select_fingerprint(self, fingerprint: str) -> None:
@@ -189,7 +189,7 @@ class PasswordManager:
if not self.fingerprint_dir: if not self.fingerprint_dir:
print( print(
colored( colored(
f"Error: Fingerprint directory for {fingerprint} not found.", f"Error: Seed profile directory for {fingerprint} not found.",
"red", "red",
) )
) )
@@ -203,12 +203,12 @@ class PasswordManager:
self.sync_index_from_nostr_if_missing() self.sync_index_from_nostr_if_missing()
print( print(
colored( colored(
f"Fingerprint {fingerprint} selected and managers initialized.", f"Seed profile {fingerprint} selected and managers initialized.",
"green", "green",
) )
) )
else: else:
print(colored(f"Error: Fingerprint {fingerprint} not found.", "red")) print(colored(f"Error: Seed profile {fingerprint} not found.", "red"))
sys.exit(1) sys.exit(1)
def setup_encryption_manager( def setup_encryption_manager(
@@ -267,18 +267,18 @@ class PasswordManager:
def handle_switch_fingerprint(self) -> bool: def handle_switch_fingerprint(self) -> bool:
""" """
Handles switching to a different fingerprint. Handles switching to a different seed profile.
Returns: Returns:
bool: True if switch was successful, False otherwise. bool: True if switch was successful, False otherwise.
""" """
try: try:
print(colored("\nAvailable Fingerprints:", "cyan")) print(colored("\nAvailable Seed Profiles:", "cyan"))
fingerprints = self.fingerprint_manager.list_fingerprints() fingerprints = self.fingerprint_manager.list_fingerprints()
for idx, fp in enumerate(fingerprints, start=1): for idx, fp in enumerate(fingerprints, start=1):
print(colored(f"{idx}. {fp}", "cyan")) print(colored(f"{idx}. {fp}", "cyan"))
choice = input("Select a fingerprint by number to switch: ").strip() choice = input("Select a seed profile by number to switch: ").strip()
if not choice.isdigit() or not (1 <= int(choice) <= len(fingerprints)): if not choice.isdigit() or not (1 <= int(choice) <= len(fingerprints)):
print(colored("Invalid selection. Returning to main menu.", "red")) print(colored("Invalid selection. Returning to main menu.", "red"))
return False # Return False to indicate failure return False # Return False to indicate failure
@@ -294,26 +294,26 @@ class PasswordManager:
if not self.fingerprint_dir: if not self.fingerprint_dir:
print( print(
colored( colored(
f"Error: Fingerprint directory for {selected_fingerprint} not found.", f"Error: Seed profile directory for {selected_fingerprint} not found.",
"red", "red",
) )
) )
return False # Return False to indicate failure return False # Return False to indicate failure
# Prompt for master password for the selected fingerprint # Prompt for master password for the selected seed profile
password = prompt_existing_password("Enter your master password: ") password = prompt_existing_password("Enter your master password: ")
# Set up the encryption manager with the new password and fingerprint directory # Set up the encryption manager with the new password and seed profile directory
self.setup_encryption_manager(self.fingerprint_dir, password) self.setup_encryption_manager(self.fingerprint_dir, password)
# Load the parent seed for the selected fingerprint # Load the parent seed for the selected seed profile
self.load_parent_seed(self.fingerprint_dir) self.load_parent_seed(self.fingerprint_dir)
# Initialize BIP85 and other managers # Initialize BIP85 and other managers
self.initialize_bip85() self.initialize_bip85()
self.initialize_managers() self.initialize_managers()
self.sync_index_from_nostr_if_missing() self.sync_index_from_nostr_if_missing()
print(colored(f"Switched to fingerprint {selected_fingerprint}.", "green")) print(colored(f"Switched to seed profile {selected_fingerprint}.", "green"))
# Re-initialize NostrClient with the new fingerprint # Re-initialize NostrClient with the new fingerprint
try: try:
@@ -322,7 +322,7 @@ class PasswordManager:
fingerprint=self.current_fingerprint, fingerprint=self.current_fingerprint,
) )
logging.info( logging.info(
f"NostrClient re-initialized with fingerprint {self.current_fingerprint}." f"NostrClient re-initialized with seed profile {self.current_fingerprint}."
) )
except Exception as e: except Exception as e:
logging.error(f"Failed to re-initialize NostrClient: {e}") logging.error(f"Failed to re-initialize NostrClient: {e}")
@@ -334,9 +334,9 @@ class PasswordManager:
return True # Return True to indicate success return True # Return True to indicate success
except Exception as e: except Exception as e:
logging.error(f"Error during fingerprint switching: {e}") logging.error(f"Error during seed profile switching: {e}")
logging.error(traceback.format_exc()) logging.error(traceback.format_exc())
print(colored(f"Error: Failed to switch fingerprints: {e}", "red")) print(colored(f"Error: Failed to switch seed profiles: {e}", "red"))
return False # Return False to indicate failure return False # Return False to indicate failure
def handle_existing_seed(self) -> None: def handle_existing_seed(self) -> None:
@@ -355,22 +355,22 @@ class PasswordManager:
if not self.fingerprint_manager: if not self.fingerprint_manager:
self.initialize_fingerprint_manager() self.initialize_fingerprint_manager()
# Prompt the user to select an existing fingerprint # Prompt the user to select an existing seed profile
fingerprints = self.fingerprint_manager.list_fingerprints() fingerprints = self.fingerprint_manager.list_fingerprints()
if not fingerprints: if not fingerprints:
print( print(
colored( colored(
"No fingerprints available. Please add a fingerprint first.", "No seed profiles available. Please add a seed profile first.",
"red", "red",
) )
) )
sys.exit(1) sys.exit(1)
print(colored("Available Fingerprints:", "cyan")) print(colored("Available Seed Profiles:", "cyan"))
for idx, fp in enumerate(fingerprints, start=1): for idx, fp in enumerate(fingerprints, start=1):
print(colored(f"{idx}. {fp}", "cyan")) print(colored(f"{idx}. {fp}", "cyan"))
choice = input("Select a fingerprint by number: ").strip() choice = input("Select a seed profile by number: ").strip()
if not choice.isdigit() or not (1 <= int(choice) <= len(fingerprints)): if not choice.isdigit() or not (1 <= int(choice) <= len(fingerprints)):
print(colored("Invalid selection. Exiting.", "red")) print(colored("Invalid selection. Exiting.", "red"))
sys.exit(1) sys.exit(1)
@@ -381,7 +381,7 @@ class PasswordManager:
selected_fingerprint selected_fingerprint
) )
if not fingerprint_dir: if not fingerprint_dir:
print(colored("Error: Fingerprint directory not found.", "red")) print(colored("Error: Seed profile directory not found.", "red"))
sys.exit(1) sys.exit(1)
# Initialize EncryptionManager with key and fingerprint_dir # Initialize EncryptionManager with key and fingerprint_dir
@@ -442,7 +442,7 @@ class PasswordManager:
if not fingerprint: if not fingerprint:
print( print(
colored( colored(
"Error: Failed to generate fingerprint for the provided seed.", "Error: Failed to generate seed profile for the provided seed.",
"red", "red",
) )
) )
@@ -454,7 +454,7 @@ class PasswordManager:
if not fingerprint_dir: if not fingerprint_dir:
print( print(
colored( colored(
"Error: Failed to retrieve fingerprint directory.", "red" "Error: Failed to retrieve seed profile directory.", "red"
) )
) )
sys.exit(1) sys.exit(1)
@@ -463,7 +463,7 @@ class PasswordManager:
self.current_fingerprint = fingerprint self.current_fingerprint = fingerprint
self.fingerprint_manager.current_fingerprint = fingerprint self.fingerprint_manager.current_fingerprint = fingerprint
self.fingerprint_dir = fingerprint_dir self.fingerprint_dir = fingerprint_dir
logging.info(f"Current fingerprint set to {fingerprint}") logging.info(f"Current seed profile set to {fingerprint}")
# Initialize EncryptionManager with key and fingerprint_dir # Initialize EncryptionManager with key and fingerprint_dir
password = prompt_for_password() password = prompt_for_password()
@@ -514,7 +514,8 @@ class PasswordManager:
if not fingerprint: if not fingerprint:
print( print(
colored( colored(
"Error: Failed to generate fingerprint for the new seed.", "red" "Error: Failed to generate seed profile for the new seed.",
"red",
) )
) )
sys.exit(1) sys.exit(1)
@@ -524,14 +525,14 @@ class PasswordManager:
) )
if not fingerprint_dir: if not fingerprint_dir:
print( print(
colored("Error: Failed to retrieve fingerprint directory.", "red") colored("Error: Failed to retrieve seed profile directory.", "red")
) )
sys.exit(1) sys.exit(1)
# Set the current fingerprint in both PasswordManager and FingerprintManager # Set the current fingerprint in both PasswordManager and FingerprintManager
self.current_fingerprint = fingerprint self.current_fingerprint = fingerprint
self.fingerprint_manager.current_fingerprint = fingerprint self.fingerprint_manager.current_fingerprint = fingerprint
logging.info(f"Current fingerprint set to {fingerprint}") logging.info(f"Current seed profile set to {fingerprint}")
# Now, save and encrypt the seed with the fingerprint_dir # Now, save and encrypt the seed with the fingerprint_dir
self.save_and_encrypt_seed(new_seed, fingerprint_dir) self.save_and_encrypt_seed(new_seed, fingerprint_dir)