From 650e72518c09b07826f4d1339be5828daa25b993 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Mon, 3 Mar 2025 17:07:02 +0800 Subject: [PATCH] rpcserver: remove duplicate info from `RoutingPolicy` We remove the inbound fee record from `RoutingPolicy.CustomRecords` as we already have fields `InboundFeeBaseMsat` and `InboundFeeRateMilliMsat`. --- rpcserver.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/rpcserver.go b/rpcserver.go index 77fe4bb78..87bda9633 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -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).