9

I'm considering the development of a lightning app, and I'm trying to make it non custodial.

I was thinking on pre-generating invoices for all users every x time to make things simpler. To do that I'd need to extend the expiry date.

I tried to look up why do lightning invoices expire, and I couldn't find a clear answer.

Why do lightning invoices have an expiry date?

Is it to ensure that they are not kept forever in the receivers DB? or is there another reason?

1 Answer 1

7

The bolt 11 which specifies invoices does not give a rational for this design choice therefor - unless one of the people who build it come along - I can only give an educated guess:

So first of all if invoices were valid for an arbitrary time the recipient would have to keep an arbitrary amount of preimages running eventually into memory / Harddisk issues. I guess this is the single most important reason.

As another one lightning payments and routing with htlcs is an Atomic process it either works or it doesn't. Giving a constrained timebound you can decide afterwords for sure what the result was. If the expiry is arbitrary it could always be the case that the payment has just not been initiated yet.

Last I can imagine that sending nodes would eat up htlcs and the recipient might have already deleted the preimage (without expiry time) In this case the network also has unnecessary load.

Excited to see if other reasons pop up and excellent question

3
  • 2 excellent points: delete the stale ones for efficiency and have a way to know when they have been deleted by the receiver Apr 11, 2019 at 23:27
  • 2
    Another reason is that even non-Bitcoin businesses put expirations on their traditional-currency invoices so that they're not obligated to deliver goods in the future at the prices they offered in the past. With digital currencies, this is even more important because of exchange rate volatility. Apr 20, 2019 at 22:43
  • Of that is a good one! Do you mind me edditing this into my response? Also interestingly this is like the free call option Problem described by ZmnSCPxj and cjp Apr 22, 2019 at 4:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.