prelim fns for edit profiles

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-01-03 17:38:47 -05:00
parent b1a84788ff
commit 5fd9f32ba7

View File

@@ -330,6 +330,14 @@ impl Accounts {
None
}
pub fn contains_full_kp(&self, pubkey: &enostr::Pubkey) -> bool {
if let Some(contains) = self.contains_account(pubkey.bytes()) {
contains.has_nsec
} else {
false
}
}
#[must_use = "UnknownIdAction's must be handled. Use .process_unknown_id_action()"]
pub fn add_account(&mut self, account: Keypair) -> AddAccountAction {
let pubkey = account.pubkey;
@@ -562,6 +570,18 @@ impl Accounts {
self.needs_relay_config = false;
}
}
pub fn get_full<'a>(&'a self, pubkey: &[u8; 32]) -> Option<FilledKeypair<'a>> {
if let Some(contains) = self.contains_account(pubkey) {
if contains.has_nsec {
if let Some(kp) = self.get_account(contains.index) {
return kp.to_full();
}
}
}
None
}
}
fn get_selected_index(accounts: &[UserAccount], keystore: &KeyStorageType) -> Option<usize> {