diff --git a/discovery/service.go b/discovery/service.go index 5397dcb7..cb3866fc 100644 --- a/discovery/service.go +++ b/discovery/service.go @@ -263,6 +263,12 @@ func (d *AuthenticatedGossiper) ProcessLocalAnnouncement(msg lnwire.Message, func (d *AuthenticatedGossiper) networkHandler() { defer d.wg.Done() + // TODO(roasbeef): changes for spec compliance + // * make into de-duplicated struct + // * always send chan ann -> node ann -> chan update + // * buffer recv'd node ann until after chan ann that includes is + // created + // * can use mostly empty struct in db as place holder var announcementBatch []lnwire.Message // TODO(roasbeef): parametrize the above @@ -366,14 +372,14 @@ func (d *AuthenticatedGossiper) networkHandler() { // announcements array. err := d.cfg.Router.ForAllOutgoingChannels(func(p *channeldb.ChannelEdgePolicy) error { c := &lnwire.ChannelUpdate{ - Signature: p.Signature, - ShortChannelID: lnwire.NewShortChanIDFromInt(p.ChannelID), - Timestamp: uint32(p.LastUpdate.Unix()), - Flags: p.Flags, - TimeLockDelta: p.TimeLockDelta, - HtlcMinimumMsat: uint32(p.MinHTLC), - FeeBaseMsat: uint32(p.FeeBaseMSat), - FeeProportionalMillionths: uint32(p.FeeProportionalMillionths), + Signature: p.Signature, + ShortChannelID: lnwire.NewShortChanIDFromInt(p.ChannelID), + Timestamp: uint32(p.LastUpdate.Unix()), + Flags: p.Flags, + TimeLockDelta: p.TimeLockDelta, + HtlcMinimumMsat: uint64(p.MinHTLC), + BaseFee: uint32(p.FeeBaseMSat), + FeeRate: uint32(p.FeeProportionalMillionths), } selfChans = append(selfChans, c) return nil @@ -621,8 +627,8 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(nMsg *networkMsg) []l Flags: msg.Flags, TimeLockDelta: msg.TimeLockDelta, MinHTLC: btcutil.Amount(msg.HtlcMinimumMsat), - FeeBaseMSat: btcutil.Amount(msg.FeeBaseMsat), - FeeProportionalMillionths: btcutil.Amount(msg.FeeProportionalMillionths), + FeeBaseMSat: btcutil.Amount(msg.BaseFee), + FeeProportionalMillionths: btcutil.Amount(msg.FeeRate), } if err := d.cfg.Router.UpdateEdge(update); err != nil { diff --git a/discovery/service_test.go b/discovery/service_test.go index 260f6989..9df3b028 100644 --- a/discovery/service_test.go +++ b/discovery/service_test.go @@ -337,11 +337,11 @@ func createUpdateAnnouncement(blockHeight uint32) (*lnwire.ChannelUpdate, error) ShortChannelID: lnwire.ShortChannelID{ BlockHeight: blockHeight, }, - Timestamp: uint32(prand.Int31()), - TimeLockDelta: uint16(prand.Int63()), - HtlcMinimumMsat: uint32(prand.Int31()), - FeeBaseMsat: uint32(prand.Int31()), - FeeProportionalMillionths: uint32(prand.Int31()), + Timestamp: uint32(prand.Int31()), + TimeLockDelta: uint16(prand.Int63()), + HtlcMinimumMsat: uint64(prand.Int63()), + FeeRate: uint32(prand.Int31()), + BaseFee: uint32(prand.Int31()), } pub := nodeKeyPriv1.PubKey() diff --git a/discovery/utils.go b/discovery/utils.go index d50c5dbd..a236121b 100644 --- a/discovery/utils.go +++ b/discovery/utils.go @@ -44,26 +44,26 @@ func createChanAnnouncement(chanProof *channeldb.ChannelAuthProof, var edge1Ann, edge2Ann *lnwire.ChannelUpdate if e1 != nil { edge1Ann = &lnwire.ChannelUpdate{ - Signature: e1.Signature, - ShortChannelID: chanID, - Timestamp: uint32(e1.LastUpdate.Unix()), - Flags: 0, - TimeLockDelta: e1.TimeLockDelta, - HtlcMinimumMsat: uint32(e1.MinHTLC), - FeeBaseMsat: uint32(e1.FeeBaseMSat), - FeeProportionalMillionths: uint32(e1.FeeProportionalMillionths), + Signature: e1.Signature, + ShortChannelID: chanID, + Timestamp: uint32(e1.LastUpdate.Unix()), + Flags: 0, + TimeLockDelta: e1.TimeLockDelta, + HtlcMinimumMsat: uint64(e1.MinHTLC), + BaseFee: uint32(e1.FeeBaseMSat), + FeeRate: uint32(e1.FeeProportionalMillionths), } } if e2 != nil { edge2Ann = &lnwire.ChannelUpdate{ - Signature: e2.Signature, - ShortChannelID: chanID, - Timestamp: uint32(e2.LastUpdate.Unix()), - Flags: 1, - TimeLockDelta: e2.TimeLockDelta, - HtlcMinimumMsat: uint32(e2.MinHTLC), - FeeBaseMsat: uint32(e2.FeeBaseMSat), - FeeProportionalMillionths: uint32(e2.FeeProportionalMillionths), + Signature: e2.Signature, + ShortChannelID: chanID, + Timestamp: uint32(e2.LastUpdate.Unix()), + Flags: 1, + TimeLockDelta: e2.TimeLockDelta, + HtlcMinimumMsat: uint64(e2.MinHTLC), + BaseFee: uint32(e2.FeeBaseMSat), + FeeRate: uint32(e2.FeeProportionalMillionths), } }