mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-06 21:20:32 +02:00
multi: introduce config-level DustThreshold for defining threshold
This commit is contained in:
parent
3897baff0a
commit
702b3a3258
@ -355,6 +355,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."`
|
GcCanceledInvoicesOnTheFly bool `long:"gc-canceled-invoices-on-the-fly" description:"If true, we'll delete newly canceled invoices on the fly."`
|
||||||
|
|
||||||
|
DustThreshold uint64 `long:"dust-threshold" description:"Sets the dust sum threshold in satoshis for a channel after which dust HTLC's will be failed."`
|
||||||
|
|
||||||
Invoices *lncfg.Invoices `group:"invoices" namespace:"invoices"`
|
Invoices *lncfg.Invoices `group:"invoices" namespace:"invoices"`
|
||||||
|
|
||||||
Routing *lncfg.Routing `group:"routing" namespace:"routing"`
|
Routing *lncfg.Routing `group:"routing" namespace:"routing"`
|
||||||
@ -550,6 +552,7 @@ func DefaultConfig() Config {
|
|||||||
MaxOutgoingCltvExpiry: htlcswitch.DefaultMaxOutgoingCltvExpiry,
|
MaxOutgoingCltvExpiry: htlcswitch.DefaultMaxOutgoingCltvExpiry,
|
||||||
MaxChannelFeeAllocation: htlcswitch.DefaultMaxLinkFeeAllocation,
|
MaxChannelFeeAllocation: htlcswitch.DefaultMaxLinkFeeAllocation,
|
||||||
MaxCommitFeeRateAnchors: lnwallet.DefaultAnchorsCommitMaxFeeRateSatPerVByte,
|
MaxCommitFeeRateAnchors: lnwallet.DefaultAnchorsCommitMaxFeeRateSatPerVByte,
|
||||||
|
DustThreshold: uint64(htlcswitch.DefaultDustThreshold.ToSatoshis()),
|
||||||
LogWriter: build.NewRotatingLogWriter(),
|
LogWriter: build.NewRotatingLogWriter(),
|
||||||
DB: lncfg.DefaultDB(),
|
DB: lncfg.DefaultDB(),
|
||||||
Cluster: lncfg.DefaultCluster(),
|
Cluster: lncfg.DefaultCluster(),
|
||||||
|
@ -189,6 +189,7 @@ func initSwitchWithDB(startingHeight uint32, db *channeldb.DB) (*Switch, error)
|
|||||||
HtlcNotifier: &mockHTLCNotifier{},
|
HtlcNotifier: &mockHTLCNotifier{},
|
||||||
Clock: clock.NewDefaultClock(),
|
Clock: clock.NewDefaultClock(),
|
||||||
HTLCExpiry: time.Hour,
|
HTLCExpiry: time.Hour,
|
||||||
|
DustThreshold: DefaultDustThreshold,
|
||||||
}
|
}
|
||||||
|
|
||||||
return New(cfg, startingHeight)
|
return New(cfg, startingHeight)
|
||||||
|
@ -77,9 +77,9 @@ var (
|
|||||||
// threshold.
|
// threshold.
|
||||||
errDustThresholdExceeded = errors.New("dust threshold exceeded")
|
errDustThresholdExceeded = errors.New("dust threshold exceeded")
|
||||||
|
|
||||||
// defaultDustThreshold is the default threshold after which we'll fail
|
// DefaultDustThreshold is the default threshold after which we'll fail
|
||||||
// payments if they are dust. This is currently set to 500k sats.
|
// payments if they are dust. This is currently set to 500m msats.
|
||||||
defaultDustThreshold = lnwire.MilliSatoshi(500_000_000)
|
DefaultDustThreshold = lnwire.MilliSatoshi(500_000_000)
|
||||||
)
|
)
|
||||||
|
|
||||||
// plexPacket encapsulates switch packet and adds error channel to receive
|
// plexPacket encapsulates switch packet and adds error channel to receive
|
||||||
@ -187,6 +187,10 @@ type Config struct {
|
|||||||
// will expiry this long after the Adds are added to a mailbox via
|
// will expiry this long after the Adds are added to a mailbox via
|
||||||
// AddPacket.
|
// AddPacket.
|
||||||
HTLCExpiry time.Duration
|
HTLCExpiry time.Duration
|
||||||
|
|
||||||
|
// DustThreshold is the threshold in milli-satoshis after which we'll
|
||||||
|
// fail incoming or outgoing dust payments for a particular channel.
|
||||||
|
DustThreshold lnwire.MilliSatoshi
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch is the central messaging bus for all incoming/outgoing HTLCs.
|
// Switch is the central messaging bus for all incoming/outgoing HTLCs.
|
||||||
@ -2375,7 +2379,7 @@ func (s *Switch) evaluateDustThreshold(link ChannelLink,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Finally check against the defined dust threshold.
|
// Finally check against the defined dust threshold.
|
||||||
if localSum > defaultDustThreshold {
|
if localSum > s.cfg.DustThreshold {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2393,7 +2397,7 @@ func (s *Switch) evaluateDustThreshold(link ChannelLink,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Finally check against the defined dust threshold.
|
// Finally check against the defined dust threshold.
|
||||||
if remoteSum > defaultDustThreshold {
|
if remoteSum > s.cfg.DustThreshold {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,6 +203,7 @@ func TestLightningNetworkDaemon(t *testing.T) {
|
|||||||
// TODO(roasbeef): create master balanced channel with all the monies?
|
// TODO(roasbeef): create master balanced channel with all the monies?
|
||||||
aliceBobArgs := []string{
|
aliceBobArgs := []string{
|
||||||
"--default-remote-max-htlcs=483",
|
"--default-remote-max-htlcs=483",
|
||||||
|
"--dust-threshold=5000000",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the subset of the test cases selected in this tranche.
|
// Run the subset of the test cases selected in this tranche.
|
||||||
|
@ -365,6 +365,11 @@
|
|||||||
; propagation (default: 10)
|
; propagation (default: 10)
|
||||||
; max-commit-fee-rate-anchors=5
|
; max-commit-fee-rate-anchors=5
|
||||||
|
|
||||||
|
; A threshold defining the maximum amount of dust a given channel can have
|
||||||
|
; after which forwarding and sending dust HTLC's to and from the channel will
|
||||||
|
; fail. This amount is expressed in satoshis. (default: 500000)
|
||||||
|
; dust-threshold=1000000
|
||||||
|
|
||||||
; If true, lnd will abort committing a migration if it would otherwise have been
|
; If true, lnd will abort committing a migration if it would otherwise have been
|
||||||
; successful. This leaves the database unmodified, and still compatible with the
|
; successful. This leaves the database unmodified, and still compatible with the
|
||||||
; previously active version of lnd.
|
; previously active version of lnd.
|
||||||
|
@ -490,6 +490,9 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||||||
|
|
||||||
s.htlcNotifier = htlcswitch.NewHtlcNotifier(time.Now)
|
s.htlcNotifier = htlcswitch.NewHtlcNotifier(time.Now)
|
||||||
|
|
||||||
|
thresholdSats := btcutil.Amount(cfg.DustThreshold)
|
||||||
|
thresholdMSats := lnwire.NewMSatFromSatoshis(thresholdSats)
|
||||||
|
|
||||||
s.htlcSwitch, err = htlcswitch.New(htlcswitch.Config{
|
s.htlcSwitch, err = htlcswitch.New(htlcswitch.Config{
|
||||||
DB: dbs.chanStateDB,
|
DB: dbs.chanStateDB,
|
||||||
LocalChannelClose: func(pubKey []byte,
|
LocalChannelClose: func(pubKey []byte,
|
||||||
@ -519,6 +522,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||||||
RejectHTLC: cfg.RejectHTLC,
|
RejectHTLC: cfg.RejectHTLC,
|
||||||
Clock: clock.NewDefaultClock(),
|
Clock: clock.NewDefaultClock(),
|
||||||
HTLCExpiry: htlcswitch.DefaultHTLCExpiry,
|
HTLCExpiry: htlcswitch.DefaultHTLCExpiry,
|
||||||
|
DustThreshold: thresholdMSats,
|
||||||
}, uint32(currentHeight))
|
}, uint32(currentHeight))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user