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
@@ -3422,20 +3422,12 @@ func (d *AuthenticatedGossiper) handleChanUpdate(ctx context.Context,
// different alias. This might mean that SigBytes is incorrect as it
// signs a different SCID than the database SCID, but since there will
// only be a difference if AuthProof == nil, this is fine.
update := &models.ChannelEdgePolicy{
Version: upd.GossipVersion(),
SigBytes: upd.Signature.ToSignatureBytes(),
ChannelID: chanInfo.ChannelID,
LastUpdate: timestamp,
MessageFlags: upd.MessageFlags,
ChannelFlags: upd.ChannelFlags,
TimeLockDelta: upd.TimeLockDelta,
MinHTLC: upd.HtlcMinimumMsat,
MaxHTLC: upd.HtlcMaximumMsat,
FeeBaseMSat: lnwire.MilliSatoshi(upd.BaseFee),
FeeProportionalMillionths: lnwire.MilliSatoshi(upd.FeeRate),
InboundFee: upd.InboundFee.ValOpt(),
ExtraOpaqueData: upd.ExtraOpaqueData,
update, err := models.ChanEdgePolicyFromWire(
chanInfo.ChannelID, upd,
)
if err != nil {
nMsg.err <- err
return nil, false
}
if err := d.cfg.Graph.UpdateEdge(ctx, update, ops...); err != nil {