From 61e114f201e9a4425afdb395dc15830fb167fd71 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Mon, 25 Nov 2019 13:36:40 +0100 Subject: [PATCH] autopilot: take channel min htlc from config --- lnd.go | 2 +- pilot.go | 33 +++++++++++++++++---------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/lnd.go b/lnd.go index ccce8f9f..00041d7f 100644 --- a/lnd.go +++ b/lnd.go @@ -479,7 +479,7 @@ func Main(lisCfg ListenerCfg) error { // Set up an autopilot manager from the current config. This will be // used to manage the underlying autopilot agent, starting and stopping // it at will. - atplCfg, err := initAutoPilot(server, cfg.Autopilot) + atplCfg, err := initAutoPilot(server, cfg.Autopilot, mainChain) if err != nil { err := fmt.Errorf("Unable to initialize autopilot: %v", err) ltndLog.Error(err) diff --git a/pilot.go b/pilot.go index cc665073..59f05116 100644 --- a/pilot.go +++ b/pilot.go @@ -70,10 +70,11 @@ func validateAtplCfg(cfg *autoPilotConfig) ([]*autopilot.WeightedHeuristic, // chanController is an implementation of the autopilot.ChannelController // interface that's backed by a running lnd instance. type chanController struct { - server *server - private bool - minConfs int32 - confTarget uint32 + server *server + private bool + minConfs int32 + confTarget uint32 + chanMinHtlcIn lnwire.MilliSatoshi } // OpenChannel opens a channel to a target peer, with a capacity of the @@ -91,9 +92,6 @@ func (c *chanController) OpenChannel(target *btcec.PublicKey, return err } - // TODO(halseth): make configurable? - minHtlcIn := lnwire.NewMSatFromSatoshis(1) - // Construct the open channel request and send it to the server to begin // the funding workflow. req := &openChanReq{ @@ -102,7 +100,7 @@ func (c *chanController) OpenChannel(target *btcec.PublicKey, subtractFees: true, localFundingAmt: amt, pushAmt: 0, - minHtlcIn: minHtlcIn, + minHtlcIn: c.chanMinHtlcIn, fundingFeePerKw: feePerKw, private: c.private, remoteCsvDelay: 0, @@ -136,11 +134,13 @@ func (c *chanController) SpliceOut(chanPoint *wire.OutPoint, // autopilot.ChannelController interface. var _ autopilot.ChannelController = (*chanController)(nil) -// initAutoPilot initializes a new autopilot.ManagerCfg to manage an -// autopilot.Agent instance based on the passed configuration struct. The agent -// and all interfaces needed to drive it won't be launched before the Manager's +// initAutoPilot initializes a new autopilot.ManagerCfg to manage an autopilot. +// Agent instance based on the passed configuration structs. The agent and all +// interfaces needed to drive it won't be launched before the Manager's // StartAgent method is called. -func initAutoPilot(svr *server, cfg *autoPilotConfig) (*autopilot.ManagerCfg, error) { +func initAutoPilot(svr *server, cfg *autoPilotConfig, chainCfg *chainConfig) ( + *autopilot.ManagerCfg, error) { + atplLog.Infof("Instantiating autopilot with max_channels=%d, allocation=%f, "+ "min_chan_size=%d, max_chan_size=%d, private=%t, min_confs=%d, "+ "conf_target=%d", cfg.MaxChannels, cfg.Allocation, cfg.MinChannelSize, @@ -173,10 +173,11 @@ func initAutoPilot(svr *server, cfg *autoPilotConfig) (*autopilot.ManagerCfg, er Self: self, Heuristic: weightedAttachment, ChanController: &chanController{ - server: svr, - private: cfg.Private, - minConfs: cfg.MinConfs, - confTarget: cfg.ConfTarget, + server: svr, + private: cfg.Private, + minConfs: cfg.MinConfs, + confTarget: cfg.ConfTarget, + chanMinHtlcIn: chainCfg.MinHTLCIn, }, WalletBalance: func() (btcutil.Amount, error) { return svr.cc.wallet.ConfirmedBalance(cfg.MinConfs)