Skip to content

Commit 707d106

Browse files
bhandrasguggero
authored andcommitted
lndclient: add inbound fee support to the lightning client
1 parent 98f1341 commit 707d106

File tree

1 file changed

+40
-8
lines changed

1 file changed

+40
-8
lines changed

lightning_client.go

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3137,6 +3137,17 @@ func (s *lightningClient) CloseChannel(ctx context.Context,
31373137
return updateChan, errChan, nil
31383138
}
31393139

3140+
type InboundFee struct {
3141+
// BaseFeeMsat is the inbound base fee charged regardless of the number
3142+
// of milli-satoshis received in the channel. By default, only negative
3143+
// values are accepted.
3144+
BaseFeeMsat int32
3145+
3146+
// FeeRatePPM is the effective inbound fee rate in micro-satoshis (parts
3147+
// per million). By default, only negative values are accepted.
3148+
FeeRatePPM int32
3149+
}
3150+
31403151
// PolicyUpdateRequest holds UpdateChanPolicy request data.
31413152
type PolicyUpdateRequest struct {
31423153
// BaseFeeMsat is the base fee charged regardless of the number of
@@ -3161,6 +3172,10 @@ type PolicyUpdateRequest struct {
31613172

31623173
// MinHtlcMsatSpecified if true, MinHtlcMsat is applied.
31633174
MinHtlcMsatSpecified bool
3175+
3176+
// InboundFee holds the optional inbound fee. If unset, the previously
3177+
// set value will be used.
3178+
InboundFee *InboundFee
31643179
}
31653180

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

3198+
if req.InboundFee != nil {
3199+
rpcReq.InboundFee = &lnrpc.InboundFee{
3200+
BaseFeeMsat: req.InboundFee.BaseFeeMsat,
3201+
FeeRatePpm: req.InboundFee.FeeRatePPM,
3202+
}
3203+
}
3204+
31833205
if req.MinHtlcMsatSpecified {
31843206
rpcReq.MinHtlcMsatSpecified = true
31853207
rpcReq.MinHtlcMsat = req.MinHtlcMsat
@@ -3234,6 +3256,14 @@ type RoutingPolicy struct {
32343256
// CustomRecords is a set of feature id-value pairs that are used to
32353257
// advertise additional information about an edge.
32363258
CustomRecords map[uint64][]byte
3259+
3260+
// InboundBaseFeeMsat is the inbound base fee charged regardless of the
3261+
// number of milli-satoshis received in the channel.
3262+
InboundBaseFeeMsat int32
3263+
3264+
// InboundFeeRatePPM is the effective inbound fee rate in micro-satoshis
3265+
// (parts per million).
3266+
InboundFeeRatePPM int32
32373267
}
32383268

32393269
// ChannelEdge holds the channel edge information and routing policies.
@@ -3269,14 +3299,16 @@ func getRoutingPolicy(policy *lnrpc.RoutingPolicy) *RoutingPolicy {
32693299
}
32703300

32713301
return &RoutingPolicy{
3272-
TimeLockDelta: policy.TimeLockDelta,
3273-
MinHtlcMsat: policy.MinHtlc,
3274-
MaxHtlcMsat: policy.MaxHtlcMsat,
3275-
FeeBaseMsat: policy.FeeBaseMsat,
3276-
FeeRateMilliMsat: policy.FeeRateMilliMsat,
3277-
Disabled: policy.Disabled,
3278-
LastUpdate: time.Unix(int64(policy.LastUpdate), 0),
3279-
CustomRecords: policy.CustomRecords,
3302+
TimeLockDelta: policy.TimeLockDelta,
3303+
MinHtlcMsat: policy.MinHtlc,
3304+
MaxHtlcMsat: policy.MaxHtlcMsat,
3305+
FeeBaseMsat: policy.FeeBaseMsat,
3306+
FeeRateMilliMsat: policy.FeeRateMilliMsat,
3307+
Disabled: policy.Disabled,
3308+
LastUpdate: time.Unix(int64(policy.LastUpdate), 0),
3309+
CustomRecords: policy.CustomRecords,
3310+
InboundBaseFeeMsat: policy.InboundFeeBaseMsat,
3311+
InboundFeeRatePPM: policy.InboundFeeRateMilliMsat,
32803312
}
32813313
}
32823314

0 commit comments

Comments
 (0)