Doing "stop gap" like logic when scanning through blocks is annoying with the current API because we conflate with the "index which I will give out next address I will give out" with the "index I derive scripts up to so I can find outputs for them". Just like bdk already does we can have a kind of look ahead to make this easier.
The API should be:
`set_lookahead(keychain: &K, look_head: u32)
set_all_lookaheads(look_ahead: u32)
lookaheads(&self) -> &BTreeMap<K, u32>
Then the KeychainTxOutIndex should just make sure that it is has always inserted lookahead more spks into the inner SpkTxOutIndex. scan will also need to return the updated DerivationAdditions for each call since now scannig can increase your derivation index.
We can also remove store_* methods from the API and rebrand them to set_derivation_index which should also return a DerivationAdditions.
Doing "stop gap" like logic when scanning through blocks is annoying with the current API because we conflate with the "index which I will give out next address I will give out" with the "index I derive scripts up to so I can find outputs for them". Just like
bdk
already does we can have a kind of look ahead to make this easier.The API should be:
set_all_lookaheads(look_ahead: u32)
lookaheads(&self) -> &BTreeMap<K, u32>
Then the
KeychainTxOutIndex
should just make sure that it is has always insertedlookahead
more spks into the innerSpkTxOutIndex
.scan
will also need to return the updatedDerivationAdditions
for each call since now scannig can increase your derivation index.We can also remove
store_*
methods from the API and rebrand them toset_derivation_index
which should also return aDerivationAdditions
.