feat: save user key to keyring
This commit is contained in:
@@ -8,3 +8,5 @@ gpui.workspace = true
|
||||
nostr-sdk.workspace = true
|
||||
dirs.workspace = true
|
||||
tokio.workspace = true
|
||||
keyring-search.workspace = true
|
||||
keyring.workspace = true
|
||||
|
||||
@@ -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(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user