From 1b7c6df569a0ff9324bbda1f066938490109481d Mon Sep 17 00:00:00 2001 From: rustaceanrob Date: Wed, 27 Mar 2024 11:02:50 -1000 Subject: [PATCH] fix(export): add tr descriptor --- crates/wallet/src/wallet/export.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/wallet/src/wallet/export.rs b/crates/wallet/src/wallet/export.rs index 95d91193d..9eea7bd6a 100644 --- a/crates/wallet/src/wallet/export.rs +++ b/crates/wallet/src/wallet/export.rs @@ -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"), } } @@ -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/*)";