diff --git a/funding/manager.go b/funding/manager.go index c244076ef..9d8c300a5 100644 --- a/funding/manager.go +++ b/funding/manager.go @@ -1750,7 +1750,10 @@ func (f *Manager) handleFundingOpen(peer lnpeer.Peer, // If we are handling a FundingOpen request then we need to specify the // default channel fees since they are not provided by the responder // interactively. - forwardingPolicy := f.defaultForwardingPolicy() + ourContribution := reservation.OurContribution() + forwardingPolicy := f.defaultForwardingPolicy( + ourContribution.ChannelConstraints, + ) // Once the reservation has been created successfully, we add it to // this peer's map of pending reservations to track this particular @@ -1825,7 +1828,6 @@ func (f *Manager) handleFundingOpen(peer lnpeer.Peer, // With the initiator's contribution recorded, respond with our // contribution in the next message of the workflow. - ourContribution := reservation.OurContribution() fundingAccept := lnwire.AcceptChannel{ PendingChannelID: msg.PendingChannelID, DustLimit: ourContribution.DustLimit, @@ -4279,10 +4281,16 @@ func (f *Manager) handleInitFundingMsg(msg *InitFundingMsg) { maxHtlcs = f.cfg.RequiredRemoteMaxHTLCs(capacity) } + // Once the reservation has been created, and indexed, queue a funding + // request to the remote peer, kicking off the funding workflow. + ourContribution := reservation.OurContribution() + // Prepare the optional channel fee values from the initFundingMsg. If // useBaseFee or useFeeRate are false the client did not provide fee // values hence we assume default fee settings from the config. - forwardingPolicy := f.defaultForwardingPolicy() + forwardingPolicy := f.defaultForwardingPolicy( + ourContribution.ChannelConstraints, + ) if baseFee != nil { forwardingPolicy.BaseFee = lnwire.MilliSatoshi(*baseFee) } @@ -4291,10 +4299,6 @@ func (f *Manager) handleInitFundingMsg(msg *InitFundingMsg) { forwardingPolicy.FeeRate = lnwire.MilliSatoshi(*feeRate) } - // Once the reservation has been created, and indexed, queue a funding - // request to the remote peer, kicking off the funding workflow. - ourContribution := reservation.OurContribution() - // Fetch our dust limit which is part of the default channel // constraints, and log it. ourDustLimit := ourContribution.DustLimit @@ -4614,11 +4618,17 @@ func copyPubKey(pub *btcec.PublicKey) *btcec.PublicKey { return btcec.NewPublicKey(&tmp.X, &tmp.Y) } -// defaultForwardingPolicy returns the default forwarding policy. -func (f *Manager) defaultForwardingPolicy() *htlcswitch.ForwardingPolicy { +// defaultForwardingPolicy returns the default forwarding policy based on the +// default routing policy and our local channel constraints. +func (f *Manager) defaultForwardingPolicy( + constraints channeldb.ChannelConstraints) *htlcswitch.ForwardingPolicy { + return &htlcswitch.ForwardingPolicy{ - BaseFee: f.cfg.DefaultRoutingPolicy.BaseFee, - FeeRate: f.cfg.DefaultRoutingPolicy.FeeRate, + MinHTLCOut: constraints.MinHTLC, + MaxHTLC: constraints.MaxPendingAmount, + BaseFee: f.cfg.DefaultRoutingPolicy.BaseFee, + FeeRate: f.cfg.DefaultRoutingPolicy.FeeRate, + TimeLockDelta: f.cfg.DefaultRoutingPolicy.TimeLockDelta, } }