From b069406d1e07a788f42d35252ad5d8e7d5fba7af Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 21 Aug 2017 23:57:52 -0700 Subject: [PATCH] peer: fix bug, use the existing timestamp for the ChannelUpdate msg This commit fixes a lingering bug within the logic for the peer/htlcswitch/channellink. When the link needs to fetch the latest update to send to a sending party due to a violation of the set routing policy, previously it would modify the timestamp on the message read from disk. This was incorrect as it would invalidate the signature within the message itself. We fix this by instead --- peer.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/peer.go b/peer.go index bdeaa3fc..3ff6e387 100644 --- a/peer.go +++ b/peer.go @@ -1784,7 +1784,7 @@ func createGetLastUpdate(router *routing.ChannelRouter, error) { return func() (*lnwire.ChannelUpdate, error) { - _, edge1, edge2, err := router.GetChannelByID(chanID) + info, edge1, edge2, err := router.GetChannelByID(chanID) if err != nil { return nil, err } @@ -1802,15 +1802,21 @@ func createGetLastUpdate(router *routing.ChannelRouter, local = edge1 } - return &lnwire.ChannelUpdate{ + update := &lnwire.ChannelUpdate{ Signature: local.Signature, + ChainHash: info.ChainHash, ShortChannelID: lnwire.NewShortChanIDFromInt(local.ChannelID), - Timestamp: uint32(time.Now().Unix()), + Timestamp: uint32(local.LastUpdate.Unix()), Flags: local.Flags, TimeLockDelta: local.TimeLockDelta, HtlcMinimumMsat: local.MinHTLC, BaseFee: uint32(local.FeeBaseMSat), FeeRate: uint32(local.FeeProportionalMillionths), - }, nil + } + + hswcLog.Debugf("Sending latest channel_update: %v", + spew.Sdump(update)) + + return update, nil } }