Skip to content
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

Wallet transaction database corruption possible #930

Closed
braydonf opened this issue Jan 17, 2020 · 0 comments · Fixed by #931
Closed

Wallet transaction database corruption possible #930

braydonf opened this issue Jan 17, 2020 · 0 comments · Fixed by #931
Labels
bug Unexpected or incorrect behavior wallet Wallet related
Milestone

Comments

@braydonf
Copy link
Contributor

braydonf commented Jan 17, 2020

If there is an unexpected event, a crash, shutdown, power-loss or similar when a block is being added to the wallet, it can possibly lead to invalid state for the wallet with some transactions left unconfirmed or missing entirely.

The tip for the wallet is set before the transactions have been completely added. Thus if there is an issue, and the transactions are not added. The next startup will begin at the next block, instead adding the block again and adding all of the transactions.

The relevant lines of code are in addBlock of lib/wallet/walletdb.js:
https://github.com/bcoin-org/bcoin/blob/master/lib/wallet/walletdb.js#L1978-L1991

Those missing or unconfirmed transactions can then lead to cascading issues with other transactions failing to confirm from an assertion, assert(coin.height !== -1), in confirm() of lib/wallet/txdb.js: https://github.com/bcoin-org/bcoin/blob/master/lib/wallet/txdb.js#L663

@braydonf braydonf added bug Unexpected or incorrect behavior wallet Wallet related labels Jan 17, 2020
@braydonf braydonf added this to the v2.0.0 milestone Jan 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected or incorrect behavior wallet Wallet related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant