handshake-org / handshake-org/hsd
wallet: resend() could be smarter
- Dominant language
- JavaScript
- Stars
- 2.1k
- Forks
- 306
- PR merge metrics
- No merged PRs in 30d
Description
Scenario: you switch from full node to spv node or replace your blockchain db or something that causes the chain to restart at some low height (like 0) but you keep your walletDB. What happens is, the wdb internally unconfirms ALL txs, then when it gets reopened (maybe after a restart) it tries to resend your entire TX history, thinking everything is just pending:
https://github.com/handshake-org/hsd/blob/f28fb9edcf34e78433e4da316d42e82d0d42ee46/lib/wallet/walletdb.js#L1661-L1677
We could probably be smarter about this, and hold off on the `resend()` if we can determine that the chain's height is way behind the walletdb height
Contributor guide
Research direction
Start in lib/wallet/walletdb.js at lines 1661-1677 and trace the resend() path used when the wallet database reopens. Compare the chain height with the walletdb height in the described restart scenario. Done means resend is deferred when the chain is far behind, while normal reopening still resends transactions appropriately.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend, blockchain
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100