handshake-org / hsd

Handshake Daemon & Full Node
Other
1.93k stars 278 forks source link

wallet: resend() could be smarter #724

Open pinheadmz opened 2 years ago

pinheadmz commented 2 years ago

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

pinheadmz commented 2 years ago

Idea: hsd wallet could just have a --no-resend option and check it in walletDB.syncNode()

flikites commented 1 year ago

Sounds good enough. Have you thought of anything else?