Skip to content

Commit

Permalink
Merge bitcoindevkit#1393: fix(export): add tr descriptor
Browse files Browse the repository at this point in the history
1b7c6df fix(export): add tr descriptor (rustaceanrob)

Pull request description:

  ### Description

  Resolves bitcoindevkit#860 by adding export of taproot descriptors

  ### Notes to the reviewers

  Allows export as Core accepts taproot.

  ### Changelog notice

  - Export taproot descriptors

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

  #### New Features:

  * [x] I've added tests for the new feature
  * [ ] I've added docs for the new feature

  #### Bugfixes:

  * [ ] This pull request breaks the existing API
  * [ ] I've added tests to reproduce the issue which are now passing
  * [x] I'm linking the issue being fixed by this PR

ACKs for top commit:
  notmandatory:
    ACK 1b7c6df

Tree-SHA512: 80bee93a1ec531717e79a5e7a91e840532ae4d3daf677a207bc53162c69410e47db4893024b3eccfd848f1628062e7c49f0e92ebeb7230e2ebb9b47eb84b9e56
  • Loading branch information
notmandatory committed May 23, 2024
2 parents 2a055de + 1b7c6df commit a2d9401
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions crates/wallet/src/wallet/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ impl FullyNodedExport {
WshInner::SortedMulti(_) => Ok(()),
WshInner::Ms(ms) => check_ms(&ms.node),
},
Descriptor::Tr(_) => Ok(()),
_ => Err("The descriptor is not compatible with Bitcoin Core"),
}
}
Expand Down Expand Up @@ -314,6 +315,18 @@ mod test {
assert_eq!(export.label, "Test Label");
}

#[test]
fn test_export_tr() {
let descriptor = "tr([73c5da0a/86'/0'/0']tprv8fMn4hSKPRC1oaCPqxDb1JWtgkpeiQvZhsr8W2xuy3GEMkzoArcAWTfJxYb6Wj8XNNDWEjfYKK4wGQXh3ZUXhDF2NcnsALpWTeSwarJt7Vc/0/*)";
let change_descriptor = "tr([73c5da0a/86'/0'/0']tprv8fMn4hSKPRC1oaCPqxDb1JWtgkpeiQvZhsr8W2xuy3GEMkzoArcAWTfJxYb6Wj8XNNDWEjfYKK4wGQXh3ZUXhDF2NcnsALpWTeSwarJt7Vc/1/*)";
let wallet = get_test_wallet(descriptor, Some(change_descriptor), Network::Testnet);
let export = FullyNodedExport::export_wallet(&wallet, "Test Label", true).unwrap();
assert_eq!(export.descriptor(), descriptor);
assert_eq!(export.change_descriptor(), Some(change_descriptor.into()));
assert_eq!(export.blockheight, 5000);
assert_eq!(export.label, "Test Label");
}

#[test]
fn test_export_to_json() {
let descriptor = "wpkh(xprv9s21ZrQH143K4CTb63EaMxja1YiTnSEWKMbn23uoEnAzxjdUJRQkazCAtzxGm4LSoTSVTptoV9RbchnKPW9HxKtZumdyxyikZFDLhogJ5Uj/44'/0'/0'/0/*)";
Expand Down

0 comments on commit a2d9401

Please sign in to comment.