Module bdk_wallet::wallet::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::new(
    &import.descriptor(),
    &import.change_descriptor().expect("change descriptor"),
    Network::Testnet,
)?;

§Export a Wallet

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

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

Structs§

Type Aliases§