-
Notifications
You must be signed in to change notification settings - Fork 329
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
Inconsistent KeychainTxOutIndex
state after db reload
#1788
Comments
I haven't fully grokked where the issue might have originated, but I'm a little confused about the use of |
I was thinking there may have been large gaps from handing out too many addresses but I just checked, and the largest gap in that wallet was only 3 addresses.
I suspect the logic assumes txs are included following the order of derivation index, but that’s not always true. Sorting outputs by chain position confirms this (derivation indexes are not sequential and have larger gaps confusing the wallet perhaps). Interestingly, if you modify the test to reorder txouts by derivation index, the issue disappears. |
Can this be reproduced with a non-memory, db file persistence? Sqlite has some strange behavior when using the memory store. |
I first encountered this issue with db file persistence, but the test uses an in-memory db for convenience. Same test also reproduces with file db |
Describe the bug
In wallets with slightly larger derivation gap, outputs spent at a higher derivation index are recognized inconsistently. After loading the wallet from sqlite, a spent output may be incorrectly reported as unspent leaving the wallet in unusable state. This appears to happen because
KeychainTxOutIndex
isn't consistently persisted/restored from the sqlite backend.To Reproduce
Tricky to reproduce! Here's a test using the higher level
Wallet
which consists of two transactions:tx1
creates some outputs with different gapstx2
spends an output with a larger gap.Wallet::load
, the wallet recognizes that output (it didn't previously). It's also incorrectly marked as unspent (because it didn't initially track the spend in tx2).Output
Expected behavior
As the test shows, the wallet should at least consistently ignore it. If it's not tracking it initially, it shouldn't track it after reload.
The text was updated successfully, but these errors were encountered: