-
Notifications
You must be signed in to change notification settings - Fork 47
account+rpcserver: bump account key index on recovery #373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
account/recovery.go
Outdated
|
||
log.Debugf("Account %s already has %d external keys (want "+ | ||
"minimum index %d), not deriving any keys", | ||
poolAccountsPath, poolAccountsAccount.ExternalKeyCount, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess wallet.ListAccounts
returns them in increasing order so we have the last one here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it returns them in order, but there are more than 255 and we want one towards the back (key family 220).
} | ||
|
||
log.Debugf("Derived next account key with index %d", key.Index) | ||
if key.Index >= minimumIndex { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Do we want to end up with the last key being minimumIndex
or the next one? Before we were comparing with poolAccountsAccount.ExternalKeyCount > minimumIndex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above it's the key count while here it's the derived index. So the count is always one higher than the index. Added a comment above to make it a bit more clear.
Fixes #372. This commit fixes the issue that if the lnd node the trader client is connected to was also restored from seed, it is starting at account key derivation index 0. So when recovering accounts we need to make sure we re-derive the right number of keys from the wallet in order to allow properly creating new accounts with the recovered node.
94de789
to
1ba717c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, straightforward fix 💯
Fixes #372.
This commit fixes the issue that if the lnd node the trader client is
connected to was also restored from seed, it is starting at account key
derivation index 0. So when recovering accounts we need to make sure we
re-derive the right number of keys from the wallet in order to allow
properly creating new accounts with the recovered node.
Pull Request Checklist
used.