keyfork/crates/util/keyfork-prompt/examples/test-basic-prompt.rs

27 lines
622 B
Rust

#![allow(missing_docs)]
use keyfork_prompt::{
prompt_validated_wordlist,
validators::{mnemonic, Validator},
default_handler,
};
use keyfork_mnemonic::English;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut handler = default_handler().unwrap();
let transport_validator = mnemonic::MnemonicSetValidator {
word_lengths: [24],
};
let mnemonics = prompt_validated_wordlist::<English, _>(
&mut *handler,
"Enter a 24-word mnemonic: ",
3,
&*transport_validator.to_fn(),
)?;
assert_eq!(mnemonics[0].as_bytes().len(), 32);
Ok(())
}