graph+rpcserver: add InboundFee to ChannelEdgeUpdate

And then use that new field instead of parsing from extra opaque data.
This commit is contained in:
Elle Mouton committed 2025-06-09 08:32:15 +02:00
1 parent cb16c7177a
commit bf72d9ec19
2 files changed
+6 -20

No files matched your search

+5
View File
@@ -12,6 +12,7 @@ import (
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/wire"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/graph/db/models"
"github.com/lightningnetwork/lnd/lnutils"
"github.com/lightningnetwork/lnd/lnwire"
@@ -360,6 +361,9 @@ type ChannelEdgeUpdate struct {
// payments.
Disabled bool
// InboundFee is the fee that must be paid for incoming HTLCs.
InboundFee fn.Option[lnwire.Fee]
// ExtraOpaqueData is the set of data that was appended to this message
// to fill out the full maximum transport message size. These fields can
// be used to specify optional data such as custom TLV fields.
@@ -442,6 +446,7 @@ func (c *ChannelGraph) addToTopologyChange(update *TopologyChange,
AdvertisingNode: aNode,
ConnectingNode: cNode,
Disabled: m.ChannelFlags&lnwire.ChanUpdateDisabled != 0,
InboundFee: m.InboundFee,
ExtraOpaqueData: m.ExtraOpaqueData,
}
+1 -20
View File
@@ -6776,23 +6776,6 @@ func marshalExtraOpaqueData(data []byte) map[uint64][]byte {
return records
}
// extractInboundFeeSafe tries to extract the inbound fee from the given extra
// opaque data tlv block. If parsing fails, a zero inbound fee is returned. This
// function is typically used on unvalidated data coming stored in the database.
// There is not much we can do other than ignoring errors here.
func extractInboundFeeSafe(data lnwire.ExtraOpaqueData) lnwire.Fee {
var inboundFee lnwire.Fee
_, err := data.ExtractRecords(&inboundFee)
if err != nil {
// Return zero fee. Do not return the inboundFee variable
// because it may be undefined.
return lnwire.Fee{}
}
return inboundFee
}
func marshalDBEdge(edgeInfo *models.ChannelEdgeInfo,
c1, c2 *models.ChannelEdgePolicy) *lnrpc.ChannelEdge {
@@ -7349,9 +7332,7 @@ func marshallTopologyChange(
customRecords := marshalExtraOpaqueData(
channelUpdate.ExtraOpaqueData,
)
inboundFee := extractInboundFeeSafe(
channelUpdate.ExtraOpaqueData,
)
inboundFee := channelUpdate.InboundFee.UnwrapOr(lnwire.Fee{})
channelUpdates[i] = &lnrpc.ChannelEdgeUpdate{
ChanId: channelUpdate.ChanID,