invoices: pre-check key send expiry
This commit is contained in:
1 file changed
+6
@@ -736,6 +736,12 @@ func (i *InvoiceRegistry) processKeySend(ctx invoiceUpdateCtx,
|
|||||||
// Use the minimum block delta that we require for settling htlcs.
|
// Use the minimum block delta that we require for settling htlcs.
|
||||||
finalCltvDelta := i.cfg.FinalCltvRejectDelta
|
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.
|
// Create placeholder invoice.
|
||||||
invoice := &channeldb.Invoice{
|
invoice := &channeldb.Invoice{
|
||||||
CreationDate: i.cfg.Clock.Now(),
|
CreationDate: i.cfg.Clock.Now(),
|
||||||
|
|||||||
Reference in new issue
Block a user