multi: add ChanEdgePolicyFromWire constructor for ChannelEdgePolicy

Add ChanEdgePolicyFromWire to construct ChannelEdgePolicy from channel
update messages, centralizing v1/v2 field mapping.
Update call sites to use the helper:

- discovery/gossiper: handleChanUpdate
- graph/builder: ApplyChannelUpdate
- routing/router_test: ApplyChannelUpdate test helper

This consolidates update-to-policy conversion logic across versions.
This commit is contained in:
Elle Mouton committed 2026-02-13 07:21:24 +02:00
1 parent 9c7a12c0e0
commit a73c45946b
4 files changed
+69 -42

No files matched your search

+6 -14
View File
@@ -952,20 +952,12 @@ func (b *Builder) ApplyChannelUpdate(msg *lnwire.ChannelUpdate1) bool {
return false
}
update := &models.ChannelEdgePolicy{
Version: msg.GossipVersion(),
SigBytes: msg.Signature.ToSignatureBytes(),
ChannelID: msg.ShortChannelID.ToUint64(),
LastUpdate: time.Unix(int64(msg.Timestamp), 0),
MessageFlags: msg.MessageFlags,
ChannelFlags: msg.ChannelFlags,
TimeLockDelta: msg.TimeLockDelta,
MinHTLC: msg.HtlcMinimumMsat,
MaxHTLC: msg.HtlcMaximumMsat,
FeeBaseMSat: lnwire.MilliSatoshi(msg.BaseFee),
FeeProportionalMillionths: lnwire.MilliSatoshi(msg.FeeRate),
InboundFee: msg.InboundFee.ValOpt(),
ExtraOpaqueData: msg.ExtraOpaqueData,
update, err := models.ChanEdgePolicyFromWire(
msg.ShortChannelID.ToUint64(), msg,
)
if err != nil {
log.Errorf("Unable to parse channel update: %v", err)
return false
}
err = b.UpdateEdge(ctx, update)