invoices: pre-check key send expiry

This commit is contained in:
Joost Jager 2020-01-10 21:35:10 +01:00
parent 0ce2d6f523
commit 59a7a9d308
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7

@ -736,6 +736,12 @@ func (i *InvoiceRegistry) processKeySend(ctx invoiceUpdateCtx,
// Use the minimum block delta that we require for settling htlcs.
finalCltvDelta := i.cfg.FinalCltvRejectDelta
// Pre-check expiry here to prevent inserting an invoice that will not
// be settled.
if ctx.expiry < uint32(ctx.currentHeight+finalCltvDelta) {
return errors.New("final expiry too soon")
}
// Create placeholder invoice.
invoice := &channeldb.Invoice{
CreationDate: i.cfg.Clock.Now(),