Skip to content

fix(export): ignore unknown Caravan key fields, accept regtest/signet - #640

Open
saket0187 wants to merge 2 commits into
bitcoindevkit:masterfrom
saket0187:fix-caravan-import-real-configs
Open

saket0187 wants to merge 2 commits into
bitcoindevkit:masterfrom
saket0187:fix-caravan-import-real-configs

Conversation

@saket0187

@saket0187 saket0187 commented Nov 9, 2026 •

Copy link
Copy Markdown

CaravanExport::from_str rejected configs downloaded from Caravan: hardware-wallet keys carry a method field, and regtest configs use a network CaravanNetwork didn't accept. Unknown key fields are now ignored, as the derived CaravanExport already does, and regtest/signet parse as Testnet, matching From<bitcoin::Network>.

Changelog notice

- Fixed `CaravanExport::from_str` rejecting Caravan configs whose keys have extra fields such as `method`, or whose `network` is `regtest` or `signet` (both now parse as `CaravanNetwork::Testnet`).

@saket0187
saket0187 requested a review from a team as a code owner November 9, 2026 09:18
@github-project-automation github-project-automation Bot moved this to Triage in BDK Wallet Nov 9, 2026

@Jean-Regis-M Jean-Regis-M left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK 29371ef

On Windows (Rust 1.100), the Caravan tests pass (9). With the parent's export.rs implementation and the new tests kept, both new tests fail (test_caravan_network_regtest_and_signet and test_caravan_import_ignores_unknown_key_fields), so each one covers its fix. Ignoring unknown key fields through #[serde(other)] plus IgnoredAny matches how the derived CaravanExport already treats unknown top-level fields.

One thing to be aware of with the regtest/signet aliases. I checked the uses of CaravanNetwork in src/. It's only stored on CaravanExport::network and never converted back to a bitcoin::Network, so nothing builds a wallet on the wrong chain from it. The information is gone after parsing, though: a regtest config reads back as Testnet, and serializing the export again writes "network": "testnet". That's the same lossy mapping From<bitcoin::Network> already uses, so it's consistent. But a caller that reads export.network to choose a chain would end up on testnet for a regtest config. A line in the Testnet variant's doc (or the changelog) saying signet and regtest configs land there too, and that the original network isn't kept, would make that explicit. Adding real Signet/Regtest variants would be the lossless option, but that's a breaking change and probably not worth it here.

@Jean-Regis-M

Copy link
Copy Markdown

Correction to my note above: the Testnet doc comment already says "Any test network (testnet, signet or regtest)", which I missed. The only part that might still be worth a few words is that the original network isn't kept, so re-serializing writes "testnet".

@saket0187

Copy link
Copy Markdown
Author

Thanks for testing! Testnet doc now says signet/regtest configs serialize back as testnet.

@caarloshenriq caarloshenriq left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK 6b45b8f

A real Caravan regtest export (with uuid, ledgerPolicyHmacs, per key method) now imports. Keys added with method: "text" still fail, since Caravan writes "bip32Path": "Unknown (...)" for them. Probably a follow up.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

3 participants