Skip to content

Commit

Permalink
lndclient: add inbound fee support to the lightning client
Browse files Browse the repository at this point in the history
  • Loading branch information
bhandras authored and guggero committed Aug 26, 2024
1 parent 76ebee9 commit d79458d
Showing 1 changed file with 39 additions and 7 deletions.
46 changes: 39 additions & 7 deletions lightning_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3137,6 +3137,17 @@ func (s *lightningClient) CloseChannel(ctx context.Context,
return updateChan, errChan, nil
}

type InboundFee struct {
// BaseFeeMsat is the inbound base fee charged regardless of the number
// of milli-satoshis received in the channel. By default, only negative
// values are accepted.
BaseFeeMsat int32

// FeeRatePPM is the effective inbound fee rate in micro-satoshis (parts
// per million). By default, only negative values are accepted.
FeeRatePPM int32
}

// PolicyUpdateRequest holds UpdateChanPolicy request data.
type PolicyUpdateRequest struct {
// BaseFeeMsat is the base fee charged regardless of the number of
Expand All @@ -3161,6 +3172,10 @@ type PolicyUpdateRequest struct {

// MinHtlcMsatSpecified if true, MinHtlcMsat is applied.
MinHtlcMsatSpecified bool

// InboundFee holds the optional inbound fee. If unset, the previously
// set value will be used.
InboundFee *InboundFee
}

// UpdateChanPolicy updates the channel policy for the passed chanPoint. If
Expand All @@ -3180,6 +3195,13 @@ func (s *lightningClient) UpdateChanPolicy(ctx context.Context,
MaxHtlcMsat: req.MaxHtlcMsat,
}

if req.InboundFee != nil {
rpcReq.InboundFee = &lnrpc.InboundFee{
BaseFeeMsat: req.InboundFee.BaseFeeMsat,
FeeRatePpm: req.InboundFee.FeeRatePPM,
}
}

if req.MinHtlcMsatSpecified {
rpcReq.MinHtlcMsatSpecified = true
rpcReq.MinHtlcMsat = req.MinHtlcMsat
Expand Down Expand Up @@ -3230,6 +3252,14 @@ type RoutingPolicy struct {

// LastUpdate is the last update time for the edge policy.
LastUpdate time.Time

// InboundBaseFeeMsat is the inbound base fee charged regardless of the
// number of milli-satoshis received in the channel.
InboundBaseFeeMsat int32

// InboundFeeRatePPM is the effective inbound fee rate in micro-satoshis
// (parts per million).
InboundFeeRatePPM int32
}

// ChannelEdge holds the channel edge information and routing policies.
Expand Down Expand Up @@ -3265,13 +3295,15 @@ func getRoutingPolicy(policy *lnrpc.RoutingPolicy) *RoutingPolicy {
}

return &RoutingPolicy{
TimeLockDelta: policy.TimeLockDelta,
MinHtlcMsat: policy.MinHtlc,
MaxHtlcMsat: policy.MaxHtlcMsat,
FeeBaseMsat: policy.FeeBaseMsat,
FeeRateMilliMsat: policy.FeeRateMilliMsat,
Disabled: policy.Disabled,
LastUpdate: time.Unix(int64(policy.LastUpdate), 0),
TimeLockDelta: policy.TimeLockDelta,
MinHtlcMsat: policy.MinHtlc,
MaxHtlcMsat: policy.MaxHtlcMsat,
FeeBaseMsat: policy.FeeBaseMsat,
FeeRateMilliMsat: policy.FeeRateMilliMsat,
Disabled: policy.Disabled,
LastUpdate: time.Unix(int64(policy.LastUpdate), 0),
InboundBaseFeeMsat: policy.InboundFeeBaseMsat,
InboundFeeRatePPM: policy.InboundFeeRateMilliMsat,
}
}

Expand Down

0 comments on commit d79458d

Please sign in to comment.