Skip to content

Commit

Permalink
discovery: ensure ChainHash field is populated when crafting new Chan…
Browse files Browse the repository at this point in the history
…nelUpdates

This commit ensures that we *always* populate the ChainHash field when
we’re crafting new channel update messages either due to the periodic
broadcast, or when we’re updating the routing policies of a set of
target channels. Previously, this wasn’t set which would cause nodes to
reject the newly crafted ChannelUpdate messages.
  • Loading branch information
Roasbeef committed Aug 23, 2017
1 parent 2d45552 commit ff997ea
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions discovery/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,13 @@ func (d *AuthenticatedGossiper) networkHandler() {

// Iterate over our channels and construct the
// announcements array.
err := d.cfg.Router.ForAllOutgoingChannels(func(_ *channeldb.ChannelEdgeInfo,
err := d.cfg.Router.ForAllOutgoingChannels(func(ei *channeldb.ChannelEdgeInfo,
p *channeldb.ChannelEdgePolicy) error {

c := &lnwire.ChannelUpdate{
Signature: p.Signature,
ShortChannelID: lnwire.NewShortChanIDFromInt(p.ChannelID),
ChainHash: ei.ChainHash,
Timestamp: uint32(p.LastUpdate.Unix()),
Flags: p.Flags,
TimeLockDelta: p.TimeLockDelta,
Expand Down Expand Up @@ -540,6 +541,7 @@ func (d *AuthenticatedGossiper) processFeeChanUpdate(feeUpdate *feeUpdateRequest
// updated, as we'll be re-signing it shortly.
c := &lnwire.ChannelUpdate{
Signature: edge.Signature,
ChainHash: info.ChainHash,
ShortChannelID: lnwire.NewShortChanIDFromInt(edge.ChannelID),
Timestamp: uint32(edge.LastUpdate.Unix()),
Flags: edge.Flags,
Expand Down Expand Up @@ -815,12 +817,12 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(nMsg *networkMsg) []l
// key, In the case of an invalid channel , we'll return an
// error to the caller and exit early.
if err := d.validateChannelUpdateAnn(pubKey, msg); err != nil {
err := errors.Errorf("unable to validate channel "+
rErr := errors.Errorf("unable to validate channel "+
"update announcement for short_chan_id=%v: %v",
spew.Sdump(msg.ShortChannelID), err)

log.Error(err)
nMsg.err <- err
log.Error(rErr)
nMsg.err <- rErr
return nil
}

Expand Down

0 comments on commit ff997ea

Please sign in to comment.