diff --git a/graph/db/notifications.go b/graph/db/notifications.go index d573e0aa5..6c0acba88 100644 --- a/graph/db/notifications.go +++ b/graph/db/notifications.go @@ -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, } diff --git a/rpcserver.go b/rpcserver.go index f9f8a5a9c..758400b1f 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -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,