Module bdk::wallet::export[][src]

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 = WalletExport::from_str(import)?;
let wallet = Wallet::new_offline(
    &import.descriptor(),
    import.change_descriptor().as_ref(),
    Network::Testnet,
    MemoryDatabase::default(),
)?;

Export a Wallet

let wallet = Wallet::new_offline(
    "wpkh([c258d2e4/84h/1h/0h]tpubDD3ynpHgJQW8VvWRzQ5WFDCrs4jqVFGHB3vLC3r49XHJSqP8bHKdK4AriuUKLccK68zfzowx7YhmDN8SiSkgCDENUFx9qVw65YyqM78vyVe/0/*)",
    Some("wpkh([c258d2e4/84h/1h/0h]tpubDD3ynpHgJQW8VvWRzQ5WFDCrs4jqVFGHB3vLC3r49XHJSqP8bHKdK4AriuUKLccK68zfzowx7YhmDN8SiSkgCDENUFx9qVw65YyqM78vyVe/1/*)"),
    Network::Testnet,
    MemoryDatabase::default()
)?;
let export = WalletExport::export_wallet(&wallet, "exported wallet", true)
    .map_err(ToString::to_string)
    .map_err(bdk::Error::Generic)?;

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

Structs

Structure that contains the export of a wallet