Skip to content

Commit 6b2e143

Browse files
committed
Simplify fingerprint checking
Only check the wallet to see if fingerprint matches
1 parent e7d4338 commit 6b2e143

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

rust/src/manager/import_wallet_manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl RustImportWalletManager {
120120
.get_all(network, mode)
121121
.unwrap_or_default()
122122
.into_iter()
123-
.find(|wallet_metadata| wallet_metadata.wallet_matches_fingerprint(fingerprint));
123+
.find(|wallet_metadata| wallet_metadata.matches_fingerprint(fingerprint));
124124

125125
if let Some(mut metadata) = existing_wallet {
126126
let id = metadata.id.clone();

rust/src/wallet/metadata.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -207,22 +207,9 @@ impl WalletMetadata {
207207
Self { network, verified: true, ..me }
208208
}
209209

210-
pub fn wallet_matches_fingerprint(&self, fingerprint: Fingerprint) -> bool {
211-
if let Some(saved_fingerprint) = self.master_fingerprint.as_ref()
212-
&& saved_fingerprint.as_ref() == &fingerprint
213-
{
214-
return true;
215-
}
216-
217-
// fallback to check fingerprint with the xpub stored in keychain
218-
let xpub = match Keychain::global().get_wallet_xpub(&self.id).ok().flatten() {
219-
Some(xpub) => xpub,
220-
None => return false,
221-
};
222-
223-
let saved_fingerprint = xpub.fingerprint();
224-
let saved_fingerprint_bytes: &[u8; 4] = saved_fingerprint.as_ref();
225-
saved_fingerprint_bytes == fingerprint.as_ref()
210+
pub fn matches_fingerprint(&self, fingerprint: Fingerprint) -> bool {
211+
let Some(wallet_fingerprint) = self.master_fingerprint.as_ref() else { return false };
212+
wallet_fingerprint.as_ref() == &fingerprint
226213
}
227214

228215
pub fn preview_new() -> Self {

0 commit comments

Comments
 (0)