-
Notifications
You must be signed in to change notification settings - Fork 58
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
electrum: fix update of spend_txid for spending coins #1324
base: master
Are you sure you want to change the base?
Conversation
I think if the spending coin is already in the DB, the |
A regression test would demonstrate whether the fix is necessary. 🤷 |
Given that we iterate over the spending coins from the DB first and then the updated spending info, I think we will always use the correct value without this change as we'll first insert the wrong value and then the right value. I wasn't able to write a functional test to trigger this error. EDIT: Related to this, we should probably modify how the two iterators are chained together so that we only include spending coins from the DB if they're not part of the other, up-to-date iterator. We shouldn't be passing the same outpoint more than once to |
I think we should still include this change in the future so that we don't rely on the order of iteration. EDIT: As a test, I swapped the order of iteration and confirmed that my functional test fails without this PR and passes with it. EDIT: Note that the replacement tx needs to be broadcast externally to the wallet in order to trigger this failure. Otherwise, the poller runs when broadcasting and the new spend_txid is detected while the coin is still spending. |
a8bb0d3
to
7180245
Compare
I've pushed the functional test that would fail without this PR if the order of iteration of spending coins were reversed. |
If a replacement tx is not seen by Liana until it is confirmed, make sure the coin now confirmed as spent by the replacement has its spend_txid set correctly.
7180245
to
3aa296b
Compare
# The replacement has to be done externally so that Liana doesn't | ||
# see it until it is confirmed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would still see it when it's included in the mempool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should add to this comment that I stop and start lianad while the replacement is broadcast and confirmed to ensure that it isn't seen by Liana in the mempool.
I agree, looks like this code is only accidentally correct. |
If the spend txid of a coin changes, we should update with the new txid.
This would affect a spending coin for which the spending transaction changes and the new spend transaction is confirmed in a single poll.