diff --git a/config.go b/config.go index 8242f0cd4..616636709 100644 --- a/config.go +++ b/config.go @@ -41,6 +41,7 @@ import ( "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/routing" "github.com/lightningnetwork/lnd/signal" + "github.com/lightningnetwork/lnd/sweep" "github.com/lightningnetwork/lnd/tor" ) @@ -439,6 +440,8 @@ type Config struct { RemoteSigner *lncfg.RemoteSigner `group:"remotesigner" namespace:"remotesigner"` + Sweeper *lncfg.Sweeper `group:"sweeper" namespace:"sweeper"` + // LogWriter is the root logger that all of the daemon's subloggers are // hooked up to. LogWriter *build.RotatingLogWriter @@ -635,6 +638,9 @@ func DefaultConfig() Config { RemoteSigner: &lncfg.RemoteSigner{ Timeout: lncfg.DefaultRemoteSignerRPCTimeout, }, + Sweeper: &lncfg.Sweeper{ + BatchWindowDuration: sweep.DefaultBatchWindowDuration, + }, } } @@ -1651,6 +1657,7 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser, cfg.HealthChecks, cfg.RPCMiddleware, cfg.RemoteSigner, + cfg.Sweeper, ) if err != nil { return nil, err diff --git a/lncfg/sweeper.go b/lncfg/sweeper.go new file mode 100644 index 000000000..5aed425bd --- /dev/null +++ b/lncfg/sweeper.go @@ -0,0 +1,19 @@ +package lncfg + +import ( + "fmt" + "time" +) + +type Sweeper struct { + BatchWindowDuration time.Duration `long:"batchwindowduration" description:"Duration of the sweep batch window. The sweep is held back during the batch window to allow more inputs to be added and thereby lower the fee per input."` +} + +// Validate checks the values configured for the sweeper. +func (s *Sweeper) Validate() error { + if s.BatchWindowDuration < 0 { + return fmt.Errorf("batchwindowduration must be positive") + } + + return nil +} diff --git a/sample-lnd.conf b/sample-lnd.conf index aed084167..3f9fb903d 100644 --- a/sample-lnd.conf +++ b/sample-lnd.conf @@ -1415,3 +1415,10 @@ litecoin.node=ltcd ; for neutrino nodes as it means they'll only maintain edges where both nodes are ; seen as being live from it's PoV. ; routing.strictgraphpruning=true + +[sweeper] + +; Duration of the sweep batch window. The sweep is held back during the batch +; window to allow more inputs to be added and thereby lower the fee per input. +; sweeper.batchwindowduration=30s + diff --git a/server.go b/server.go index cf8e8a52b..ad34055d5 100644 --- a/server.go +++ b/server.go @@ -1004,7 +1004,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr, Signer: cc.Wallet.Cfg.Signer, Wallet: cc.Wallet, NewBatchTimer: func() <-chan time.Time { - return time.NewTimer(sweep.DefaultBatchWindowDuration).C + return time.NewTimer(cfg.Sweeper.BatchWindowDuration).C }, Notifier: cc.ChainNotifier, Store: sweeperStore,