From: Antoine Poinsot Date: Thu, 25 Jul 2024 14:51:16 +0000 (+0200) Subject: bdk_wallet: remove unnecessary calls to calc_checksum X-Git-Tag: v1.0.0-beta.2~18^2 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/database/scripts/struct.CheckPoint.html?a=commitdiff_plain;h=70c7d6b1c064103b359ad2e774a2648fbd85a414;p=bdk bdk_wallet: remove unnecessary calls to calc_checksum This code was: 1. Removing the checksum from the descriptor string, asserting it was present 2. Re-calculating the checksum on the descriptor string absent the checksum Instead, just use the existing checksum? If we don't trust it we probably shouldn't assert its presence in the first place. --- diff --git a/crates/wallet/src/wallet/mod.rs b/crates/wallet/src/wallet/mod.rs index df22c8a6..7217d32f 100644 --- a/crates/wallet/src/wallet/mod.rs +++ b/crates/wallet/src/wallet/mod.rs @@ -79,7 +79,7 @@ use utils::{check_nsequence_rbf, After, Older, SecpCtx}; use crate::descriptor::policy::BuildSatisfaction; use crate::descriptor::{ - self, calc_checksum, DerivedDescriptor, DescriptorMeta, ExtendedDescriptor, ExtractPolicy, + self, DerivedDescriptor, DescriptorMeta, ExtendedDescriptor, ExtractPolicy, IntoWalletDescriptor, Policy, XKeyUtils, }; use crate::psbt::PsbtUtils; @@ -2360,15 +2360,13 @@ where .into_wallet_descriptor(secp, network)? .0 .to_string(); - let mut wallet_name = calc_checksum(&descriptor[..descriptor.find('#').unwrap()])?; + let mut wallet_name = descriptor.split_once('#').unwrap().1.to_string(); if let Some(change_descriptor) = change_descriptor { let change_descriptor = change_descriptor .into_wallet_descriptor(secp, network)? .0 .to_string(); - wallet_name.push_str( - calc_checksum(&change_descriptor[..change_descriptor.find('#').unwrap()])?.as_str(), - ); + wallet_name.push_str(change_descriptor.split_once('#').unwrap().1); } Ok(wallet_name)