From b62e80c3c2427825ae04f1e81505cc24998dc25c Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Sun, 29 Jun 2025 15:11:59 -0400 Subject: [PATCH] Backup to Nostr after adding entries --- src/password_manager/manager.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/password_manager/manager.py b/src/password_manager/manager.py index 6fcbf0c..c891417 100644 --- a/src/password_manager/manager.py +++ b/src/password_manager/manager.py @@ -736,11 +736,25 @@ class PasswordManager: # Provide user feedback print( colored( - f"\n[+] Password generated and indexed with ID {index}.\n", "green" + f"\n[+] Password generated and indexed with ID {index}.\n", + "green", ) ) print(colored(f"Password for {website_name}: {password}\n", "yellow")) + # Automatically push the updated encrypted index to Nostr so the + # latest changes are backed up remotely. + try: + encrypted_data = self.get_encrypted_data() + if encrypted_data: + self.nostr_client.publish_json_to_nostr(encrypted_data) + logging.info( + "Encrypted index posted to Nostr after entry addition." + ) + except Exception as nostr_error: + logging.error(f"Failed to post updated index to Nostr: {nostr_error}") + logging.error(traceback.format_exc()) + except Exception as e: logging.error(f"Error during password generation: {e}") logging.error(traceback.format_exc())