diff --git a/config.go b/config.go index 6e65afb7..f70785de 100644 --- a/config.go +++ b/config.go @@ -146,6 +146,7 @@ type autoPilotConfig struct { MinChannelSize int64 `long:"minchansize" description:"The smallest channel that the autopilot agent should create"` MaxChannelSize int64 `long:"maxchansize" description:"The largest channel that the autopilot agent should create"` Private bool `long:"private" description:"Whether the channels created by the autopilot agent should be private or not. Private channels won't be announced to the network."` + MinConfs int32 `long:"minconfs" description:"The minimum number of confirmations each of your inputs in funding transactions created by the autopilot agent must have."` } type torConfig struct { @@ -424,6 +425,12 @@ func loadConfig() (*config, error) { fmt.Fprintln(os.Stderr, err) return nil, err } + if cfg.Autopilot.MinConfs < 0 { + str := "%s: autopilot.minconfs must be non-negative" + err := fmt.Errorf(str, funcName) + fmt.Fprintln(os.Stderr, err) + return nil, err + } // Ensure that the specified values for the min and max channel size // don't are within the bounds of the normal chan size constraints. diff --git a/pilot.go b/pilot.go index 86c8ef5a..fa4e77ef 100644 --- a/pilot.go +++ b/pilot.go @@ -17,8 +17,9 @@ import ( // chanController is an implementation of the autopilot.ChannelController // interface that's backed by a running lnd instance. type chanController struct { - server *server - private bool + server *server + private bool + minConfs int32 } // OpenChannel opens a channel to a target peer, with a capacity of the @@ -48,6 +49,7 @@ func (c *chanController) OpenChannel(target *btcec.PublicKey, fundingFeePerKw: feePerKw, private: c.private, remoteCsvDelay: 0, + minConfs: c.minConfs, } updateStream, errChan := c.server.OpenChannel(req) @@ -110,11 +112,12 @@ func initAutoPilot(svr *server, cfg *autoPilotConfig) (*autopilot.Agent, error) Self: self, Heuristic: prefAttachment, ChanController: &chanController{ - server: svr, - private: cfg.Private, + server: svr, + private: cfg.Private, + minConfs: cfg.MinConfs, }, WalletBalance: func() (btcutil.Amount, error) { - return svr.cc.wallet.ConfirmedBalance(1) + return svr.cc.wallet.ConfirmedBalance(cfg.MinConfs) }, Graph: autopilot.ChannelGraphFromDatabase(svr.chanDB.ChannelGraph()), MaxPendingOpens: 10,