From fb3680672477b372daa93f32060f434208a0e39f Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Mon, 17 Jul 2023 12:53:26 +0200 Subject: [PATCH] peer: load initial forwarding policy from channel DB --- peer/brontide.go | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/peer/brontide.go b/peer/brontide.go index cd328ea10..a58a44292 100644 --- a/peer/brontide.go +++ b/peer/brontide.go @@ -3832,26 +3832,18 @@ func (p *Brontide) addActiveChannel(c *channeldb.OpenChannel) error { err) } - // We'll query the localChanCfg of the new channel to determine the - // minimum HTLC value that can be forwarded. For the maximum HTLC value - // that can be forwarded and fees we'll use the default values, as they - // currently are always set to the default values at initial channel - // creation. Note that the maximum HTLC value defaults to the cap on - // the total value of outstanding HTLCs. - fwdMinHtlc := lnChan.FwdMinHtlc() - defaultPolicy := p.cfg.RoutingPolicy - forwardingPolicy := &models.ForwardingPolicy{ - MinHTLCOut: fwdMinHtlc, - MaxHTLC: c.LocalChanCfg.MaxPendingAmount, - BaseFee: defaultPolicy.BaseFee, - FeeRate: defaultPolicy.FeeRate, - TimeLockDelta: defaultPolicy.TimeLockDelta, + // We'll query the channel DB for the new channel's initial forwarding + // policies to determine the policy we start out with. + initialPolicy, err := p.cfg.ChannelDB.GetInitialForwardingPolicy(chanID) + if err != nil { + return fmt.Errorf("unable to query for initial forwarding "+ + "policy: %v", err) } // Create the link and add it to the switch. err = p.addLink( - chanPoint, lnChan, forwardingPolicy, - chainEvents, shouldReestablish, + chanPoint, lnChan, initialPolicy, chainEvents, + shouldReestablish, ) if err != nil { return fmt.Errorf("can't register new channel link(%v) with "+