Skip to content

Commit d79458d

Browse files
bhandrasguggero
authored andcommitted
lndclient: add inbound fee support to the lightning client
1 parent 76ebee9 commit d79458d

File tree

1 file changed

+39
-7
lines changed

1 file changed

+39
-7
lines changed

lightning_client.go

Lines changed: 39 additions & 7 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
@@ -3230,6 +3252,14 @@ type RoutingPolicy struct {
32303252

32313253
// LastUpdate is the last update time for the edge policy.
32323254
LastUpdate time.Time
3255+
3256+
// InboundBaseFeeMsat is the inbound base fee charged regardless of the
3257+
// number of milli-satoshis received in the channel.
3258+
InboundBaseFeeMsat int32
3259+
3260+
// InboundFeeRatePPM is the effective inbound fee rate in micro-satoshis
3261+
// (parts per million).
3262+
InboundFeeRatePPM int32
32333263
}
32343264

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

32673297
return &RoutingPolicy{
3268-
TimeLockDelta: policy.TimeLockDelta,
3269-
MinHtlcMsat: policy.MinHtlc,
3270-
MaxHtlcMsat: policy.MaxHtlcMsat,
3271-
FeeBaseMsat: policy.FeeBaseMsat,
3272-
FeeRateMilliMsat: policy.FeeRateMilliMsat,
3273-
Disabled: policy.Disabled,
3274-
LastUpdate: time.Unix(int64(policy.LastUpdate), 0),
3298+
TimeLockDelta: policy.TimeLockDelta,
3299+
MinHtlcMsat: policy.MinHtlc,
3300+
MaxHtlcMsat: policy.MaxHtlcMsat,
3301+
FeeBaseMsat: policy.FeeBaseMsat,
3302+
FeeRateMilliMsat: policy.FeeRateMilliMsat,
3303+
Disabled: policy.Disabled,
3304+
LastUpdate: time.Unix(int64(policy.LastUpdate), 0),
3305+
InboundBaseFeeMsat: policy.InboundFeeBaseMsat,
3306+
InboundFeeRatePPM: policy.InboundFeeRateMilliMsat,
32753307
}
32763308
}
32773309

0 commit comments

Comments
 (0)