From af0b3698c691cd08ece9ae201cc9699f0d57acc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=97=E5=AE=87?= Date: Tue, 27 Sep 2022 21:56:25 +0800 Subject: [PATCH] Fix `Wallet::descriptor_checksum` to actually return the checksum --- src/wallet/mod.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/wallet/mod.rs b/src/wallet/mod.rs index 88fcecff..2e3d9fdf 100644 --- a/src/wallet/mod.rs +++ b/src/wallet/mod.rs @@ -1842,7 +1842,7 @@ where .to_string() .split_once('#') .unwrap() - .0 + .1 .to_string() } } @@ -1938,6 +1938,22 @@ pub(crate) mod test { // OP_PUSH. const P2WPKH_FAKE_WITNESS_SIZE: usize = 106; + #[test] + fn test_descriptor_checksum() { + let (wallet, _, _) = get_funded_wallet(get_test_wpkh()); + let checksum = wallet.descriptor_checksum(KeychainKind::External); + assert_eq!(checksum.len(), 8); + + let raw_descriptor = wallet + .descriptor + .to_string() + .split_once('#') + .unwrap() + .0 + .to_string(); + assert_eq!(get_checksum(&raw_descriptor).unwrap(), checksum); + } + #[test] fn test_get_funded_wallet_balance() { let (wallet, _, _) = get_funded_wallet(get_test_wpkh());