rpcserver: remove duplicate info from RoutingPolicy

We remove the inbound fee record from `RoutingPolicy.CustomRecords` as
we already have fields `InboundFeeBaseMsat` and `InboundFeeRateMilliMsat`.
This commit is contained in:
yyforyongyu committed 2025-07-01 19:59:50 +08:00
1 parent 624dc6c26a
commit 650e72518c
1 file changed
+16 -8
+16 -8
View File
@@ -6842,12 +6842,23 @@ func marshalDBEdge(edgeInfo *models.ChannelEdgeInfo,
return edge
}
// marshalPolicyExtraOpaqueData marshals the given tlv data and filters out
// inbound fee record.
func marshalPolicyExtraOpaqueData(data []byte) map[uint64][]byte {
records := marshalExtraOpaqueData(data)
// Remove the inbound fee record as we have dedicated fields for it.
delete(records, uint64(lnwire.FeeRecordType))
return records
}
func marshalDBRoutingPolicy(
policy *models.ChannelEdgePolicy) *lnrpc.RoutingPolicy {
disabled := policy.ChannelFlags&lnwire.ChanUpdateDisabled != 0
customRecords := marshalExtraOpaqueData(policy.ExtraOpaqueData)
customRecords := marshalPolicyExtraOpaqueData(policy.ExtraOpaqueData)
inboundFee := policy.InboundFee.UnwrapOr(lnwire.Fee{})
return &lnrpc.RoutingPolicy{
@@ -7361,7 +7372,7 @@ func marshallTopologyChange(
channelUpdates := make([]*lnrpc.ChannelEdgeUpdate, len(topChange.ChannelEdgeUpdates))
for i, channelUpdate := range topChange.ChannelEdgeUpdates {
customRecords := marshalExtraOpaqueData(
customRecords := marshalPolicyExtraOpaqueData(
channelUpdate.ExtraOpaqueData,
)
inboundFee := channelUpdate.InboundFee.UnwrapOr(lnwire.Fee{})
@@ -7954,12 +7965,9 @@ func (r *rpcServer) UpdateChannelPolicy(ctx context.Context,
MinHTLC: minHtlc,
}
rpcsLog.Debugf("[updatechanpolicy] updating channel policy "+
"base_fee=%v, rate_fixed=%v, time_lock_delta: %v, "+
"min_htlc=%v, max_htlc=%v, targets=%v",
req.BaseFeeMsat, feeRateFixed, req.TimeLockDelta,
minHtlc, maxHtlc,
spew.Sdump(targetChans))
rpcsLog.Debugf("[updatechanpolicy] updating channel policy, "+
"targets=%v, req=%v", lnutils.SpewLogClosure(targetChans),
lnutils.SpewLogClosure(req))
// With the scope resolved, we'll now send this to the local channel
// manager so it can propagate the new policy for our target channel(s).