Merge pull request #3903 from joostjager/keysend-no-spam
invoices: streamline key send cltv delta picking and validation
This commit is contained in:
commit
91e796aed8
@ -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(),
|
||||||
|
@ -3535,7 +3535,11 @@ func (r *rpcServer) extractPaymentIntent(rpcPayReq *rpcPaymentRequest) (rpcPayme
|
|||||||
if rpcPayReq.FinalCltvDelta != 0 {
|
if rpcPayReq.FinalCltvDelta != 0 {
|
||||||
payIntent.cltvDelta = uint16(rpcPayReq.FinalCltvDelta)
|
payIntent.cltvDelta = uint16(rpcPayReq.FinalCltvDelta)
|
||||||
} else {
|
} else {
|
||||||
payIntent.cltvDelta = zpay32.DefaultFinalCLTVDelta
|
// If no final cltv delta is given, assume the default that we
|
||||||
|
// use when creating an invoice. We do not assume the default of
|
||||||
|
// 9 blocks that is defined in BOLT-11, because this is never
|
||||||
|
// enough for other lnd nodes.
|
||||||
|
payIntent.cltvDelta = uint16(cfg.Bitcoin.TimeLockDelta)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the user is manually specifying payment details, then the payment
|
// If the user is manually specifying payment details, then the payment
|
||||||
|
Loading…
Reference in New Issue
Block a user