-
Notifications
You must be signed in to change notification settings - Fork 268
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
Reject received payments where PaymentRequest Expiry Tag time has been exceeded. #749
Conversation
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.
Nice! And choosing to return an unknown payment hash
is consistent with our current behaviour. Just a few minor formatting changes/typos to fix and we're good. Thanks!
eclair-core/src/main/scala/fr/acinq/eclair/payment/LocalPaymentHandler.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/LocalPaymentHandler.scala
Outdated
Show resolved
Hide resolved
Expiry Tag time has been exceeded. Fixes ACINQ#748
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.
How about implementing this like so (loosely inspired by how guava's cleanes stale cache entries), that would result in a single path to UnknownPaymentHash
:
- Put the following code in a separate
purgeExpiredRequests
method:
hash2preimage.collect {
case e@(_, (_, pr)) if pr.expiry.isEmpty => e // requests that don't expire are kept forever
case e@(_, (_, pr)) if pr.timestamp + pr.expiry.get > currentSeconds => e // clean up expired requests
})
- Create a
PurgeExpiredRequests
object to make the intent obvious:
case PurgeExpiredRequests =>
context.become(run(purgeExpiredRequests(hash2preimage)))
- In the handler for
UpdateAddHtlc
, use the newly created method:
purgeExpiredRequests(hash2preimage.get(htlc.paymentHash)) match {
Not sure this is any better/clearer. I think I have done what you suggested. |
I took the liberty to commit a new version that addresses your concerns. WDYT? |
requested changes have been made, format is now correct
Fixes #748