MCPcopy Create free account
hub / github.com/bwt-dev/bwt / find_gap

Method find_gap

src/wallet.rs:406–424  ·  view source on GitHub ↗
(&self, store: &MemoryStore)

Source from the content-addressed store, hash-verified

404 }
405
406 pub fn find_gap(&self, store: &MemoryStore) -> Option<usize> {
407 // return None if this wallet has no history at all
408 let max_funded_index = self.max_funded_index?;
409
410 Some(if self.is_wildcard {
411 (0..=max_funded_index)
412 .map(|derivation_index| self.derive_address(derivation_index))
413 .fold((0, 0), |(curr_gap, max_gap), address| {
414 if store.has_history(&address.into()) {
415 (0, curr_gap.max(max_gap))
416 } else {
417 (curr_gap + 1, max_gap)
418 }
419 })
420 .1
421 } else {
422 0
423 })
424 }
425
426 /// Get the bip32 origins of the public keys used at the provided index
427 pub fn bip32_origins(&self, index: u32) -> Vec<Bip32Origin> {

Callers 1

find_wallet_gapMethod · 0.80

Calls 3

derive_addressMethod · 0.80
has_historyMethod · 0.80
intoMethod · 0.80

Tested by

no test coverage detected