use bip39::{Language, Mnemonic};
use nostr::Keys;
use nostr::nips::nip06::FromMnemonic;

pub fn english_mnemonic() -> Mnemonic {
    Mnemonic::generate_in(Language::English, 24).unwrap()
}

pub fn genkeys_with_mnemonic() -> Option<(Keys, Mnemonic)> {
    let mnemo = english_mnemonic();
    let wlist = mnemo.words().collect::<Vec<&str>>().join(" ");

    if let Ok(keys) = Keys::from_mnemonic(wlist, None) {
        Some((keys, mnemo))
    } else {
        None
    }
}
