mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-10 08:42:59 +02:00
multi: add height-based invoice expiry
This commit adds height-based invoice expiry for hodl invoices that have active htlcs. This allows us to cancel our intentionally held htlcs before channels are force closed. We only add this for hodl invoices because we expect regular invoices to automatically be resolved. We still keep hodl invoices in the time-based expiry queue, because we want to expire open invoices that reach their timeout before any htlcs are added. Since htlcs are added after the invoice is created, we add new htlcs as they arrive in the invoice registry. In this commit, we allow adding of duplicate entries for an invoice to be added to the expiry queue as each htlc arrives to keep implementation simple. Our cancellation logic can already handle the case where an entry is already canceled, so this is ok.
This commit is contained in:
17
config.go
17
config.go
@@ -344,6 +344,8 @@ type Config struct {
|
||||
|
||||
GcCanceledInvoicesOnTheFly bool `long:"gc-canceled-invoices-on-the-fly" description:"If true, we'll delete newly canceled invoices on the fly."`
|
||||
|
||||
Invoices *lncfg.Invoices `group:"invoices" namespace:"invoices"`
|
||||
|
||||
Routing *lncfg.Routing `group:"routing" namespace:"routing"`
|
||||
|
||||
Gossip *lncfg.Gossip `group:"gossip" namespace:"gossip"`
|
||||
@@ -529,6 +531,9 @@ func DefaultConfig() Config {
|
||||
MaxChannelUpdateBurst: discovery.DefaultMaxChannelUpdateBurst,
|
||||
ChannelUpdateInterval: discovery.DefaultChannelUpdateInterval,
|
||||
},
|
||||
Invoices: &lncfg.Invoices{
|
||||
HoldExpiryDelta: lncfg.DefaultHoldInvoiceExpiryDelta,
|
||||
},
|
||||
MaxOutgoingCltvExpiry: htlcswitch.DefaultMaxOutgoingCltvExpiry,
|
||||
MaxChannelFeeAllocation: htlcswitch.DefaultMaxLinkFeeAllocation,
|
||||
MaxCommitFeeRateAnchors: lnwallet.DefaultAnchorsCommitMaxFeeRateSatPerVByte,
|
||||
@@ -1369,6 +1374,18 @@ func ValidateConfig(cfg Config, usageMessage string,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Log a warning if our expiry delta is not greater than our incoming
|
||||
// broadcast delta. We do not fail here because this value may be set
|
||||
// to zero to intentionally keep lnd's behavior unchanged from when we
|
||||
// didn't auto-cancel these invoices.
|
||||
if cfg.Invoices.HoldExpiryDelta <= lncfg.DefaultIncomingBroadcastDelta {
|
||||
ltndLog.Warnf("Invoice hold expiry delta: %v <= incoming "+
|
||||
"delta: %v, accepted hold invoices will force close "+
|
||||
"channels if they are not canceled manually",
|
||||
cfg.Invoices.HoldExpiryDelta,
|
||||
lncfg.DefaultIncomingBroadcastDelta)
|
||||
}
|
||||
|
||||
// Validate the subconfigs for workers, caches, and the tower client.
|
||||
err = lncfg.Validate(
|
||||
cfg.Workers,
|
||||
|
Reference in New Issue
Block a user