multi: enforce routing.MinCLTVDelta=18 for invoices + chanupd
This commit clamps all user-chosen CLTVs in LND to be at least 18, which is the new conservative value used in the sepc. This minimum is applied uniformly to forwarding CLTV deltas (via channel updates) as well as final CLTV deltas for new invoices.
This commit is contained in:
5 files changed
+47
-18
No files matched your search
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/netann"
|
||||
"github.com/lightningnetwork/lnd/routing"
|
||||
"github.com/lightningnetwork/lnd/zpay32"
|
||||
)
|
||||
|
||||
@@ -228,6 +229,14 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,
|
||||
return nil, nil, fmt.Errorf("CLTV delta of %v is too large, max "+
|
||||
"accepted is: %v", invoice.CltvExpiry, math.MaxUint16)
|
||||
case invoice.CltvExpiry != 0:
|
||||
// Disallow user-chosen final CLTV deltas below the required
|
||||
// minimum.
|
||||
if invoice.CltvExpiry < routing.MinCLTVDelta {
|
||||
return nil, nil, fmt.Errorf("CLTV delta of %v must be "+
|
||||
"greater than minimum of %v",
|
||||
routing.MinCLTVDelta, invoice.CltvExpiry)
|
||||
}
|
||||
|
||||
options = append(options,
|
||||
zpay32.CLTVExpiry(invoice.CltvExpiry))
|
||||
default:
|
||||
|
||||
Reference in new issue
Block a user