Save keys after importing

This commit is contained in:
Mike Dilger 2022-12-28 07:30:22 +13:00
parent dac14cceeb
commit 7d2985def1
2 changed files with 28 additions and 8 deletions

View File

@ -414,6 +414,15 @@ impl Overlord {
signer.unlock_encrypted_private_key(&password)?;
}
password.zeroize();
// Save
let public_key = GLOBALS.signer.read().await.public_key().unwrap();
{
let mut settings = GLOBALS.settings.write().await;
settings.encrypted_private_key = Some(epk);
settings.public_key = Some(public_key);
settings.save().await?;
}
}
"import_hex" => {
let (mut import_hex, mut password): (String, String) =
@ -427,6 +436,15 @@ impl Overlord {
signer.unlock_encrypted_private_key(&password)?;
}
password.zeroize();
// Save
let public_key = GLOBALS.signer.read().await.public_key().unwrap();
{
let mut settings = GLOBALS.settings.write().await;
settings.encrypted_private_key = Some(epk);
settings.public_key = Some(public_key);
settings.save().await?;
}
}
_ => {}
},

View File

@ -17,17 +17,19 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Fram
};
ui.horizontal(|ui| {
ui.text_edit_multiline(&mut app.draft);
if GLOBALS.signer.blocking_read().is_ready() {
ui.text_edit_multiline(&mut app.draft);
if ui.button("Send").clicked() && !app.draft.is_empty() {
info!("Would send: {}", app.draft);
if ui.button("Send").clicked() && !app.draft.is_empty() {
info!("Would send: {}", app.draft);
// We need our private key
// Then we need to create a TextNote event
// Then we need to send it to multiple relays
// NOT a one-liner
// We need our private key
// Then we need to create a TextNote event
// Then we need to send it to multiple relays
// NOT a one-liner
app.draft = "".to_owned();
app.draft = "".to_owned();
}
}
ui.with_layout(Layout::right_to_left(Align::TOP), |ui| {