htlcswitch+lnwallet+peer: default max htlc in fwding policy of new chans
In this commit, we set a default max HTLC in the forwarding policies of newly open channels. The ForwardingPolicy's MaxHTLC field (added in this commit) will later be used to decide whether an HTLC satisfies our policy before forwarding it. To ensure the ForwardingPolicy's MaxHTLC default matches the max HTLC advertised in the ChannelUpdate sent out for this channel, we also add a MaxPendingAmount() function to the lnwallet.Channel.
This commit is contained in:
parent
cbe0bf6a22
commit
20b3114100
@ -71,6 +71,9 @@ type ForwardingPolicy struct {
|
|||||||
// lifetime of the channel.
|
// lifetime of the channel.
|
||||||
MinHTLC lnwire.MilliSatoshi
|
MinHTLC lnwire.MilliSatoshi
|
||||||
|
|
||||||
|
// MaxHTLC is the largest HTLC that is to be forwarded.
|
||||||
|
MaxHTLC lnwire.MilliSatoshi
|
||||||
|
|
||||||
// BaseFee is the base fee, expressed in milli-satoshi that must be
|
// BaseFee is the base fee, expressed in milli-satoshi that must be
|
||||||
// paid for each incoming HTLC. This field, combined with FeeRate is
|
// paid for each incoming HTLC. This field, combined with FeeRate is
|
||||||
// used to compute the required fee for a given HTLC.
|
// used to compute the required fee for a given HTLC.
|
||||||
|
@ -6336,3 +6336,9 @@ func (lc *LightningChannel) RemoteCommitHeight() uint64 {
|
|||||||
func (lc *LightningChannel) FwdMinHtlc() lnwire.MilliSatoshi {
|
func (lc *LightningChannel) FwdMinHtlc() lnwire.MilliSatoshi {
|
||||||
return lc.localChanCfg.MinHTLC
|
return lc.localChanCfg.MinHTLC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MaxPendingAmount returns the maximum HTLC value that can be pending at
|
||||||
|
// any time over this channel.
|
||||||
|
func (lc *LightningChannel) MaxPendingAmount() lnwire.MilliSatoshi {
|
||||||
|
return lc.localChanCfg.MaxPendingAmount
|
||||||
|
}
|
||||||
|
12
peer.go
12
peer.go
@ -1670,15 +1670,17 @@ out:
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// We'll query the localChanCfg of the new channel to
|
// We'll query the localChanCfg of the new channel to determine the
|
||||||
// determine the minimum HTLC value that can be
|
// minimum HTLC value that can be forwarded. For the maximum HTLC
|
||||||
// forwarded. For fees we'll use the default values, as
|
// value that can be forwarded and fees we'll use the default
|
||||||
// they currently are always set to the default values
|
// values, as they currently are always set to the default values
|
||||||
// at initial channel creation.
|
// at initial channel creation. Note that the maximum HTLC value
|
||||||
|
// defaults to the cap on the total value of outstanding HTLCs.
|
||||||
fwdMinHtlc := lnChan.FwdMinHtlc()
|
fwdMinHtlc := lnChan.FwdMinHtlc()
|
||||||
defaultPolicy := p.server.cc.routingPolicy
|
defaultPolicy := p.server.cc.routingPolicy
|
||||||
forwardingPolicy := &htlcswitch.ForwardingPolicy{
|
forwardingPolicy := &htlcswitch.ForwardingPolicy{
|
||||||
MinHTLC: fwdMinHtlc,
|
MinHTLC: fwdMinHtlc,
|
||||||
|
MaxHTLC: lnChan.MaxPendingAmount(),
|
||||||
BaseFee: defaultPolicy.BaseFee,
|
BaseFee: defaultPolicy.BaseFee,
|
||||||
FeeRate: defaultPolicy.FeeRate,
|
FeeRate: defaultPolicy.FeeRate,
|
||||||
TimeLockDelta: defaultPolicy.TimeLockDelta,
|
TimeLockDelta: defaultPolicy.TimeLockDelta,
|
||||||
|
Loading…
Reference in New Issue
Block a user