2024-07-24 16:18:41 +01:00
|
|
|
use bdk::{
|
|
|
|
|
bitcoin::Network, database::MemoryDatabase, keys::ExtendedKey, template::Bip84, KeychainKind,
|
|
|
|
|
Wallet,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Re-enable this if we want to use alongside a fullnode.
|
2024-06-25 13:38:23 +01:00
|
|
|
pub mod electrum;
|
|
|
|
|
pub mod esplora;
|
2024-07-24 16:18:41 +01:00
|
|
|
|
|
|
|
|
/// Create a BDK wallet using BIP 84 descriptor ("m/84h/1h/0h/0" and "m/84h/1h/0h/1")
|
|
|
|
|
pub fn create_wallet(xkey: ExtendedKey) -> anyhow::Result<Wallet<MemoryDatabase>> {
|
|
|
|
|
let xprv = xkey
|
|
|
|
|
.into_xprv(Network::Testnet)
|
|
|
|
|
.expect("couldn't turn xkey into xprv");
|
|
|
|
|
|
|
|
|
|
let external_descriptor = Bip84(xprv, KeychainKind::External);
|
|
|
|
|
let internal_descriptor = Some(Bip84(xprv, KeychainKind::Internal));
|
|
|
|
|
|
|
|
|
|
let wallet = Wallet::new(
|
|
|
|
|
external_descriptor,
|
|
|
|
|
internal_descriptor,
|
|
|
|
|
Network::Testnet,
|
|
|
|
|
MemoryDatabase::default(),
|
|
|
|
|
)?;
|
|
|
|
|
|
|
|
|
|
Ok(wallet)
|
|
|
|
|
}
|