get_checksum_bytes now checks input data for checksum

If `exclude_hash` is set, we split the input data, and if a checksum
already existed within the original data, we check the calculated
checksum against the original checksum.

Additionally, the implementation of `IntoWalletDescriptor` for `&str`
has been refactored for clarity.
This commit is contained in:
志宇
2022-09-29 13:06:03 +08:00
parent af0b3698c6
commit fd34956c29
3 changed files with 32 additions and 24 deletions

View File

@@ -1943,15 +1943,10 @@ pub(crate) mod test {
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);
assert_eq!(
get_checksum(&wallet.descriptor.to_string()).unwrap(),
checksum
);
}
#[test]