[wallet] Add fetch_index() helper function
This commit is contained in:
parent
dc83db273a
commit
fef6176275
@ -967,6 +967,20 @@ where
|
|||||||
Ok(index)
|
Ok(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn fetch_index(&self, keychain: KeychainKind) -> Result<u32, Error> {
|
||||||
|
let (descriptor, keychain) = self._get_descriptor_for_keychain(keychain);
|
||||||
|
let index = match descriptor.is_deriveable() {
|
||||||
|
false => Some(0),
|
||||||
|
true => self.database.borrow_mut().get_last_index(keychain)?,
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(i) = index {
|
||||||
|
Ok(i)
|
||||||
|
} else {
|
||||||
|
self.fetch_and_increment_index(keychain)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn cache_addresses(
|
fn cache_addresses(
|
||||||
&self,
|
&self,
|
||||||
keychain: KeychainKind,
|
keychain: KeychainKind,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user