Skip to content

Commit bf72d9e

Browse files
committed
graph+rpcserver: add InboundFee to ChannelEdgeUpdate
And then use that new field instead of parsing from extra opaque data.
1 parent cb16c71 commit bf72d9e

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

graph/db/notifications.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/btcsuite/btcd/btcutil"
1313
"github.com/btcsuite/btcd/wire"
1414
"github.com/go-errors/errors"
15+
"github.com/lightningnetwork/lnd/fn/v2"
1516
"github.com/lightningnetwork/lnd/graph/db/models"
1617
"github.com/lightningnetwork/lnd/lnutils"
1718
"github.com/lightningnetwork/lnd/lnwire"
@@ -360,6 +361,9 @@ type ChannelEdgeUpdate struct {
360361
// payments.
361362
Disabled bool
362363

364+
// InboundFee is the fee that must be paid for incoming HTLCs.
365+
InboundFee fn.Option[lnwire.Fee]
366+
363367
// ExtraOpaqueData is the set of data that was appended to this message
364368
// to fill out the full maximum transport message size. These fields can
365369
// be used to specify optional data such as custom TLV fields.
@@ -442,6 +446,7 @@ func (c *ChannelGraph) addToTopologyChange(update *TopologyChange,
442446
AdvertisingNode: aNode,
443447
ConnectingNode: cNode,
444448
Disabled: m.ChannelFlags&lnwire.ChanUpdateDisabled != 0,
449+
InboundFee: m.InboundFee,
445450
ExtraOpaqueData: m.ExtraOpaqueData,
446451
}
447452

rpcserver.go

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6776,23 +6776,6 @@ func marshalExtraOpaqueData(data []byte) map[uint64][]byte {
67766776
return records
67776777
}
67786778

6779-
// extractInboundFeeSafe tries to extract the inbound fee from the given extra
6780-
// opaque data tlv block. If parsing fails, a zero inbound fee is returned. This
6781-
// function is typically used on unvalidated data coming stored in the database.
6782-
// There is not much we can do other than ignoring errors here.
6783-
func extractInboundFeeSafe(data lnwire.ExtraOpaqueData) lnwire.Fee {
6784-
var inboundFee lnwire.Fee
6785-
6786-
_, err := data.ExtractRecords(&inboundFee)
6787-
if err != nil {
6788-
// Return zero fee. Do not return the inboundFee variable
6789-
// because it may be undefined.
6790-
return lnwire.Fee{}
6791-
}
6792-
6793-
return inboundFee
6794-
}
6795-
67966779
func marshalDBEdge(edgeInfo *models.ChannelEdgeInfo,
67976780
c1, c2 *models.ChannelEdgePolicy) *lnrpc.ChannelEdge {
67986781

@@ -7349,9 +7332,7 @@ func marshallTopologyChange(
73497332
customRecords := marshalExtraOpaqueData(
73507333
channelUpdate.ExtraOpaqueData,
73517334
)
7352-
inboundFee := extractInboundFeeSafe(
7353-
channelUpdate.ExtraOpaqueData,
7354-
)
7335+
inboundFee := channelUpdate.InboundFee.UnwrapOr(lnwire.Fee{})
73557336

73567337
channelUpdates[i] = &lnrpc.ChannelEdgeUpdate{
73577338
ChanId: channelUpdate.ChanID,

0 commit comments

Comments
 (0)