fix(lightning): proper handle timeouts while receiving a payment #3963
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.
#3929 was a mess:
It required fix(client): missing expiry time #3955
It still doesn't fully solve the timeout handling as it calls
context.wait_key_exists(ContractKey(contract_id))
which will block until a payment has been received.In this situation the client will never timeout because a timeout will be considered an error and it will keep retrying.
It still considers that a
DecryptedPreimage::Pending
is a good moment to timeout. But in fact if we gotDecryptedPreimage::Pending
the payment may still succeed, so we can't timeout here.This PR tries to fix these issues. It also introduces tests for the expiration time check.
Note: this PR should be fully compatible with previous releases. We are just properly using an existing endpoint to solve the issue on the client-side.