Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lndclient: add inbound fee support to the lightning client #188

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading