Question: Invoice.is_confirmed vs is_expired
Closed this issue ยท 2 comments
I just wanted to check what the behavior is for a flow in which the user pays right before expiration, say:
Invoice created, 2 confirmations required, 15 block expiration.
Payment is received on block 14 or even 15 which will take until block 16 or 17 to confirm. Does the library stop tracking invoices at the expiration block or only when you call remove_invoice?
I ask because in the examples you have one loop that just removes invoices irrespective of any payment that might be waiting on confirmations. Is that because you created the invoices to expire in 5 blocks and the remover loop at 30?
Thanks!
Hey, great question! The library will continue tracking invoices until you remove them with remove_invoice
.
The expiration field exists to make cleaning up old invoices easier, but your implementation decides the details of when invoices actually stop being tracked.
This behavior is briefly mentioned in the docs here: https://docs.rs/acceptxmr/latest/acceptxmr/struct.Invoice.html
The text is:
Invoices have an expiration block, after which they are considered expired. However, note that the payment gateway by default will continue updating invoices even after expiration.
I do my best to keep that documentation up-to-date, so 99% of questions can probably be answered by it. If you have any suggestions to improve the docs, please let me know (or feel free to make a PR if you're feeling motivated!).
Thanks! I've spent a lot of time in the docs, and they've been very helpful. I missed this one though. :( So sorry for that.
I appreciate the answer. :)