Walletwasabi: Look for consecutive unused addresses (gap limit)

Created on 16 Dec 2019  路  4Comments  路  Source: zkSNACKs/WalletWasabi

  1. Go to receive tab
  2. Generate 11 new addresses
  3. Send bitcoin to the 11th address (now there is 10 consecutive unused addresses)
  4. Generate 12 more new addresses (now there is 22 unused addresses in receive tab)
  5. Send bitcoin to the last generated address (now there is 21 unused addresses but only 11 consecutive unused addresses)
  6. Wait for the transactions to get confirmed then close Wasabi
  7. Open Wasabi, go to recover wallet, change the minimum gap limit to 21 and recover your wallet

When the wallet finishes loading you will see only one coin instead of two.

This is because when recovering a wallet Wasabi uses the minimum gap limit in order to stop looking for addresses if there are that many unused addresses, but it doesn't take into consideration that the unused addresses should be consecutive.

debug

Most helpful comment

Sorry @yahiheb, I did some progress with this issue because i think it is rather important. Please, review my PR and repeat your test with it. If you find a better solution just push it on top.

All 4 comments

Yes, that's true and you are right. Would you like to take this one? I think you should check that the number of consecutive keys are filled. Try with something like this:

```c#
// KeyManager.cs file

var keys = GetKeys(KeyState.Clean, true);
var consecutives = keys.Skip(1).Zip(keys, (curr, prev) => curr.Index == prev.Index + 1).Count(x=>x);

while (consecutives < MinGapLimit)
{
// generate one more
}
```

Yes, good catch!

Would you like to take this one?

Yes I will try.

Sorry @yahiheb, I did some progress with this issue because i think it is rather important. Please, review my PR and repeat your test with it. If you find a better solution just push it on top.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

trading2835 picture trading2835  路  3Comments

MaxHillebrand picture MaxHillebrand  路  3Comments

MaxHillebrand picture MaxHillebrand  路  3Comments

2pac1 picture 2pac1  路  3Comments

UkolovaOlga picture UkolovaOlga  路  3Comments