feat: save user key to keyring

This commit is contained in:
2024-11-21 09:03:48 +07:00
parent c60a37a245
commit 126506522d
6 changed files with 31 additions and 7 deletions

View File

@@ -8,3 +8,5 @@ gpui.workspace = true
nostr-sdk.workspace = true
dirs.workspace = true
tokio.workspace = true
keyring-search.workspace = true
keyring.workspace = true

View File

@@ -1,4 +1,5 @@
use gpui::Global;
use keyring::Entry;
use nostr_sdk::prelude::*;
use state::get_client;
@@ -17,4 +18,15 @@ impl NostrClient {
Self { client }
}
pub fn add_account(&self, keys: Keys) -> Result<()> {
let public_key = keys.public_key().to_bech32()?;
let secret = keys.secret_key().to_secret_hex();
let entry = Entry::new("Coop Safe Storage", &public_key)?;
// Add secret to keyring
entry.set_password(&secret)?;
Ok(())
}
}