From: 志宇 Date: Tue, 27 Sep 2022 13:56:25 +0000 (+0800) Subject: Fix `Wallet::descriptor_checksum` to actually return the checksum X-Git-Tag: v0.23.0-rc.1~2^2 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/enum.FileStoreError.html?a=commitdiff_plain;h=af0b3698c691cd08ece9ae201cc9699f0d57acc8;p=bdk Fix `Wallet::descriptor_checksum` to actually return the checksum --- 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());