Caravan Wallet Format Import/Export¶
Overview
- Lead Developer: @vkprogrammer-001
- Ticket: #5
- Pull Request: #205
- Feature Type: Non-breaking
Overview¶
BDK now supports importing and exporting wallets using the Caravan multisig wallet format. A new CaravanExport struct handles serialization to and from Caravan's JSON configuration, making it straightforward to move multisig wallet configurations between BDK and Caravan-compatible coordinators.
Why Do This?¶
Caravan is a widely used stateless multisig coordinator. Teams building multisig workflows often need to share wallet configurations across tools. By supporting the Caravan format natively, BDK wallets can participate in Caravan-based multisig setups without requiring custom serialization code.
Exporting a Wallet to Caravan Format¶
use bdk_wallet::wallet::export::CaravanExport;
let export = CaravanExport::from_wallet(&wallet, "my-multisig")?;
let json = export.to_string();
println!("{}", json);
The resulting JSON can be loaded directly into Caravan to reconstruct the wallet configuration.
Importing a Caravan Config into BDK¶
use bdk_wallet::wallet::export::CaravanExport;
let json = std::fs::read_to_string("caravan-export.json")?;
let import = CaravanExport::from_str(&json)?;
let (descriptor, change_descriptor) = import.to_descriptors()?;
let wallet = Wallet::create(descriptor, change_descriptor)
.network(Network::Bitcoin)
.create_wallet_no_persist()?;