I tried to implement the example from the cookbook, but I made a mistake somewhere. Or I misunderstood something https://solanacookbook.com/references/keypairs-and-wallets.html#how-to-restore-a-keypair-from-a-mnemonic-phrase
[dependencies]
bip39 = { version = "2.0.0", features = ["rand"] }
derivation-path = "0.2.0"
hdpath = "0.6.3"
slip10 = "0.4.3"
solana-sdk = { version = "2.0.8", features = ["curve25519-dalek"] }
tiny-hderive = "0.3.0"
main.rs
use bip39::{Language, Mnemonic};
// use derivation_path::{ChildIndex, DerivationPath};
use solana_sdk::derivation_path::DerivationPath;
use solana_sdk::signature::SeedDerivable;
use solana_sdk::signature::{Keypair, Signer};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mnemonic = "neither lonely flavor argue grass remind eye tag avocado spot unusual intact";
let mnemonic = Mnemonic::parse_in_normalized(Language::English, mnemonic)?;
let seed = mnemonic.to_seed("");
for i in 0..10 {
let path = format!("m/44'/501'/{}'/0'", i);
println!("{}", path);
let der_path = DerivationPath::try_from(path.as_str()).unwrap();
// let master = ExtendedPrivKey::derive(&seed, der_path).unwrap();
// let derived = master.derive(&path);
// let secret = SecretKey::from_bytes(&derived.secret())?;
let keypair = Keypair::from_seed_and_derivation_path(&seed, Some(der_path)).unwrap();
// let keypair = Keypair::from_bytes(&master)?;
let pubkey = keypair.pubkey();
println!("{} => {}", path, pubkey);
}
Ok(())
}