Fix race condition in BTC sent confirmation popup #5333
Merged
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.
Fixes #5331, Fixes #5305
There is a race condition with the BTC display of the sent confirmation popup. The address field and senders amount were obtained from GUI input elements which are cleared after a transaction has been sent. So the fields could be empty when the confirmation popup is shown after the wallet calls back with success.
Solution is to move a variable
sendersAmount
from class scope to method scope and make it final. Likewise thewithdrawToAddress
must be defined in method scope so that the method does not access the GUI input field after it has been cleared.The problem does not occur for displaying BSQ sent transactions, because the relevant parameters are already method-scoped and immutable.
Testing
The issue can be reproduced consistently if you introduce a delay of 1 second in the processing of the wallet OnSuccess callback.
It helps verify that the fix works correctly. (The delay was for testing/verification only, not included in PR).