Open NicolaLS opened 1 month ago
Related to #1395.
I think it's possible to have the equivalent of generate_in_with
currently in BDK (assuming "keys-bip39" and "std" features are enabled)
fn main() {
use bdk_wallet::bip39::Mnemonic;
use bdk_wallet::bitcoin::key::rand::thread_rng;
use bdk_wallet::keys::bip39::{Language, WordCount};
use bdk_wallet::keys::{GeneratableKey, GeneratedKey};
use bdk_wallet::miniscript::Tap;
let mnemonic: GeneratedKey<Mnemonic, Tap> = Mnemonic::generate_with_aux_rand(
(WordCount::Words12, Language::English),
&mut thread_rng(),
)
.expect("should work");
println!("{}", *mnemonic);
}
But since this is not immediately obvious, I'm also in favor of enabling bip39/rand_core
by default, so something like
[features]
keys-bip39 = ["bip39/rand_core"]
Describe the enhancement
Enable rust-bip39
rand
feature by default or using another feature onbdk_wallet
. This will make generate_with_in method available.Use case
Provide the full API of rust-bip39 for developers that want to use
bdk_wallet
to crate bip39 mnemonics and don't want to worry about creating the entropy themselves. Instead of having to implement logic to create some entropy from 12-24 words, developers could usebdk_wallet::keys::bip39::Mnemonic::generate_in_with(&mut rng, Language::English, 24)
.Additional context
bdk_wallet
re-exports rust-bip39 but does not provide its full functionality because rust-bip39 maderand_core
andrand
optional dependencies in this commit.bdk_wallet
already depends onrand_core
(0.6.0)Suggested solution Either enable
rand
per default:Or enable it with another feature: