graph+rpcserver: add InboundFee to ChannelEdgeUpdate
And then use that new field instead of parsing from extra opaque data.
This commit is contained in:
2 files changed
+6
-20
No files matched your search
@@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
|
"github.com/lightningnetwork/lnd/fn/v2"
|
||||||
"github.com/lightningnetwork/lnd/graph/db/models"
|
"github.com/lightningnetwork/lnd/graph/db/models"
|
||||||
"github.com/lightningnetwork/lnd/lnutils"
|
"github.com/lightningnetwork/lnd/lnutils"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
@@ -360,6 +361,9 @@ type ChannelEdgeUpdate struct {
|
|||||||
// payments.
|
// payments.
|
||||||
Disabled bool
|
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
|
// ExtraOpaqueData is the set of data that was appended to this message
|
||||||
// to fill out the full maximum transport message size. These fields can
|
// to fill out the full maximum transport message size. These fields can
|
||||||
// be used to specify optional data such as custom TLV fields.
|
// be used to specify optional data such as custom TLV fields.
|
||||||
@@ -442,6 +446,7 @@ func (c *ChannelGraph) addToTopologyChange(update *TopologyChange,
|
|||||||
AdvertisingNode: aNode,
|
AdvertisingNode: aNode,
|
||||||
ConnectingNode: cNode,
|
ConnectingNode: cNode,
|
||||||
Disabled: m.ChannelFlags&lnwire.ChanUpdateDisabled != 0,
|
Disabled: m.ChannelFlags&lnwire.ChanUpdateDisabled != 0,
|
||||||
|
InboundFee: m.InboundFee,
|
||||||
ExtraOpaqueData: m.ExtraOpaqueData,
|
ExtraOpaqueData: m.ExtraOpaqueData,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-20
@@ -6776,23 +6776,6 @@ func marshalExtraOpaqueData(data []byte) map[uint64][]byte {
|
|||||||
return records
|
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,
|
func marshalDBEdge(edgeInfo *models.ChannelEdgeInfo,
|
||||||
c1, c2 *models.ChannelEdgePolicy) *lnrpc.ChannelEdge {
|
c1, c2 *models.ChannelEdgePolicy) *lnrpc.ChannelEdge {
|
||||||
|
|
||||||
@@ -7349,9 +7332,7 @@ func marshallTopologyChange(
|
|||||||
customRecords := marshalExtraOpaqueData(
|
customRecords := marshalExtraOpaqueData(
|
||||||
channelUpdate.ExtraOpaqueData,
|
channelUpdate.ExtraOpaqueData,
|
||||||
)
|
)
|
||||||
inboundFee := extractInboundFeeSafe(
|
inboundFee := channelUpdate.InboundFee.UnwrapOr(lnwire.Fee{})
|
||||||
channelUpdate.ExtraOpaqueData,
|
|
||||||
)
|
|
||||||
|
|
||||||
channelUpdates[i] = &lnrpc.ChannelEdgeUpdate{
|
channelUpdates[i] = &lnrpc.ChannelEdgeUpdate{
|
||||||
ChanId: channelUpdate.ChanID,
|
ChanId: channelUpdate.ChanID,
|
||||||
|
|||||||
Reference in new issue
Block a user