Skip to content

Commit

Permalink
bdk_wallet: remove unnecessary calls to calc_checksum
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
darosior committed Jul 27, 2024
1 parent 8245fb7 commit 70c7d6b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions crates/wallet/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 70c7d6b

Please sign in to comment.