bdk_wallet

Module export

Source
Expand description

Wallet export

This modules implements the wallet export format used by FullyNoded.

§Examples

§Import from JSON

let import = r#"{
    "descriptor": "wpkh([c258d2e4\/84h\/1h\/0h]tpubDD3ynpHgJQW8VvWRzQ5WFDCrs4jqVFGHB3vLC3r49XHJSqP8bHKdK4AriuUKLccK68zfzowx7YhmDN8SiSkgCDENUFx9qVw65YyqM78vyVe\/0\/*)",
    "blockheight":1782088,
    "label":"testnet"
}"#;

let import = FullyNodedExport::from_str(import)?;
let wallet = Wallet::create(
    import.descriptor(),
    import.change_descriptor().expect("change descriptor"),
)
.network(Network::Testnet)
.create_wallet_no_persist()?;

§Export a Wallet

let wallet = Wallet::create(
    "wpkh([c258d2e4/84h/1h/0h]tpubDD3ynpHgJQW8VvWRzQ5WFDCrs4jqVFGHB3vLC3r49XHJSqP8bHKdK4AriuUKLccK68zfzowx7YhmDN8SiSkgCDENUFx9qVw65YyqM78vyVe/0/*)",
    "wpkh([c258d2e4/84h/1h/0h]tpubDD3ynpHgJQW8VvWRzQ5WFDCrs4jqVFGHB3vLC3r49XHJSqP8bHKdK4AriuUKLccK68zfzowx7YhmDN8SiSkgCDENUFx9qVw65YyqM78vyVe/1/*)",
)
.network(Network::Testnet)
.create_wallet_no_persist()?;
let export = FullyNodedExport::export_wallet(&wallet, "exported wallet", true).unwrap();

println!("Exported: {}", export.to_string());

Structs§

Type Aliases§