fix(electrum): fix a bug with broadcast #830
Open
+69
−23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description and Notes
In #698 small bug where our node would stop responding during start-up, on very specific conditions was introduced.
If we broadcast a transaction and shutdown floresta before it gets confirmed, then try to start floresta again, we would get stuck. This happens because electrum would try to use the node handle to broadcast a transaction, but since
FlorestaNodewouldn't be running, the electrum server would never get an answer, blocking forever.This commit fixes this by moving the re-broadcast to then main loop. Now the re-broadcast code will try to broadcast again every 24 hours, until the tx gets confirmed. This makes sure our transaction won't fall off the mempool. It also only broadcasts after the node left IBD, to avoid having a transaction that gets stuck inside our mempool due to it already being confirmed.
I've also made all ElectrumServer's field private, there's no reason for them to be public.
How to verify the changes you have done?
To reproduce the bug: broadcast a transaction that spends from/to a cached address, then before it confirms, shut
florestaddown gracefully. When you restart it, it won't go past a log message about the RPC being up. On this branch it should start as expected.