Skip to content

Commit 413b3ce

Browse files
committed
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.
1 parent 20b5d0c commit 413b3ce

File tree

1 file changed

+3
-5
lines changed
  • crates/wallet/src/wallet

1 file changed

+3
-5
lines changed

crates/wallet/src/wallet/mod.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ use utils::{check_nsequence_rbf, After, Older, SecpCtx};
7979

8080
use crate::descriptor::policy::BuildSatisfaction;
8181
use crate::descriptor::{
82-
self, calc_checksum, DerivedDescriptor, DescriptorMeta, ExtendedDescriptor, ExtractPolicy,
82+
self, DerivedDescriptor, DescriptorMeta, ExtendedDescriptor, ExtractPolicy,
8383
IntoWalletDescriptor, Policy, XKeyUtils,
8484
};
8585
use crate::psbt::PsbtUtils;
@@ -2360,15 +2360,13 @@ where
23602360
.into_wallet_descriptor(secp, network)?
23612361
.0
23622362
.to_string();
2363-
let mut wallet_name = calc_checksum(&descriptor[..descriptor.find('#').unwrap()])?;
2363+
let mut wallet_name = descriptor.split_once('#').unwrap().1.to_string();
23642364
if let Some(change_descriptor) = change_descriptor {
23652365
let change_descriptor = change_descriptor
23662366
.into_wallet_descriptor(secp, network)?
23672367
.0
23682368
.to_string();
2369-
wallet_name.push_str(
2370-
calc_checksum(&change_descriptor[..change_descriptor.find('#').unwrap()])?.as_str(),
2371-
);
2369+
wallet_name.push_str(change_descriptor.split_once('#').unwrap().1);
23722370
}
23732371

23742372
Ok(wallet_name)

0 commit comments

Comments
 (0)