multi: rename ChannelUpdate to ChannelUpdate1

In preparation for adding a new ChannelUpdate2 message and a
ChannelUpdate interface, we rename the existing message to
ChannelUpdate1.
This commit is contained in:
Elle Mouton 2024-08-21 08:39:37 +02:00
parent 0f0e436427
commit 7720aec8f1
No known key found for this signature in database
GPG key ID: D7D916376026F177
43 changed files with 198 additions and 172 deletions

View file

@ -61,7 +61,8 @@ type ChannelGraphTimeSeries interface {
// specified short channel ID. If no channel updates are known for the // specified short channel ID. If no channel updates are known for the
// channel, then an empty slice will be returned. // channel, then an empty slice will be returned.
FetchChanUpdates(chain chainhash.Hash, FetchChanUpdates(chain chainhash.Hash,
shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate, error) shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate1,
error)
} }
// ChanSeries is an implementation of the ChannelGraphTimeSeries // ChanSeries is an implementation of the ChannelGraphTimeSeries
@ -326,7 +327,7 @@ func (c *ChanSeries) FetchChanAnns(chain chainhash.Hash,
// //
// NOTE: This is part of the ChannelGraphTimeSeries interface. // NOTE: This is part of the ChannelGraphTimeSeries interface.
func (c *ChanSeries) FetchChanUpdates(chain chainhash.Hash, func (c *ChanSeries) FetchChanUpdates(chain chainhash.Hash,
shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate, error) { shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate1, error) {
chanInfo, e1, e2, err := c.graph.FetchChannelEdgesByID( chanInfo, e1, e2, err := c.graph.FetchChannelEdgesByID(
shortChanID.ToUint64(), shortChanID.ToUint64(),
@ -335,7 +336,7 @@ func (c *ChanSeries) FetchChanUpdates(chain chainhash.Hash,
return nil, err return nil, err
} }
chanUpdates := make([]*lnwire.ChannelUpdate, 0, 2) chanUpdates := make([]*lnwire.ChannelUpdate1, 0, 2)
if e1 != nil { if e1 != nil {
chanUpdate, err := netann.ChannelUpdateFromEdge(chanInfo, e1) chanUpdate, err := netann.ChannelUpdateFromEdge(chanInfo, e1)
if err != nil { if err != nil {

View file

@ -322,7 +322,7 @@ type Config struct {
// SignAliasUpdate is used to re-sign a channel update using the // SignAliasUpdate is used to re-sign a channel update using the
// remote's alias if the option-scid-alias feature bit was negotiated. // remote's alias if the option-scid-alias feature bit was negotiated.
SignAliasUpdate func(u *lnwire.ChannelUpdate) (*ecdsa.Signature, SignAliasUpdate func(u *lnwire.ChannelUpdate1) (*ecdsa.Signature,
error) error)
// FindBaseByAlias finds the SCID stored in the graph by an alias SCID. // FindBaseByAlias finds the SCID stored in the graph by an alias SCID.
@ -1035,7 +1035,7 @@ func (d *deDupedAnnouncements) addMsg(message networkMsg) {
// Channel updates are identified by the (short channel id, // Channel updates are identified by the (short channel id,
// channelflags) tuple. // channelflags) tuple.
case *lnwire.ChannelUpdate: case *lnwire.ChannelUpdate1:
sender := route.NewVertex(message.source) sender := route.NewVertex(message.source)
deDupKey := channelUpdateID{ deDupKey := channelUpdateID{
msg.ShortChannelID, msg.ShortChannelID,
@ -1047,7 +1047,15 @@ func (d *deDupedAnnouncements) addMsg(message networkMsg) {
if ok { if ok {
// If we already have seen this message, record its // If we already have seen this message, record its
// timestamp. // timestamp.
oldTimestamp = mws.msg.(*lnwire.ChannelUpdate).Timestamp update, ok := mws.msg.(*lnwire.ChannelUpdate1)
if !ok {
log.Errorf("Expected *lnwire.ChannelUpdate1, "+
"got: %T", mws.msg)
return
}
oldTimestamp = update.Timestamp
} }
// If we already had this message with a strictly newer // If we already had this message with a strictly newer
@ -1582,7 +1590,7 @@ func (d *AuthenticatedGossiper) isRecentlyRejectedMsg(msg lnwire.Message,
var scid uint64 var scid uint64
switch m := msg.(type) { switch m := msg.(type) {
case *lnwire.ChannelUpdate: case *lnwire.ChannelUpdate1:
scid = m.ShortChannelID.ToUint64() scid = m.ShortChannelID.ToUint64()
case *lnwire.ChannelAnnouncement1: case *lnwire.ChannelAnnouncement1:
@ -2035,7 +2043,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
// A new authenticated channel edge update has arrived. This indicates // A new authenticated channel edge update has arrived. This indicates
// that the directional information for an already known channel has // that the directional information for an already known channel has
// been updated. // been updated.
case *lnwire.ChannelUpdate: case *lnwire.ChannelUpdate1:
return d.handleChanUpdate(nMsg, msg, schedulerOp) return d.handleChanUpdate(nMsg, msg, schedulerOp)
// A new signature announcement has been received. This indicates // A new signature announcement has been received. This indicates
@ -2058,7 +2066,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
// should be inspected. // should be inspected.
func (d *AuthenticatedGossiper) processZombieUpdate( func (d *AuthenticatedGossiper) processZombieUpdate(
chanInfo *models.ChannelEdgeInfo, scid lnwire.ShortChannelID, chanInfo *models.ChannelEdgeInfo, scid lnwire.ShortChannelID,
msg *lnwire.ChannelUpdate) error { msg *lnwire.ChannelUpdate1) error {
// The least-significant bit in the flag on the channel update tells us // The least-significant bit in the flag on the channel update tells us
// which edge is being updated. // which edge is being updated.
@ -2151,7 +2159,7 @@ func (d *AuthenticatedGossiper) isMsgStale(msg lnwire.Message) bool {
// can safely delete the local proof from the database. // can safely delete the local proof from the database.
return chanInfo.AuthProof != nil return chanInfo.AuthProof != nil
case *lnwire.ChannelUpdate: case *lnwire.ChannelUpdate1:
_, p1, p2, err := d.cfg.Graph.GetChannelByID(msg.ShortChannelID) _, p1, p2, err := d.cfg.Graph.GetChannelByID(msg.ShortChannelID)
// If the channel cannot be found, it is most likely a leftover // If the channel cannot be found, it is most likely a leftover
@ -2196,7 +2204,7 @@ func (d *AuthenticatedGossiper) isMsgStale(msg lnwire.Message) bool {
// the underlying graph with the new state. // the underlying graph with the new state.
func (d *AuthenticatedGossiper) updateChannel(info *models.ChannelEdgeInfo, func (d *AuthenticatedGossiper) updateChannel(info *models.ChannelEdgeInfo,
edge *models.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement1, edge *models.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement1,
*lnwire.ChannelUpdate, error) { *lnwire.ChannelUpdate1, error) {
// Parse the unsigned edge into a channel update. // Parse the unsigned edge into a channel update.
chanUpdate := netann.UnsignedChannelUpdateFromEdge(info, edge) chanUpdate := netann.UnsignedChannelUpdateFromEdge(info, edge)
@ -2284,7 +2292,7 @@ func (d *AuthenticatedGossiper) SyncManager() *SyncManager {
// IsKeepAliveUpdate determines whether this channel update is considered a // IsKeepAliveUpdate determines whether this channel update is considered a
// keep-alive update based on the previous channel update processed for the same // keep-alive update based on the previous channel update processed for the same
// direction. // direction.
func IsKeepAliveUpdate(update *lnwire.ChannelUpdate, func IsKeepAliveUpdate(update *lnwire.ChannelUpdate1,
prev *models.ChannelEdgePolicy) bool { prev *models.ChannelEdgePolicy) bool {
// Both updates should be from the same direction. // Both updates should be from the same direction.
@ -2753,7 +2761,7 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
// Reprocess the message, making sure we return an // Reprocess the message, making sure we return an
// error to the original caller in case the gossiper // error to the original caller in case the gossiper
// shuts down. // shuts down.
case *lnwire.ChannelUpdate: case *lnwire.ChannelUpdate1:
log.Debugf("Reprocessing ChannelUpdate for "+ log.Debugf("Reprocessing ChannelUpdate for "+
"shortChanID=%v", scid.ToUint64()) "shortChanID=%v", scid.ToUint64())
@ -2796,7 +2804,7 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
// handleChanUpdate processes a new channel update. // handleChanUpdate processes a new channel update.
func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg, func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
upd *lnwire.ChannelUpdate, upd *lnwire.ChannelUpdate1,
ops []batch.SchedulerOption) ([]networkMsg, bool) { ops []batch.SchedulerOption) ([]networkMsg, bool) {
log.Debugf("Processing ChannelUpdate: peer=%v, short_chan_id=%v, ", log.Debugf("Processing ChannelUpdate: peer=%v, short_chan_id=%v, ",

View file

@ -478,8 +478,8 @@ type annBatch struct {
chanAnn *lnwire.ChannelAnnouncement1 chanAnn *lnwire.ChannelAnnouncement1
chanUpdAnn1 *lnwire.ChannelUpdate chanUpdAnn1 *lnwire.ChannelUpdate1
chanUpdAnn2 *lnwire.ChannelUpdate chanUpdAnn2 *lnwire.ChannelUpdate1
localProofAnn *lnwire.AnnounceSignatures1 localProofAnn *lnwire.AnnounceSignatures1
remoteProofAnn *lnwire.AnnounceSignatures1 remoteProofAnn *lnwire.AnnounceSignatures1
@ -585,12 +585,12 @@ func createNodeAnnouncement(priv *btcec.PrivateKey,
func createUpdateAnnouncement(blockHeight uint32, func createUpdateAnnouncement(blockHeight uint32,
flags lnwire.ChanUpdateChanFlags, flags lnwire.ChanUpdateChanFlags,
nodeKey *btcec.PrivateKey, timestamp uint32, nodeKey *btcec.PrivateKey, timestamp uint32,
extraBytes ...[]byte) (*lnwire.ChannelUpdate, error) { extraBytes ...[]byte) (*lnwire.ChannelUpdate1, error) {
var err error var err error
htlcMinMsat := lnwire.MilliSatoshi(prand.Int63()) htlcMinMsat := lnwire.MilliSatoshi(prand.Int63())
a := &lnwire.ChannelUpdate{ a := &lnwire.ChannelUpdate1{
ShortChannelID: lnwire.ShortChannelID{ ShortChannelID: lnwire.ShortChannelID{
BlockHeight: blockHeight, BlockHeight: blockHeight,
}, },
@ -618,7 +618,7 @@ func createUpdateAnnouncement(blockHeight uint32,
return a, nil return a, nil
} }
func signUpdate(nodeKey *btcec.PrivateKey, a *lnwire.ChannelUpdate) error { func signUpdate(nodeKey *btcec.PrivateKey, a *lnwire.ChannelUpdate1) error {
signer := mock.SingleSigner{Privkey: nodeKey} signer := mock.SingleSigner{Privkey: nodeKey}
sig, err := netann.SignAnnouncement(&signer, testKeyLoc, a) sig, err := netann.SignAnnouncement(&signer, testKeyLoc, a)
if err != nil { if err != nil {
@ -749,7 +749,7 @@ func createTestCtx(t *testing.T, startHeight uint32, isChanPeer bool) (
return false return false
} }
signAliasUpdate := func(*lnwire.ChannelUpdate) (*ecdsa.Signature, signAliasUpdate := func(*lnwire.ChannelUpdate1) (*ecdsa.Signature,
error) { error) {
return nil, nil return nil, nil
@ -1462,7 +1462,7 @@ func TestSignatureAnnouncementRetryAtStartup(t *testing.T) {
return false return false
} }
signAliasUpdate := func(*lnwire.ChannelUpdate) (*ecdsa.Signature, signAliasUpdate := func(*lnwire.ChannelUpdate1) (*ecdsa.Signature,
error) { error) {
return nil, nil return nil, nil
@ -1868,7 +1868,7 @@ func TestDeDuplicatedAnnouncements(t *testing.T) {
t.Fatal("channel update not replaced in batch") t.Fatal("channel update not replaced in batch")
} }
assertChannelUpdate := func(channelUpdate *lnwire.ChannelUpdate) { assertChannelUpdate := func(channelUpdate *lnwire.ChannelUpdate1) {
channelKey := channelUpdateID{ channelKey := channelUpdateID{
ua3.ShortChannelID, ua3.ShortChannelID,
ua3.ChannelFlags, ua3.ChannelFlags,
@ -2814,7 +2814,7 @@ func TestRetransmit(t *testing.T) {
switch msg.(type) { switch msg.(type) {
case *lnwire.ChannelAnnouncement1: case *lnwire.ChannelAnnouncement1:
chanAnn++ chanAnn++
case *lnwire.ChannelUpdate: case *lnwire.ChannelUpdate1:
chanUpd++ chanUpd++
case *lnwire.NodeAnnouncement: case *lnwire.NodeAnnouncement:
nodeAnn++ nodeAnn++
@ -3247,7 +3247,7 @@ func TestSendChannelUpdateReliably(t *testing.T) {
// already been announced. We'll keep track of the old message that is // already been announced. We'll keep track of the old message that is
// now stale to use later on. // now stale to use later on.
staleChannelUpdate := batch.chanUpdAnn1 staleChannelUpdate := batch.chanUpdAnn1
newChannelUpdate := &lnwire.ChannelUpdate{} newChannelUpdate := &lnwire.ChannelUpdate1{}
*newChannelUpdate = *staleChannelUpdate *newChannelUpdate = *staleChannelUpdate
newChannelUpdate.Timestamp++ newChannelUpdate.Timestamp++
if err := signUpdate(selfKeyPriv, newChannelUpdate); err != nil { if err := signUpdate(selfKeyPriv, newChannelUpdate); err != nil {
@ -3301,7 +3301,7 @@ func TestSendChannelUpdateReliably(t *testing.T) {
} }
switch msg := msg.(type) { switch msg := msg.(type) {
case *lnwire.ChannelUpdate: case *lnwire.ChannelUpdate1:
assertMessage(t, staleChannelUpdate, msg) assertMessage(t, staleChannelUpdate, msg)
case *lnwire.AnnounceSignatures1: case *lnwire.AnnounceSignatures1:
assertMessage(t, batch.localProofAnn, msg) assertMessage(t, batch.localProofAnn, msg)
@ -3505,7 +3505,7 @@ out:
// being the channel our first private channel. // being the channel our first private channel.
for i := 0; i < numChannels-1; i++ { for i := 0; i < numChannels-1; i++ {
assertBroadcastMsg(t, ctx, func(msg lnwire.Message) error { assertBroadcastMsg(t, ctx, func(msg lnwire.Message) error {
upd, ok := msg.(*lnwire.ChannelUpdate) upd, ok := msg.(*lnwire.ChannelUpdate1)
if !ok { if !ok {
return fmt.Errorf("channel update not "+ return fmt.Errorf("channel update not "+
"broadcast, instead %T was", msg) "broadcast, instead %T was", msg)
@ -3529,7 +3529,7 @@ out:
// remote peer via the reliable sender. // remote peer via the reliable sender.
select { select {
case msg := <-sentMsgs: case msg := <-sentMsgs:
upd, ok := msg.(*lnwire.ChannelUpdate) upd, ok := msg.(*lnwire.ChannelUpdate1)
if !ok { if !ok {
t.Fatalf("channel update not "+ t.Fatalf("channel update not "+
"broadcast, instead %T was", msg) "broadcast, instead %T was", msg)
@ -3553,7 +3553,7 @@ out:
for { for {
select { select {
case msg := <-ctx.broadcastedMessage: case msg := <-ctx.broadcastedMessage:
if upd, ok := msg.msg.(*lnwire.ChannelUpdate); ok { if upd, ok := msg.msg.(*lnwire.ChannelUpdate1); ok {
if upd.ShortChannelID == firstChanID { if upd.ShortChannelID == firstChanID {
t.Fatalf("chan update msg received: %v", t.Fatalf("chan update msg received: %v",
spew.Sdump(msg)) spew.Sdump(msg))
@ -3885,7 +3885,7 @@ func TestRateLimitChannelUpdates(t *testing.T) {
// We'll define a helper to assert whether updates should be rate // We'll define a helper to assert whether updates should be rate
// limited or not depending on their contents. // limited or not depending on their contents.
assertRateLimit := func(update *lnwire.ChannelUpdate, peer lnpeer.Peer, assertRateLimit := func(update *lnwire.ChannelUpdate1, peer lnpeer.Peer,
shouldRateLimit bool) { shouldRateLimit bool) {
t.Helper() t.Helper()

View file

@ -85,7 +85,7 @@ func msgShortChanID(msg lnwire.Message) (lnwire.ShortChannelID, error) {
switch msg := msg.(type) { switch msg := msg.(type) {
case *lnwire.AnnounceSignatures1: case *lnwire.AnnounceSignatures1:
shortChanID = msg.ShortChannelID shortChanID = msg.ShortChannelID
case *lnwire.ChannelUpdate: case *lnwire.ChannelUpdate1:
shortChanID = msg.ShortChannelID shortChanID = msg.ShortChannelID
default: default:
return shortChanID, ErrUnsupportedMessage return shortChanID, ErrUnsupportedMessage
@ -160,7 +160,7 @@ func (s *MessageStore) DeleteMessage(msg lnwire.Message,
// In the event that we're attempting to delete a ChannelUpdate // In the event that we're attempting to delete a ChannelUpdate
// from the store, we'll make sure that we're actually deleting // from the store, we'll make sure that we're actually deleting
// the correct one as it can be overwritten. // the correct one as it can be overwritten.
if msg, ok := msg.(*lnwire.ChannelUpdate); ok { if msg, ok := msg.(*lnwire.ChannelUpdate1); ok {
// Deleting a value from a bucket that doesn't exist // Deleting a value from a bucket that doesn't exist
// acts as a NOP, so we'll return if a message doesn't // acts as a NOP, so we'll return if a message doesn't
// exist under this key. // exist under this key.
@ -176,7 +176,13 @@ func (s *MessageStore) DeleteMessage(msg lnwire.Message,
// If the timestamps don't match, then the update stored // If the timestamps don't match, then the update stored
// should be the latest one, so we'll avoid deleting it. // should be the latest one, so we'll avoid deleting it.
if msg.Timestamp != dbMsg.(*lnwire.ChannelUpdate).Timestamp { m, ok := dbMsg.(*lnwire.ChannelUpdate1)
if !ok {
return fmt.Errorf("expected "+
"*lnwire.ChannelUpdate1, got: %T",
dbMsg)
}
if msg.Timestamp != m.Timestamp {
return nil return nil
} }
} }

View file

@ -59,8 +59,8 @@ func randAnnounceSignatures() *lnwire.AnnounceSignatures1 {
} }
} }
func randChannelUpdate() *lnwire.ChannelUpdate { func randChannelUpdate() *lnwire.ChannelUpdate1 {
return &lnwire.ChannelUpdate{ return &lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(rand.Uint64()), ShortChannelID: lnwire.NewShortChanIDFromInt(rand.Uint64()),
ExtraOpaqueData: make([]byte, 0), ExtraOpaqueData: make([]byte, 0),
} }
@ -118,7 +118,7 @@ func TestMessageStoreMessages(t *testing.T) {
switch msg := msg.(type) { switch msg := msg.(type) {
case *lnwire.AnnounceSignatures1: case *lnwire.AnnounceSignatures1:
shortChanID = msg.ShortChannelID.ToUint64() shortChanID = msg.ShortChannelID.ToUint64()
case *lnwire.ChannelUpdate: case *lnwire.ChannelUpdate1:
shortChanID = msg.ShortChannelID.ToUint64() shortChanID = msg.ShortChannelID.ToUint64()
default: default:
t.Fatalf("found unexpected message type %T", msg) t.Fatalf("found unexpected message type %T", msg)

View file

@ -1412,9 +1412,11 @@ func (g *GossipSyncer) FilterGossipMsgs(msgs ...msgWithSenders) {
// set of channel announcements and channel updates. This will allow us // set of channel announcements and channel updates. This will allow us
// to quickly check if we should forward a chan ann, based on the known // to quickly check if we should forward a chan ann, based on the known
// channel updates for a channel. // channel updates for a channel.
chanUpdateIndex := make(map[lnwire.ShortChannelID][]*lnwire.ChannelUpdate) chanUpdateIndex := make(
map[lnwire.ShortChannelID][]*lnwire.ChannelUpdate1,
)
for _, msg := range msgs { for _, msg := range msgs {
chanUpdate, ok := msg.msg.(*lnwire.ChannelUpdate) chanUpdate, ok := msg.msg.(*lnwire.ChannelUpdate1)
if !ok { if !ok {
continue continue
} }
@ -1484,7 +1486,7 @@ func (g *GossipSyncer) FilterGossipMsgs(msgs ...msgWithSenders) {
// For each channel update, we'll only send if it the timestamp // For each channel update, we'll only send if it the timestamp
// is between our time range. // is between our time range.
case *lnwire.ChannelUpdate: case *lnwire.ChannelUpdate1:
if passesFilter(msg.Timestamp) { if passesFilter(msg.Timestamp) {
msgsToSend = append(msgsToSend, msg) msgsToSend = append(msgsToSend, msg)
} }

View file

@ -52,7 +52,7 @@ type mockChannelGraphTimeSeries struct {
annResp chan []lnwire.Message annResp chan []lnwire.Message
updateReq chan lnwire.ShortChannelID updateReq chan lnwire.ShortChannelID
updateResp chan []*lnwire.ChannelUpdate updateResp chan []*lnwire.ChannelUpdate1
} }
func newMockChannelGraphTimeSeries( func newMockChannelGraphTimeSeries(
@ -74,7 +74,7 @@ func newMockChannelGraphTimeSeries(
annResp: make(chan []lnwire.Message, 1), annResp: make(chan []lnwire.Message, 1),
updateReq: make(chan lnwire.ShortChannelID, 1), updateReq: make(chan lnwire.ShortChannelID, 1),
updateResp: make(chan []*lnwire.ChannelUpdate, 1), updateResp: make(chan []*lnwire.ChannelUpdate1, 1),
} }
} }
@ -149,7 +149,7 @@ func (m *mockChannelGraphTimeSeries) FetchChanAnns(chain chainhash.Hash,
return <-m.annResp, nil return <-m.annResp, nil
} }
func (m *mockChannelGraphTimeSeries) FetchChanUpdates(chain chainhash.Hash, func (m *mockChannelGraphTimeSeries) FetchChanUpdates(chain chainhash.Hash,
shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate, error) { shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate1, error) {
m.updateReq <- shortChanID m.updateReq <- shortChanID
@ -311,7 +311,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
}, },
}, },
{ {
msg: &lnwire.ChannelUpdate{ msg: &lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(10), ShortChannelID: lnwire.NewShortChanIDFromInt(10),
Timestamp: unixStamp(5), Timestamp: unixStamp(5),
}, },
@ -323,7 +323,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
}, },
}, },
{ {
msg: &lnwire.ChannelUpdate{ msg: &lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(15), ShortChannelID: lnwire.NewShortChanIDFromInt(15),
Timestamp: unixStamp(25002), Timestamp: unixStamp(25002),
}, },
@ -335,7 +335,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
}, },
}, },
{ {
msg: &lnwire.ChannelUpdate{ msg: &lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(20), ShortChannelID: lnwire.NewShortChanIDFromInt(20),
Timestamp: unixStamp(999999), Timestamp: unixStamp(999999),
}, },
@ -369,7 +369,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
} }
// If so, then we'll send back the missing update. // If so, then we'll send back the missing update.
chanSeries.updateResp <- []*lnwire.ChannelUpdate{ chanSeries.updateResp <- []*lnwire.ChannelUpdate1{
{ {
ShortChannelID: lnwire.NewShortChanIDFromInt(25), ShortChannelID: lnwire.NewShortChanIDFromInt(25),
Timestamp: unixStamp(5), Timestamp: unixStamp(5),
@ -551,7 +551,7 @@ func TestGossipSyncerApplyGossipFilter(t *testing.T) {
// For this first response, we'll send back a proper // For this first response, we'll send back a proper
// set of messages that should be echoed back. // set of messages that should be echoed back.
chanSeries.horizonResp <- []lnwire.Message{ chanSeries.horizonResp <- []lnwire.Message{
&lnwire.ChannelUpdate{ &lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(25), ShortChannelID: lnwire.NewShortChanIDFromInt(25),
Timestamp: unixStamp(5), Timestamp: unixStamp(5),
}, },
@ -709,7 +709,7 @@ func TestGossipSyncerReplyShortChanIDs(t *testing.T) {
&lnwire.ChannelAnnouncement1{ &lnwire.ChannelAnnouncement1{
ShortChannelID: lnwire.NewShortChanIDFromInt(20), ShortChannelID: lnwire.NewShortChanIDFromInt(20),
}, },
&lnwire.ChannelUpdate{ &lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(20), ShortChannelID: lnwire.NewShortChanIDFromInt(20),
Timestamp: unixStamp(999999), Timestamp: unixStamp(999999),
}, },

View file

@ -4144,7 +4144,7 @@ func (f *Manager) ensureInitialForwardingPolicy(chanID lnwire.ChannelID,
// send out to the network after a new channel has been created locally. // send out to the network after a new channel has been created locally.
type chanAnnouncement struct { type chanAnnouncement struct {
chanAnn *lnwire.ChannelAnnouncement1 chanAnn *lnwire.ChannelAnnouncement1
chanUpdateAnn *lnwire.ChannelUpdate chanUpdateAnn *lnwire.ChannelUpdate1
chanProof *lnwire.AnnounceSignatures1 chanProof *lnwire.AnnounceSignatures1
} }
@ -4238,7 +4238,7 @@ func (f *Manager) newChanAnnouncement(localPubKey,
// We announce the channel with the default values. Some of // We announce the channel with the default values. Some of
// these values can later be changed by crafting a new ChannelUpdate. // these values can later be changed by crafting a new ChannelUpdate.
chanUpdateAnn := &lnwire.ChannelUpdate{ chanUpdateAnn := &lnwire.ChannelUpdate1{
ShortChannelID: shortChanID, ShortChannelID: shortChanID,
ChainHash: chainHash, ChainHash: chainHash,
Timestamp: uint32(time.Now().Unix()), Timestamp: uint32(time.Now().Unix()),

View file

@ -1210,7 +1210,7 @@ func assertChannelAnnouncements(t *testing.T, alice, bob *testNode,
switch m := msg.(type) { switch m := msg.(type) {
case *lnwire.ChannelAnnouncement1: case *lnwire.ChannelAnnouncement1:
gotChannelAnnouncement = true gotChannelAnnouncement = true
case *lnwire.ChannelUpdate: case *lnwire.ChannelUpdate1:
// The channel update sent by the node should // The channel update sent by the node should
// advertise the MinHTLC value required by the // advertise the MinHTLC value required by the

View file

@ -127,7 +127,7 @@ func ValidateNodeAnn(a *lnwire.NodeAnnouncement) error {
// signed by the node's private key, and (2) that the announcement's message // signed by the node's private key, and (2) that the announcement's message
// flags and optional fields are sane. // flags and optional fields are sane.
func ValidateChannelUpdateAnn(pubKey *btcec.PublicKey, capacity btcutil.Amount, func ValidateChannelUpdateAnn(pubKey *btcec.PublicKey, capacity btcutil.Amount,
a *lnwire.ChannelUpdate) error { a *lnwire.ChannelUpdate1) error {
if err := ValidateChannelUpdateFields(capacity, a); err != nil { if err := ValidateChannelUpdateFields(capacity, a); err != nil {
return err return err
@ -138,7 +138,7 @@ func ValidateChannelUpdateAnn(pubKey *btcec.PublicKey, capacity btcutil.Amount,
// VerifyChannelUpdateSignature verifies that the channel update message was // VerifyChannelUpdateSignature verifies that the channel update message was
// signed by the party with the given node public key. // signed by the party with the given node public key.
func VerifyChannelUpdateSignature(msg *lnwire.ChannelUpdate, func VerifyChannelUpdateSignature(msg *lnwire.ChannelUpdate1,
pubKey *btcec.PublicKey) error { pubKey *btcec.PublicKey) error {
data, err := msg.DataToSign() data, err := msg.DataToSign()
@ -163,7 +163,7 @@ func VerifyChannelUpdateSignature(msg *lnwire.ChannelUpdate,
// ValidateChannelUpdateFields validates a channel update's message flags and // ValidateChannelUpdateFields validates a channel update's message flags and
// corresponding update fields. // corresponding update fields.
func ValidateChannelUpdateFields(capacity btcutil.Amount, func ValidateChannelUpdateFields(capacity btcutil.Amount,
msg *lnwire.ChannelUpdate) error { msg *lnwire.ChannelUpdate1) error {
// The maxHTLC flag is mandatory. // The maxHTLC flag is mandatory.
if !msg.MessageFlags.HasMaxHtlc() { if !msg.MessageFlags.HasMaxHtlc() {

View file

@ -1521,7 +1521,7 @@ type routingMsg struct {
// ApplyChannelUpdate validates a channel update and if valid, applies it to the // ApplyChannelUpdate validates a channel update and if valid, applies it to the
// database. It returns a bool indicating whether the updates were successful. // database. It returns a bool indicating whether the updates were successful.
func (b *Builder) ApplyChannelUpdate(msg *lnwire.ChannelUpdate) bool { func (b *Builder) ApplyChannelUpdate(msg *lnwire.ChannelUpdate1) bool {
ch, _, _, err := b.GetChannelByID(msg.ShortChannelID) ch, _, _, err := b.GetChannelByID(msg.ShortChannelID)
if err != nil { if err != nil {
log.Errorf("Unable to retrieve channel by id: %v", err) log.Errorf("Unable to retrieve channel by id: %v", err)

View file

@ -146,7 +146,7 @@ func (v *ValidationBarrier) InitJobDependencies(job interface{}) {
// initialization needs to be done beyond just occupying a job slot. // initialization needs to be done beyond just occupying a job slot.
case *models.ChannelEdgePolicy: case *models.ChannelEdgePolicy:
return return
case *lnwire.ChannelUpdate: case *lnwire.ChannelUpdate1:
return return
case *lnwire.NodeAnnouncement: case *lnwire.NodeAnnouncement:
// TODO(roasbeef): node ann needs to wait on existing channel updates // TODO(roasbeef): node ann needs to wait on existing channel updates
@ -202,7 +202,7 @@ func (v *ValidationBarrier) WaitForDependants(job interface{}) error {
jobDesc = fmt.Sprintf("job=channeldb.LightningNode, pub=%s", jobDesc = fmt.Sprintf("job=channeldb.LightningNode, pub=%s",
vertex) vertex)
case *lnwire.ChannelUpdate: case *lnwire.ChannelUpdate1:
signals, ok = v.chanEdgeDependencies[msg.ShortChannelID] signals, ok = v.chanEdgeDependencies[msg.ShortChannelID]
jobDesc = fmt.Sprintf("job=lnwire.ChannelUpdate, scid=%v", jobDesc = fmt.Sprintf("job=lnwire.ChannelUpdate, scid=%v",
@ -295,7 +295,7 @@ func (v *ValidationBarrier) SignalDependants(job interface{}, allow bool) {
delete(v.nodeAnnDependencies, route.Vertex(msg.PubKeyBytes)) delete(v.nodeAnnDependencies, route.Vertex(msg.PubKeyBytes))
case *lnwire.NodeAnnouncement: case *lnwire.NodeAnnouncement:
delete(v.nodeAnnDependencies, route.Vertex(msg.NodeID)) delete(v.nodeAnnDependencies, route.Vertex(msg.NodeID))
case *lnwire.ChannelUpdate: case *lnwire.ChannelUpdate1:
delete(v.chanEdgeDependencies, msg.ShortChannelID) delete(v.chanEdgeDependencies, msg.ShortChannelID)
case *models.ChannelEdgePolicy: case *models.ChannelEdgePolicy:
shortID := lnwire.NewShortChanIDFromInt(msg.ChannelID) shortID := lnwire.NewShortChanIDFromInt(msg.ChannelID)

View file

@ -85,9 +85,9 @@ func TestValidationBarrierQuit(t *testing.T) {
// Create a set of channel updates, that must wait until their // Create a set of channel updates, that must wait until their
// associated channel announcement has been verified. // associated channel announcement has been verified.
chanUpds := make([]*lnwire.ChannelUpdate, 0, numTasks) chanUpds := make([]*lnwire.ChannelUpdate1, 0, numTasks)
for i := 0; i < numTasks; i++ { for i := 0; i < numTasks; i++ {
chanUpds = append(chanUpds, &lnwire.ChannelUpdate{ chanUpds = append(chanUpds, &lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(uint64(i)), ShortChannelID: lnwire.NewShortChanIDFromInt(uint64(i)),
}) })
barrier.InitJobDependencies(chanUpds[i]) barrier.InitJobDependencies(chanUpds[i])

View file

@ -85,7 +85,7 @@ type scidAliasHandler interface {
// HTLCs on option_scid_alias channels. // HTLCs on option_scid_alias channels.
attachFailAliasUpdate(failClosure func( attachFailAliasUpdate(failClosure func(
sid lnwire.ShortChannelID, sid lnwire.ShortChannelID,
incoming bool) *lnwire.ChannelUpdate) incoming bool) *lnwire.ChannelUpdate1)
// getAliases fetches the link's underlying aliases. This is used by // getAliases fetches the link's underlying aliases. This is used by
// the Switch to determine whether to forward an HTLC and where to // the Switch to determine whether to forward an HTLC and where to

View file

@ -119,7 +119,8 @@ type ChannelLinkConfig struct {
// specified when we receive an incoming HTLC. This will be used to // specified when we receive an incoming HTLC. This will be used to
// provide payment senders our latest policy when sending encrypted // provide payment senders our latest policy when sending encrypted
// error messages. // error messages.
FetchLastChannelUpdate func(lnwire.ShortChannelID) (*lnwire.ChannelUpdate, error) FetchLastChannelUpdate func(lnwire.ShortChannelID) (
*lnwire.ChannelUpdate1, error)
// Peer is a lightning network node with which we have the channel link // Peer is a lightning network node with which we have the channel link
// opened. // opened.
@ -261,7 +262,7 @@ type ChannelLinkConfig struct {
// FailAliasUpdate is a function used to fail an HTLC for an // FailAliasUpdate is a function used to fail an HTLC for an
// option_scid_alias channel. // option_scid_alias channel.
FailAliasUpdate func(sid lnwire.ShortChannelID, FailAliasUpdate func(sid lnwire.ShortChannelID,
incoming bool) *lnwire.ChannelUpdate incoming bool) *lnwire.ChannelUpdate1
// GetAliases is used by the link and switch to fetch the set of // GetAliases is used by the link and switch to fetch the set of
// aliases for a given link. // aliases for a given link.
@ -763,7 +764,7 @@ func shouldAdjustCommitFee(netFee, chanFee,
} }
// failCb is used to cut down on the argument verbosity. // failCb is used to cut down on the argument verbosity.
type failCb func(update *lnwire.ChannelUpdate) lnwire.FailureMessage type failCb func(update *lnwire.ChannelUpdate1) lnwire.FailureMessage
// createFailureWithUpdate creates a ChannelUpdate when failing an incoming or // createFailureWithUpdate creates a ChannelUpdate when failing an incoming or
// outgoing HTLC. It may return a FailureMessage that references a channel's // outgoing HTLC. It may return a FailureMessage that references a channel's
@ -2961,7 +2962,7 @@ func (l *channelLink) getAliases() []lnwire.ShortChannelID {
// //
// Part of the scidAliasHandler interface. // Part of the scidAliasHandler interface.
func (l *channelLink) attachFailAliasUpdate(closure func( func (l *channelLink) attachFailAliasUpdate(closure func(
sid lnwire.ShortChannelID, incoming bool) *lnwire.ChannelUpdate) { sid lnwire.ShortChannelID, incoming bool) *lnwire.ChannelUpdate1) {
l.Lock() l.Lock()
l.cfg.FailAliasUpdate = closure l.cfg.FailAliasUpdate = closure
@ -3053,7 +3054,7 @@ func (l *channelLink) CheckHtlcForward(payHash [32]byte,
// As part of the returned error, we'll send our latest routing // As part of the returned error, we'll send our latest routing
// policy so the sending node obtains the most up to date data. // policy so the sending node obtains the most up to date data.
cb := func(upd *lnwire.ChannelUpdate) lnwire.FailureMessage { cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
return lnwire.NewFeeInsufficient(amtToForward, *upd) return lnwire.NewFeeInsufficient(amtToForward, *upd)
} }
failure := l.createFailureWithUpdate(false, originalScid, cb) failure := l.createFailureWithUpdate(false, originalScid, cb)
@ -3081,7 +3082,7 @@ func (l *channelLink) CheckHtlcForward(payHash [32]byte,
// Grab the latest routing policy so the sending node is up to // Grab the latest routing policy so the sending node is up to
// date with our current policy. // date with our current policy.
cb := func(upd *lnwire.ChannelUpdate) lnwire.FailureMessage { cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
return lnwire.NewIncorrectCltvExpiry( return lnwire.NewIncorrectCltvExpiry(
incomingTimeout, *upd, incomingTimeout, *upd,
) )
@ -3130,7 +3131,7 @@ func (l *channelLink) canSendHtlc(policy models.ForwardingPolicy,
// As part of the returned error, we'll send our latest routing // As part of the returned error, we'll send our latest routing
// policy so the sending node obtains the most up to date data. // policy so the sending node obtains the most up to date data.
cb := func(upd *lnwire.ChannelUpdate) lnwire.FailureMessage { cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
return lnwire.NewAmountBelowMinimum(amt, *upd) return lnwire.NewAmountBelowMinimum(amt, *upd)
} }
failure := l.createFailureWithUpdate(false, originalScid, cb) failure := l.createFailureWithUpdate(false, originalScid, cb)
@ -3145,7 +3146,7 @@ func (l *channelLink) canSendHtlc(policy models.ForwardingPolicy,
// As part of the returned error, we'll send our latest routing // As part of the returned error, we'll send our latest routing
// policy so the sending node obtains the most up-to-date data. // policy so the sending node obtains the most up-to-date data.
cb := func(upd *lnwire.ChannelUpdate) lnwire.FailureMessage { cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
return lnwire.NewTemporaryChannelFailure(upd) return lnwire.NewTemporaryChannelFailure(upd)
} }
failure := l.createFailureWithUpdate(false, originalScid, cb) failure := l.createFailureWithUpdate(false, originalScid, cb)
@ -3160,7 +3161,7 @@ func (l *channelLink) canSendHtlc(policy models.ForwardingPolicy,
"outgoing_expiry=%v, best_height=%v", payHash[:], "outgoing_expiry=%v, best_height=%v", payHash[:],
timeout, heightNow) timeout, heightNow)
cb := func(upd *lnwire.ChannelUpdate) lnwire.FailureMessage { cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
return lnwire.NewExpiryTooSoon(*upd) return lnwire.NewExpiryTooSoon(*upd)
} }
failure := l.createFailureWithUpdate(false, originalScid, cb) failure := l.createFailureWithUpdate(false, originalScid, cb)
@ -3180,7 +3181,7 @@ func (l *channelLink) canSendHtlc(policy models.ForwardingPolicy,
if amt > l.Bandwidth() { if amt > l.Bandwidth() {
l.log.Warnf("insufficient bandwidth to route htlc: %v is "+ l.log.Warnf("insufficient bandwidth to route htlc: %v is "+
"larger than %v", amt, l.Bandwidth()) "larger than %v", amt, l.Bandwidth())
cb := func(upd *lnwire.ChannelUpdate) lnwire.FailureMessage { cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
return lnwire.NewTemporaryChannelFailure(upd) return lnwire.NewTemporaryChannelFailure(upd)
} }
failure := l.createFailureWithUpdate(false, originalScid, cb) failure := l.createFailureWithUpdate(false, originalScid, cb)
@ -3693,7 +3694,7 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg,
l.log.Errorf("unable to encode the "+ l.log.Errorf("unable to encode the "+
"remaining route %v", err) "remaining route %v", err)
cb := func(upd *lnwire.ChannelUpdate) lnwire.FailureMessage { cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage { //nolint:lll
return lnwire.NewTemporaryChannelFailure(upd) return lnwire.NewTemporaryChannelFailure(upd)
} }

View file

@ -6166,13 +6166,13 @@ func TestForwardingAsymmetricTimeLockPolicies(t *testing.T) {
// forwarding policy. // forwarding policy.
func TestCheckHtlcForward(t *testing.T) { func TestCheckHtlcForward(t *testing.T) {
fetchLastChannelUpdate := func(lnwire.ShortChannelID) ( fetchLastChannelUpdate := func(lnwire.ShortChannelID) (
*lnwire.ChannelUpdate, error) { *lnwire.ChannelUpdate1, error) {
return &lnwire.ChannelUpdate{}, nil return &lnwire.ChannelUpdate1{}, nil
} }
failAliasUpdate := func(sid lnwire.ShortChannelID, failAliasUpdate := func(sid lnwire.ShortChannelID,
incoming bool) *lnwire.ChannelUpdate { incoming bool) *lnwire.ChannelUpdate1 {
return nil return nil
} }

View file

@ -166,7 +166,7 @@ type mockServer struct {
var _ lnpeer.Peer = (*mockServer)(nil) var _ lnpeer.Peer = (*mockServer)(nil)
func initSwitchWithDB(startingHeight uint32, db *channeldb.DB) (*Switch, error) { func initSwitchWithDB(startingHeight uint32, db *channeldb.DB) (*Switch, error) {
signAliasUpdate := func(u *lnwire.ChannelUpdate) (*ecdsa.Signature, signAliasUpdate := func(u *lnwire.ChannelUpdate1) (*ecdsa.Signature,
error) { error) {
return testSig, nil return testSig, nil
@ -182,9 +182,9 @@ func initSwitchWithDB(startingHeight uint32, db *channeldb.DB) (*Switch, error)
events: make(map[time.Time]channeldb.ForwardingEvent), events: make(map[time.Time]channeldb.ForwardingEvent),
}, },
FetchLastChannelUpdate: func(scid lnwire.ShortChannelID) ( FetchLastChannelUpdate: func(scid lnwire.ShortChannelID) (
*lnwire.ChannelUpdate, error) { *lnwire.ChannelUpdate1, error) {
return &lnwire.ChannelUpdate{ return &lnwire.ChannelUpdate1{
ShortChannelID: scid, ShortChannelID: scid,
}, nil }, nil
}, },
@ -734,7 +734,7 @@ type mockChannelLink struct {
checkHtlcForwardResult *LinkError checkHtlcForwardResult *LinkError
failAliasUpdate func(sid lnwire.ShortChannelID, failAliasUpdate func(sid lnwire.ShortChannelID,
incoming bool) *lnwire.ChannelUpdate incoming bool) *lnwire.ChannelUpdate1
confirmedZC bool confirmedZC bool
} }
@ -869,7 +869,7 @@ func (f *mockChannelLink) AttachMailBox(mailBox MailBox) {
} }
func (f *mockChannelLink) attachFailAliasUpdate(closure func( func (f *mockChannelLink) attachFailAliasUpdate(closure func(
sid lnwire.ShortChannelID, incoming bool) *lnwire.ChannelUpdate) { sid lnwire.ShortChannelID, incoming bool) *lnwire.ChannelUpdate1) {
f.failAliasUpdate = closure f.failAliasUpdate = closure
} }

View file

@ -173,7 +173,8 @@ type Config struct {
// specified when we receive an incoming HTLC. This will be used to // specified when we receive an incoming HTLC. This will be used to
// provide payment senders our latest policy when sending encrypted // provide payment senders our latest policy when sending encrypted
// error messages. // error messages.
FetchLastChannelUpdate func(lnwire.ShortChannelID) (*lnwire.ChannelUpdate, error) FetchLastChannelUpdate func(lnwire.ShortChannelID) (
*lnwire.ChannelUpdate1, error)
// Notifier is an instance of a chain notifier that we'll use to signal // Notifier is an instance of a chain notifier that we'll use to signal
// the switch when a new block has arrived. // the switch when a new block has arrived.
@ -220,7 +221,7 @@ type Config struct {
// option_scid_alias channels. This avoids a potential privacy leak by // option_scid_alias channels. This avoids a potential privacy leak by
// replacing the public, confirmed SCID with the alias in the // replacing the public, confirmed SCID with the alias in the
// ChannelUpdate. // ChannelUpdate.
SignAliasUpdate func(u *lnwire.ChannelUpdate) (*ecdsa.Signature, SignAliasUpdate func(u *lnwire.ChannelUpdate1) (*ecdsa.Signature,
error) error)
// IsAlias returns whether or not a given SCID is an alias. // IsAlias returns whether or not a given SCID is an alias.
@ -2615,7 +2616,7 @@ func (s *Switch) failMailboxUpdate(outgoingScid,
// and the caller is expected to handle this properly. In this case, a return // and the caller is expected to handle this properly. In this case, a return
// to the original non-alias behavior is expected. // to the original non-alias behavior is expected.
func (s *Switch) failAliasUpdate(scid lnwire.ShortChannelID, func (s *Switch) failAliasUpdate(scid lnwire.ShortChannelID,
incoming bool) *lnwire.ChannelUpdate { incoming bool) *lnwire.ChannelUpdate1 {
// This function does not defer the unlocking because of the database // This function does not defer the unlocking because of the database
// lookups for ChannelUpdate. // lookups for ChannelUpdate.

View file

@ -3951,7 +3951,7 @@ func TestSwitchHoldForward(t *testing.T) {
// Simulate an error during the composition of the failure message. // Simulate an error during the composition of the failure message.
currentCallback := c.s.cfg.FetchLastChannelUpdate currentCallback := c.s.cfg.FetchLastChannelUpdate
c.s.cfg.FetchLastChannelUpdate = func( c.s.cfg.FetchLastChannelUpdate = func(
lnwire.ShortChannelID) (*lnwire.ChannelUpdate, error) { lnwire.ShortChannelID) (*lnwire.ChannelUpdate1, error) {
return nil, errors.New("cannot fetch update") return nil, errors.New("cannot fetch update")
} }

View file

@ -91,8 +91,10 @@ func genIDs() (lnwire.ChannelID, lnwire.ChannelID, lnwire.ShortChannelID,
// mockGetChanUpdateMessage helper function which returns topology update of // mockGetChanUpdateMessage helper function which returns topology update of
// the channel // the channel
func mockGetChanUpdateMessage(cid lnwire.ShortChannelID) (*lnwire.ChannelUpdate, error) { func mockGetChanUpdateMessage(_ lnwire.ShortChannelID) (*lnwire.ChannelUpdate1,
return &lnwire.ChannelUpdate{ error) {
return &lnwire.ChannelUpdate1{
Signature: wireSig, Signature: wireSig,
}, nil }, nil
} }

View file

@ -1605,7 +1605,7 @@ func marshallWireError(msg lnwire.FailureMessage,
// marshallChannelUpdate marshalls a channel update as received over the wire to // marshallChannelUpdate marshalls a channel update as received over the wire to
// the router rpc format. // the router rpc format.
func marshallChannelUpdate(update *lnwire.ChannelUpdate) *lnrpc.ChannelUpdate { func marshallChannelUpdate(update *lnwire.ChannelUpdate1) *lnrpc.ChannelUpdate {
if update == nil { if update == nil {
return nil return nil
} }

View file

@ -56,11 +56,11 @@ func (c ChanUpdateChanFlags) String() string {
return fmt.Sprintf("%08b", c) return fmt.Sprintf("%08b", c)
} }
// ChannelUpdate message is used after channel has been initially announced. // ChannelUpdate1 message is used after channel has been initially announced.
// Each side independently announces its fees and minimum expiry for HTLCs and // Each side independently announces its fees and minimum expiry for HTLCs and
// other parameters. Also this message is used to redeclare initially set // other parameters. Also this message is used to redeclare initially set
// channel parameters. // channel parameters.
type ChannelUpdate struct { type ChannelUpdate1 struct {
// Signature is used to validate the announced data and prove the // Signature is used to validate the announced data and prove the
// ownership of node id. // ownership of node id.
Signature Sig Signature Sig
@ -122,13 +122,13 @@ type ChannelUpdate struct {
// A compile time check to ensure ChannelUpdate implements the lnwire.Message // A compile time check to ensure ChannelUpdate implements the lnwire.Message
// interface. // interface.
var _ Message = (*ChannelUpdate)(nil) var _ Message = (*ChannelUpdate1)(nil)
// Decode deserializes a serialized ChannelUpdate stored in the passed // Decode deserializes a serialized ChannelUpdate stored in the passed
// io.Reader observing the specified protocol version. // io.Reader observing the specified protocol version.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (a *ChannelUpdate) Decode(r io.Reader, pver uint32) error { func (a *ChannelUpdate1) Decode(r io.Reader, pver uint32) error {
err := ReadElements(r, err := ReadElements(r,
&a.Signature, &a.Signature,
a.ChainHash[:], a.ChainHash[:],
@ -159,7 +159,7 @@ func (a *ChannelUpdate) Decode(r io.Reader, pver uint32) error {
// observing the protocol version specified. // observing the protocol version specified.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (a *ChannelUpdate) Encode(w *bytes.Buffer, pver uint32) error { func (a *ChannelUpdate1) Encode(w *bytes.Buffer, pver uint32) error {
if err := WriteSig(w, a.Signature); err != nil { if err := WriteSig(w, a.Signature); err != nil {
return err return err
} }
@ -217,13 +217,13 @@ func (a *ChannelUpdate) Encode(w *bytes.Buffer, pver uint32) error {
// wire. // wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (a *ChannelUpdate) MsgType() MessageType { func (a *ChannelUpdate1) MsgType() MessageType {
return MsgChannelUpdate return MsgChannelUpdate
} }
// DataToSign is used to retrieve part of the announcement message which should // DataToSign is used to retrieve part of the announcement message which should
// be signed. // be signed.
func (a *ChannelUpdate) DataToSign() ([]byte, error) { func (a *ChannelUpdate1) DataToSign() ([]byte, error) {
// We should not include the signatures itself. // We should not include the signatures itself.
b := make([]byte, 0, MaxMsgBody) b := make([]byte, 0, MaxMsgBody)
buf := bytes.NewBuffer(b) buf := bytes.NewBuffer(b)

View file

@ -1047,7 +1047,7 @@ func TestLightningWireProtocol(t *testing.T) {
maxHtlc = 0 maxHtlc = 0
} }
req := ChannelUpdate{ req := ChannelUpdate1{
ShortChannelID: NewShortChanIDFromInt(uint64(r.Int63())), ShortChannelID: NewShortChanIDFromInt(uint64(r.Int63())),
Timestamp: uint32(r.Int31()), Timestamp: uint32(r.Int31()),
MessageFlags: msgFlags, MessageFlags: msgFlags,
@ -1565,7 +1565,7 @@ func TestLightningWireProtocol(t *testing.T) {
}, },
{ {
msgType: MsgChannelUpdate, msgType: MsgChannelUpdate,
scenario: func(m ChannelUpdate) bool { scenario: func(m ChannelUpdate1) bool {
return mainScenario(&m) return mainScenario(&m)
}, },
}, },

View file

@ -261,7 +261,7 @@ func makeEmptyMessage(msgType MessageType) (Message, error) {
case MsgChannelAnnouncement: case MsgChannelAnnouncement:
msg = &ChannelAnnouncement1{} msg = &ChannelAnnouncement1{}
case MsgChannelUpdate: case MsgChannelUpdate:
msg = &ChannelUpdate{} msg = &ChannelUpdate1{}
case MsgNodeAnnouncement: case MsgNodeAnnouncement:
msg = &NodeAnnouncement{} msg = &NodeAnnouncement{}
case MsgPing: case MsgPing:

View file

@ -692,7 +692,7 @@ func newMsgNodeAnnouncement(t testing.TB,
return msg return msg
} }
func newMsgChannelUpdate(t testing.TB, r *rand.Rand) *lnwire.ChannelUpdate { func newMsgChannelUpdate(t testing.TB, r *rand.Rand) *lnwire.ChannelUpdate1 {
t.Helper() t.Helper()
msgFlags := lnwire.ChanUpdateMsgFlags(r.Int31()) msgFlags := lnwire.ChanUpdateMsgFlags(r.Int31())
@ -706,7 +706,7 @@ func newMsgChannelUpdate(t testing.TB, r *rand.Rand) *lnwire.ChannelUpdate {
maxHtlc = 0 maxHtlc = 0
} }
msg := &lnwire.ChannelUpdate{ msg := &lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(r.Uint64()), ShortChannelID: lnwire.NewShortChanIDFromInt(r.Uint64()),
Timestamp: uint32(r.Int31()), Timestamp: uint32(r.Int31()),
MessageFlags: msgFlags, MessageFlags: msgFlags,

View file

@ -600,7 +600,7 @@ func (f *FailInvalidOnionKey) Error() string {
// unable to pull out a fully valid version, then we'll fall back to the // unable to pull out a fully valid version, then we'll fall back to the
// regular parsing mechanism which includes the length prefix an NO type byte. // regular parsing mechanism which includes the length prefix an NO type byte.
func parseChannelUpdateCompatibilityMode(reader io.Reader, length uint16, func parseChannelUpdateCompatibilityMode(reader io.Reader, length uint16,
chanUpdate *ChannelUpdate, pver uint32) error { chanUpdate *ChannelUpdate1, pver uint32) error {
// Instantiate a LimitReader because there may be additional data // Instantiate a LimitReader because there may be additional data
// present after the channel update. Without limiting the stream, the // present after the channel update. Without limiting the stream, the
@ -647,11 +647,13 @@ type FailTemporaryChannelFailure struct {
// which caused the failure. // which caused the failure.
// //
// NOTE: This field is optional. // NOTE: This field is optional.
Update *ChannelUpdate Update *ChannelUpdate1
} }
// NewTemporaryChannelFailure creates new instance of the FailTemporaryChannelFailure. // NewTemporaryChannelFailure creates new instance of the FailTemporaryChannelFailure.
func NewTemporaryChannelFailure(update *ChannelUpdate) *FailTemporaryChannelFailure { func NewTemporaryChannelFailure(
update *ChannelUpdate1) *FailTemporaryChannelFailure {
return &FailTemporaryChannelFailure{Update: update} return &FailTemporaryChannelFailure{Update: update}
} }
@ -685,7 +687,7 @@ func (f *FailTemporaryChannelFailure) Decode(r io.Reader, pver uint32) error {
} }
if length != 0 { if length != 0 {
f.Update = &ChannelUpdate{} f.Update = &ChannelUpdate1{}
return parseChannelUpdateCompatibilityMode( return parseChannelUpdateCompatibilityMode(
r, length, f.Update, pver, r, length, f.Update, pver,
@ -720,12 +722,12 @@ type FailAmountBelowMinimum struct {
// Update is used to update information about state of the channel // Update is used to update information about state of the channel
// which caused the failure. // which caused the failure.
Update ChannelUpdate Update ChannelUpdate1
} }
// NewAmountBelowMinimum creates new instance of the FailAmountBelowMinimum. // NewAmountBelowMinimum creates new instance of the FailAmountBelowMinimum.
func NewAmountBelowMinimum(htlcMsat MilliSatoshi, func NewAmountBelowMinimum(htlcMsat MilliSatoshi,
update ChannelUpdate) *FailAmountBelowMinimum { update ChannelUpdate1) *FailAmountBelowMinimum {
return &FailAmountBelowMinimum{ return &FailAmountBelowMinimum{
HtlcMsat: htlcMsat, HtlcMsat: htlcMsat,
@ -761,7 +763,7 @@ func (f *FailAmountBelowMinimum) Decode(r io.Reader, pver uint32) error {
return err return err
} }
f.Update = ChannelUpdate{} f.Update = ChannelUpdate1{}
return parseChannelUpdateCompatibilityMode( return parseChannelUpdateCompatibilityMode(
r, length, &f.Update, pver, r, length, &f.Update, pver,
@ -790,12 +792,12 @@ type FailFeeInsufficient struct {
// Update is used to update information about state of the channel // Update is used to update information about state of the channel
// which caused the failure. // which caused the failure.
Update ChannelUpdate Update ChannelUpdate1
} }
// NewFeeInsufficient creates new instance of the FailFeeInsufficient. // NewFeeInsufficient creates new instance of the FailFeeInsufficient.
func NewFeeInsufficient(htlcMsat MilliSatoshi, func NewFeeInsufficient(htlcMsat MilliSatoshi,
update ChannelUpdate) *FailFeeInsufficient { update ChannelUpdate1) *FailFeeInsufficient {
return &FailFeeInsufficient{ return &FailFeeInsufficient{
HtlcMsat: htlcMsat, HtlcMsat: htlcMsat,
Update: update, Update: update,
@ -830,7 +832,7 @@ func (f *FailFeeInsufficient) Decode(r io.Reader, pver uint32) error {
return err return err
} }
f.Update = ChannelUpdate{} f.Update = ChannelUpdate1{}
return parseChannelUpdateCompatibilityMode( return parseChannelUpdateCompatibilityMode(
r, length, &f.Update, pver, r, length, &f.Update, pver,
@ -861,12 +863,12 @@ type FailIncorrectCltvExpiry struct {
// Update is used to update information about state of the channel // Update is used to update information about state of the channel
// which caused the failure. // which caused the failure.
Update ChannelUpdate Update ChannelUpdate1
} }
// NewIncorrectCltvExpiry creates new instance of the FailIncorrectCltvExpiry. // NewIncorrectCltvExpiry creates new instance of the FailIncorrectCltvExpiry.
func NewIncorrectCltvExpiry(cltvExpiry uint32, func NewIncorrectCltvExpiry(cltvExpiry uint32,
update ChannelUpdate) *FailIncorrectCltvExpiry { update ChannelUpdate1) *FailIncorrectCltvExpiry {
return &FailIncorrectCltvExpiry{ return &FailIncorrectCltvExpiry{
CltvExpiry: cltvExpiry, CltvExpiry: cltvExpiry,
@ -899,7 +901,7 @@ func (f *FailIncorrectCltvExpiry) Decode(r io.Reader, pver uint32) error {
return err return err
} }
f.Update = ChannelUpdate{} f.Update = ChannelUpdate1{}
return parseChannelUpdateCompatibilityMode( return parseChannelUpdateCompatibilityMode(
r, length, &f.Update, pver, r, length, &f.Update, pver,
@ -924,11 +926,11 @@ func (f *FailIncorrectCltvExpiry) Encode(w *bytes.Buffer, pver uint32) error {
type FailExpiryTooSoon struct { type FailExpiryTooSoon struct {
// Update is used to update information about state of the channel // Update is used to update information about state of the channel
// which caused the failure. // which caused the failure.
Update ChannelUpdate Update ChannelUpdate1
} }
// NewExpiryTooSoon creates new instance of the FailExpiryTooSoon. // NewExpiryTooSoon creates new instance of the FailExpiryTooSoon.
func NewExpiryTooSoon(update ChannelUpdate) *FailExpiryTooSoon { func NewExpiryTooSoon(update ChannelUpdate1) *FailExpiryTooSoon {
return &FailExpiryTooSoon{ return &FailExpiryTooSoon{
Update: update, Update: update,
} }
@ -957,7 +959,7 @@ func (f *FailExpiryTooSoon) Decode(r io.Reader, pver uint32) error {
return err return err
} }
f.Update = ChannelUpdate{} f.Update = ChannelUpdate1{}
return parseChannelUpdateCompatibilityMode( return parseChannelUpdateCompatibilityMode(
r, length, &f.Update, pver, r, length, &f.Update, pver,
@ -983,11 +985,13 @@ type FailChannelDisabled struct {
// Update is used to update information about state of the channel // Update is used to update information about state of the channel
// which caused the failure. // which caused the failure.
Update ChannelUpdate Update ChannelUpdate1
} }
// NewChannelDisabled creates new instance of the FailChannelDisabled. // NewChannelDisabled creates new instance of the FailChannelDisabled.
func NewChannelDisabled(flags uint16, update ChannelUpdate) *FailChannelDisabled { func NewChannelDisabled(flags uint16,
update ChannelUpdate1) *FailChannelDisabled {
return &FailChannelDisabled{ return &FailChannelDisabled{
Flags: flags, Flags: flags,
Update: update, Update: update,
@ -1022,7 +1026,7 @@ func (f *FailChannelDisabled) Decode(r io.Reader, pver uint32) error {
return err return err
} }
f.Update = ChannelUpdate{} f.Update = ChannelUpdate1{}
return parseChannelUpdateCompatibilityMode( return parseChannelUpdateCompatibilityMode(
r, length, &f.Update, pver, r, length, &f.Update, pver,
@ -1510,7 +1514,7 @@ func makeEmptyOnionError(code FailCode) (FailureMessage, error) {
// writeOnionErrorChanUpdate writes out a ChannelUpdate using the onion error // writeOnionErrorChanUpdate writes out a ChannelUpdate using the onion error
// format. The format is that we first write out the true serialized length of // format. The format is that we first write out the true serialized length of
// the channel update, followed by the serialized channel update itself. // the channel update, followed by the serialized channel update itself.
func writeOnionErrorChanUpdate(w *bytes.Buffer, chanUpdate *ChannelUpdate, func writeOnionErrorChanUpdate(w *bytes.Buffer, chanUpdate *ChannelUpdate1,
pver uint32) error { pver uint32) error {
// First, we encode the channel update in a temporary buffer in order // First, we encode the channel update in a temporary buffer in order

View file

@ -20,7 +20,7 @@ var (
testType = uint64(3) testType = uint64(3)
testOffset = uint16(24) testOffset = uint16(24)
sig, _ = NewSigFromSignature(testSig) sig, _ = NewSigFromSignature(testSig)
testChannelUpdate = ChannelUpdate{ testChannelUpdate = ChannelUpdate1{
Signature: sig, Signature: sig,
ShortChannelID: NewShortChanIDFromInt(1), ShortChannelID: NewShortChanIDFromInt(1),
Timestamp: 1, Timestamp: 1,
@ -137,7 +137,7 @@ func TestChannelUpdateCompatibilityParsing(t *testing.T) {
// Now that we have the set of bytes encoded, we'll ensure that we're // Now that we have the set of bytes encoded, we'll ensure that we're
// able to decode it using our compatibility method, as it's a regular // able to decode it using our compatibility method, as it's a regular
// encoded channel update message. // encoded channel update message.
var newChanUpdate ChannelUpdate var newChanUpdate ChannelUpdate1
err := parseChannelUpdateCompatibilityMode( err := parseChannelUpdateCompatibilityMode(
&b, uint16(b.Len()), &newChanUpdate, 0, &b, uint16(b.Len()), &newChanUpdate, 0,
) )
@ -164,7 +164,7 @@ func TestChannelUpdateCompatibilityParsing(t *testing.T) {
// We should be able to properly parse the encoded channel update // We should be able to properly parse the encoded channel update
// message even with the extra two bytes. // message even with the extra two bytes.
var newChanUpdate2 ChannelUpdate var newChanUpdate2 ChannelUpdate1
err = parseChannelUpdateCompatibilityMode( err = parseChannelUpdateCompatibilityMode(
&b, uint16(b.Len()), &newChanUpdate2, 0, &b, uint16(b.Len()), &newChanUpdate2, 0,
) )

View file

@ -60,7 +60,7 @@ type ChanStatusConfig struct {
// ApplyChannelUpdate processes new ChannelUpdates signed by our node by // ApplyChannelUpdate processes new ChannelUpdates signed by our node by
// updating our local routing table and broadcasting the update to our // updating our local routing table and broadcasting the update to our
// peers. // peers.
ApplyChannelUpdate func(*lnwire.ChannelUpdate, *wire.OutPoint, ApplyChannelUpdate func(*lnwire.ChannelUpdate1, *wire.OutPoint,
bool) error bool) error
// DB stores the set of channels that are to be monitored. // DB stores the set of channels that are to be monitored.
@ -650,7 +650,7 @@ func (m *ChanStatusManager) signAndSendNextUpdate(outpoint wire.OutPoint,
// in case our ChannelEdgePolicy is not found in the database. Also returns if // in case our ChannelEdgePolicy is not found in the database. Also returns if
// the channel is private by checking AuthProof for nil. // the channel is private by checking AuthProof for nil.
func (m *ChanStatusManager) fetchLastChanUpdateByOutPoint(op wire.OutPoint) ( func (m *ChanStatusManager) fetchLastChanUpdateByOutPoint(op wire.OutPoint) (
*lnwire.ChannelUpdate, bool, error) { *lnwire.ChannelUpdate1, bool, error) {
// Get the edge info and policies for this channel from the graph. // Get the edge info and policies for this channel from the graph.
info, edge1, edge2, err := m.cfg.Graph.FetchChannelEdgesByOutpoint(&op) info, edge1, edge2, err := m.cfg.Graph.FetchChannelEdgesByOutpoint(&op)

View file

@ -126,7 +126,7 @@ type mockGraph struct {
chanPols2 map[wire.OutPoint]*models.ChannelEdgePolicy chanPols2 map[wire.OutPoint]*models.ChannelEdgePolicy
sidToCid map[lnwire.ShortChannelID]wire.OutPoint sidToCid map[lnwire.ShortChannelID]wire.OutPoint
updates chan *lnwire.ChannelUpdate updates chan *lnwire.ChannelUpdate1
} }
func newMockGraph(t *testing.T, numChannels int, func newMockGraph(t *testing.T, numChannels int,
@ -138,7 +138,7 @@ func newMockGraph(t *testing.T, numChannels int,
chanPols1: make(map[wire.OutPoint]*models.ChannelEdgePolicy), chanPols1: make(map[wire.OutPoint]*models.ChannelEdgePolicy),
chanPols2: make(map[wire.OutPoint]*models.ChannelEdgePolicy), chanPols2: make(map[wire.OutPoint]*models.ChannelEdgePolicy),
sidToCid: make(map[lnwire.ShortChannelID]wire.OutPoint), sidToCid: make(map[lnwire.ShortChannelID]wire.OutPoint),
updates: make(chan *lnwire.ChannelUpdate, 2*numChannels), updates: make(chan *lnwire.ChannelUpdate1, 2*numChannels),
} }
for i := 0; i < numChannels; i++ { for i := 0; i < numChannels; i++ {
@ -177,7 +177,7 @@ func (g *mockGraph) FetchChannelEdgesByOutpoint(
return info, pol1, pol2, nil return info, pol1, pol2, nil
} }
func (g *mockGraph) ApplyChannelUpdate(update *lnwire.ChannelUpdate, func (g *mockGraph) ApplyChannelUpdate(update *lnwire.ChannelUpdate1,
op *wire.OutPoint, private bool) error { op *wire.OutPoint, private bool) error {
g.mu.Lock() g.mu.Lock()

View file

@ -15,7 +15,7 @@ import (
func CreateChanAnnouncement(chanProof *models.ChannelAuthProof, func CreateChanAnnouncement(chanProof *models.ChannelAuthProof,
chanInfo *models.ChannelEdgeInfo, chanInfo *models.ChannelEdgeInfo,
e1, e2 *models.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement1, e1, e2 *models.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement1,
*lnwire.ChannelUpdate, *lnwire.ChannelUpdate, error) { *lnwire.ChannelUpdate1, *lnwire.ChannelUpdate1, error) {
// First, using the parameters of the channel, along with the channel // First, using the parameters of the channel, along with the channel
// authentication chanProof, we'll create re-create the original // authentication chanProof, we'll create re-create the original
@ -68,7 +68,7 @@ func CreateChanAnnouncement(chanProof *models.ChannelAuthProof,
// Since it's up to a node's policy as to whether they advertise the // Since it's up to a node's policy as to whether they advertise the
// edge in a direction, we don't create an advertisement if the edge is // edge in a direction, we don't create an advertisement if the edge is
// nil. // nil.
var edge1Ann, edge2Ann *lnwire.ChannelUpdate var edge1Ann, edge2Ann *lnwire.ChannelUpdate1
if e1 != nil { if e1 != nil {
edge1Ann, err = ChannelUpdateFromEdge(chanInfo, e1) edge1Ann, err = ChannelUpdateFromEdge(chanInfo, e1)
if err != nil { if err != nil {

View file

@ -18,12 +18,12 @@ var ErrUnableToExtractChanUpdate = fmt.Errorf("unable to extract ChannelUpdate")
// ChannelUpdateModifier is a closure that makes in-place modifications to an // ChannelUpdateModifier is a closure that makes in-place modifications to an
// lnwire.ChannelUpdate. // lnwire.ChannelUpdate.
type ChannelUpdateModifier func(*lnwire.ChannelUpdate) type ChannelUpdateModifier func(*lnwire.ChannelUpdate1)
// ChanUpdSetDisable is a functional option that sets the disabled channel flag // ChanUpdSetDisable is a functional option that sets the disabled channel flag
// if disabled is true, and clears the bit otherwise. // if disabled is true, and clears the bit otherwise.
func ChanUpdSetDisable(disabled bool) ChannelUpdateModifier { func ChanUpdSetDisable(disabled bool) ChannelUpdateModifier {
return func(update *lnwire.ChannelUpdate) { return func(update *lnwire.ChannelUpdate1) {
if disabled { if disabled {
// Set the bit responsible for marking a channel as // Set the bit responsible for marking a channel as
// disabled. // disabled.
@ -39,7 +39,7 @@ func ChanUpdSetDisable(disabled bool) ChannelUpdateModifier {
// ChanUpdSetTimestamp is a functional option that sets the timestamp of the // ChanUpdSetTimestamp is a functional option that sets the timestamp of the
// update to the current time, or increments it if the timestamp is already in // update to the current time, or increments it if the timestamp is already in
// the future. // the future.
func ChanUpdSetTimestamp(update *lnwire.ChannelUpdate) { func ChanUpdSetTimestamp(update *lnwire.ChannelUpdate1) {
newTimestamp := uint32(time.Now().Unix()) newTimestamp := uint32(time.Now().Unix())
if newTimestamp <= update.Timestamp { if newTimestamp <= update.Timestamp {
// Increment the prior value to ensure the timestamp // Increment the prior value to ensure the timestamp
@ -57,7 +57,7 @@ func ChanUpdSetTimestamp(update *lnwire.ChannelUpdate) {
// //
// NOTE: This method modifies the given update. // NOTE: This method modifies the given update.
func SignChannelUpdate(signer lnwallet.MessageSigner, keyLoc keychain.KeyLocator, func SignChannelUpdate(signer lnwallet.MessageSigner, keyLoc keychain.KeyLocator,
update *lnwire.ChannelUpdate, mods ...ChannelUpdateModifier) error { update *lnwire.ChannelUpdate1, mods ...ChannelUpdateModifier) error {
// Apply the requested changes to the channel update. // Apply the requested changes to the channel update.
for _, modifier := range mods { for _, modifier := range mods {
@ -86,7 +86,7 @@ func SignChannelUpdate(signer lnwallet.MessageSigner, keyLoc keychain.KeyLocator
func ExtractChannelUpdate(ownerPubKey []byte, func ExtractChannelUpdate(ownerPubKey []byte,
info *models.ChannelEdgeInfo, info *models.ChannelEdgeInfo,
policies ...*models.ChannelEdgePolicy) ( policies ...*models.ChannelEdgePolicy) (
*lnwire.ChannelUpdate, error) { *lnwire.ChannelUpdate1, error) {
// Helper function to extract the owner of the given policy. // Helper function to extract the owner of the given policy.
owner := func(edge *models.ChannelEdgePolicy) []byte { owner := func(edge *models.ChannelEdgePolicy) []byte {
@ -118,9 +118,9 @@ func ExtractChannelUpdate(ownerPubKey []byte,
// UnsignedChannelUpdateFromEdge reconstructs an unsigned ChannelUpdate from the // UnsignedChannelUpdateFromEdge reconstructs an unsigned ChannelUpdate from the
// given edge info and policy. // given edge info and policy.
func UnsignedChannelUpdateFromEdge(info *models.ChannelEdgeInfo, func UnsignedChannelUpdateFromEdge(info *models.ChannelEdgeInfo,
policy *models.ChannelEdgePolicy) *lnwire.ChannelUpdate { policy *models.ChannelEdgePolicy) *lnwire.ChannelUpdate1 {
return &lnwire.ChannelUpdate{ return &lnwire.ChannelUpdate1{
ChainHash: info.ChainHash, ChainHash: info.ChainHash,
ShortChannelID: lnwire.NewShortChanIDFromInt(policy.ChannelID), ShortChannelID: lnwire.NewShortChanIDFromInt(policy.ChannelID),
Timestamp: uint32(policy.LastUpdate.Unix()), Timestamp: uint32(policy.LastUpdate.Unix()),
@ -138,7 +138,7 @@ func UnsignedChannelUpdateFromEdge(info *models.ChannelEdgeInfo,
// ChannelUpdateFromEdge reconstructs a signed ChannelUpdate from the given edge // ChannelUpdateFromEdge reconstructs a signed ChannelUpdate from the given edge
// info and policy. // info and policy.
func ChannelUpdateFromEdge(info *models.ChannelEdgeInfo, func ChannelUpdateFromEdge(info *models.ChannelEdgeInfo,
policy *models.ChannelEdgePolicy) (*lnwire.ChannelUpdate, error) { policy *models.ChannelEdgePolicy) (*lnwire.ChannelUpdate1, error) {
update := UnsignedChannelUpdateFromEdge(info, policy) update := UnsignedChannelUpdateFromEdge(info, policy)

View file

@ -111,7 +111,7 @@ func TestUpdateDisableFlag(t *testing.T) {
// Create the initial update, the only fields we are // Create the initial update, the only fields we are
// concerned with in this test are the timestamp and the // concerned with in this test are the timestamp and the
// channel flags. // channel flags.
ogUpdate := &lnwire.ChannelUpdate{ ogUpdate := &lnwire.ChannelUpdate1{
Timestamp: uint32(tc.startTime.Unix()), Timestamp: uint32(tc.startTime.Unix()),
} }
if !tc.startEnabled { if !tc.startEnabled {
@ -122,7 +122,7 @@ func TestUpdateDisableFlag(t *testing.T) {
// the original. UpdateDisableFlag will mutate the // the original. UpdateDisableFlag will mutate the
// passed channel update, so we keep the old one to test // passed channel update, so we keep the old one to test
// against. // against.
newUpdate := &lnwire.ChannelUpdate{ newUpdate := &lnwire.ChannelUpdate1{
Timestamp: ogUpdate.Timestamp, Timestamp: ogUpdate.Timestamp,
ChannelFlags: ogUpdate.ChannelFlags, ChannelFlags: ogUpdate.ChannelFlags,
} }

View file

@ -22,7 +22,7 @@ func SignAnnouncement(signer lnwallet.MessageSigner, keyLoc keychain.KeyLocator,
switch m := msg.(type) { switch m := msg.(type) {
case *lnwire.ChannelAnnouncement1: case *lnwire.ChannelAnnouncement1:
data, err = m.DataToSign() data, err = m.DataToSign()
case *lnwire.ChannelUpdate: case *lnwire.ChannelUpdate1:
data, err = m.DataToSign() data, err = m.DataToSign()
case *lnwire.NodeAnnouncement: case *lnwire.NodeAnnouncement:
data, err = m.DataToSign() data, err = m.DataToSign()

View file

@ -301,7 +301,7 @@ type Config struct {
// FetchLastChanUpdate fetches our latest channel update for a target // FetchLastChanUpdate fetches our latest channel update for a target
// channel. // channel.
FetchLastChanUpdate func(lnwire.ShortChannelID) (*lnwire.ChannelUpdate, FetchLastChanUpdate func(lnwire.ShortChannelID) (*lnwire.ChannelUpdate1,
error) error)
// FundingManager is an implementation of the funding.Controller interface. // FundingManager is an implementation of the funding.Controller interface.
@ -1962,7 +1962,7 @@ out:
nextMsg.MsgType()) nextMsg.MsgType())
} }
case *lnwire.ChannelUpdate, case *lnwire.ChannelUpdate1,
*lnwire.ChannelAnnouncement1, *lnwire.ChannelAnnouncement1,
*lnwire.NodeAnnouncement, *lnwire.NodeAnnouncement,
*lnwire.AnnounceSignatures1, *lnwire.AnnounceSignatures1,
@ -2231,7 +2231,7 @@ func messageSummary(msg lnwire.Message) string {
return fmt.Sprintf("chain_hash=%v, short_chan_id=%v", return fmt.Sprintf("chain_hash=%v, short_chan_id=%v",
msg.ChainHash, msg.ShortChannelID.ToUint64()) msg.ChainHash, msg.ShortChannelID.ToUint64())
case *lnwire.ChannelUpdate: case *lnwire.ChannelUpdate1:
return fmt.Sprintf("chain_hash=%v, short_chan_id=%v, "+ return fmt.Sprintf("chain_hash=%v, short_chan_id=%v, "+
"mflags=%v, cflags=%v, update_time=%v", msg.ChainHash, "mflags=%v, cflags=%v, update_time=%v", msg.ChainHash,
msg.ShortChannelID.ToUint64(), msg.MessageFlags, msg.ShortChannelID.ToUint64(), msg.MessageFlags,

View file

@ -611,7 +611,7 @@ func createTestPeer(t *testing.T) *peerTestCtx {
IsChannelActive: func(lnwire.ChannelID) bool { IsChannelActive: func(lnwire.ChannelID) bool {
return true return true
}, },
ApplyChannelUpdate: func(*lnwire.ChannelUpdate, ApplyChannelUpdate: func(*lnwire.ChannelUpdate1,
*wire.OutPoint, bool) error { *wire.OutPoint, bool) error {
return nil return nil
@ -719,9 +719,9 @@ func createTestPeer(t *testing.T) *peerTestCtx {
}, },
PongBuf: make([]byte, lnwire.MaxPongBytes), PongBuf: make([]byte, lnwire.MaxPongBytes),
FetchLastChanUpdate: func(chanID lnwire.ShortChannelID, FetchLastChanUpdate: func(chanID lnwire.ShortChannelID,
) (*lnwire.ChannelUpdate, error) { ) (*lnwire.ChannelUpdate1, error) {
return &lnwire.ChannelUpdate{}, nil return &lnwire.ChannelUpdate1{}, nil
}, },
} }

View file

@ -197,7 +197,7 @@ func TestMissionControl(t *testing.T) {
// A node level failure should bring probability of all known channels // A node level failure should bring probability of all known channels
// back to zero. // back to zero.
ctx.reportFailure(0, lnwire.NewExpiryTooSoon(lnwire.ChannelUpdate{})) ctx.reportFailure(0, lnwire.NewExpiryTooSoon(lnwire.ChannelUpdate1{}))
ctx.expectP(1000, 0) ctx.expectP(1000, 0)
// Check whether history snapshot looks sane. // Check whether history snapshot looks sane.
@ -219,14 +219,14 @@ func TestMissionControlChannelUpdate(t *testing.T) {
// Report a policy related failure. Because it is the first, we don't // Report a policy related failure. Because it is the first, we don't
// expect a penalty. // expect a penalty.
ctx.reportFailure( ctx.reportFailure(
0, lnwire.NewFeeInsufficient(0, lnwire.ChannelUpdate{}), 0, lnwire.NewFeeInsufficient(0, lnwire.ChannelUpdate1{}),
) )
ctx.expectP(100, testAprioriHopProbability) ctx.expectP(100, testAprioriHopProbability)
// Report another failure for the same channel. We expect it to be // Report another failure for the same channel. We expect it to be
// pruned. // pruned.
ctx.reportFailure( ctx.reportFailure(
0, lnwire.NewFeeInsufficient(0, lnwire.ChannelUpdate{}), 0, lnwire.NewFeeInsufficient(0, lnwire.ChannelUpdate1{}),
) )
ctx.expectP(100, 0) ctx.expectP(100, 0)
} }

View file

@ -182,7 +182,7 @@ func (m *mockPaymentSessionOld) RequestRoute(_, _ lnwire.MilliSatoshi,
return r, nil return r, nil
} }
func (m *mockPaymentSessionOld) UpdateAdditionalEdge(_ *lnwire.ChannelUpdate, func (m *mockPaymentSessionOld) UpdateAdditionalEdge(_ *lnwire.ChannelUpdate1,
_ *btcec.PublicKey, _ *models.CachedEdgePolicy) bool { _ *btcec.PublicKey, _ *models.CachedEdgePolicy) bool {
return false return false
@ -702,7 +702,7 @@ func (m *mockPaymentSession) RequestRoute(maxAmt, feeLimit lnwire.MilliSatoshi,
return args.Get(0).(*route.Route), args.Error(1) return args.Get(0).(*route.Route), args.Error(1)
} }
func (m *mockPaymentSession) UpdateAdditionalEdge(msg *lnwire.ChannelUpdate, func (m *mockPaymentSession) UpdateAdditionalEdge(msg *lnwire.ChannelUpdate1,
pubKey *btcec.PublicKey, policy *models.CachedEdgePolicy) bool { pubKey *btcec.PublicKey, policy *models.CachedEdgePolicy) bool {
args := m.Called(msg, pubKey, policy) args := m.Called(msg, pubKey, policy)

View file

@ -145,8 +145,8 @@ type PaymentSession interface {
// (private channels) and applies the update from the message. Returns // (private channels) and applies the update from the message. Returns
// a boolean to indicate whether the update has been applied without // a boolean to indicate whether the update has been applied without
// error. // error.
UpdateAdditionalEdge(msg *lnwire.ChannelUpdate, pubKey *btcec.PublicKey, UpdateAdditionalEdge(msg *lnwire.ChannelUpdate1,
policy *models.CachedEdgePolicy) bool pubKey *btcec.PublicKey, policy *models.CachedEdgePolicy) bool
// GetAdditionalEdgePolicy uses the public key and channel ID to query // GetAdditionalEdgePolicy uses the public key and channel ID to query
// the ephemeral channel edge policy for additional edges. Returns a nil // the ephemeral channel edge policy for additional edges. Returns a nil
@ -432,7 +432,7 @@ func (p *paymentSession) RequestRoute(maxAmt, feeLimit lnwire.MilliSatoshi,
// validates the message signature and checks it's up to date, then applies the // validates the message signature and checks it's up to date, then applies the
// updates to the supplied policy. It returns a boolean to indicate whether // updates to the supplied policy. It returns a boolean to indicate whether
// there's an error when applying the updates. // there's an error when applying the updates.
func (p *paymentSession) UpdateAdditionalEdge(msg *lnwire.ChannelUpdate, func (p *paymentSession) UpdateAdditionalEdge(msg *lnwire.ChannelUpdate1,
pubKey *btcec.PublicKey, policy *models.CachedEdgePolicy) bool { pubKey *btcec.PublicKey, policy *models.CachedEdgePolicy) bool {
// Validate the message signature. // Validate the message signature.

View file

@ -147,7 +147,7 @@ func TestUpdateAdditionalEdge(t *testing.T) {
) )
// Create the channel update message and sign. // Create the channel update message and sign.
msg := &lnwire.ChannelUpdate{ msg := &lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(testChannelID), ShortChannelID: lnwire.NewShortChanIDFromInt(testChannelID),
Timestamp: uint32(time.Now().Unix()), Timestamp: uint32(time.Now().Unix()),
BaseFee: newFeeBaseMSat, BaseFee: newFeeBaseMSat,

View file

@ -164,7 +164,7 @@ var resultTestCases = []resultTestCase{
name: "fail expiry too soon", name: "fail expiry too soon",
route: &routeFourHop, route: &routeFourHop,
failureSrcIdx: 3, failureSrcIdx: 3,
failure: lnwire.NewExpiryTooSoon(lnwire.ChannelUpdate{}), failure: lnwire.NewExpiryTooSoon(lnwire.ChannelUpdate1{}),
expectedResult: &interpretedResult{ expectedResult: &interpretedResult{
pairResults: map[DirectedNodePair]pairResult{ pairResults: map[DirectedNodePair]pairResult{
@ -266,8 +266,9 @@ var resultTestCases = []resultTestCase{
name: "fail fee insufficient intermediate", name: "fail fee insufficient intermediate",
route: &routeFourHop, route: &routeFourHop,
failureSrcIdx: 2, failureSrcIdx: 2,
failure: lnwire.NewFeeInsufficient(0, lnwire.ChannelUpdate{}), failure: lnwire.NewFeeInsufficient(
0, lnwire.ChannelUpdate1{},
),
expectedResult: &interpretedResult{ expectedResult: &interpretedResult{
pairResults: map[DirectedNodePair]pairResult{ pairResults: map[DirectedNodePair]pairResult{
getTestPair(0, 1): { getTestPair(0, 1): {

View file

@ -284,7 +284,7 @@ type Config struct {
// ApplyChannelUpdate can be called to apply a new channel update to the // ApplyChannelUpdate can be called to apply a new channel update to the
// graph that we received from a payment failure. // graph that we received from a payment failure.
ApplyChannelUpdate func(msg *lnwire.ChannelUpdate) bool ApplyChannelUpdate func(msg *lnwire.ChannelUpdate1) bool
// ClosedSCIDs is used by the router to fetch closed channels. // ClosedSCIDs is used by the router to fetch closed channels.
// //
@ -1270,9 +1270,9 @@ func (r *ChannelRouter) sendPayment(ctx context.Context,
// extractChannelUpdate examines the error and extracts the channel update. // extractChannelUpdate examines the error and extracts the channel update.
func (r *ChannelRouter) extractChannelUpdate( func (r *ChannelRouter) extractChannelUpdate(
failure lnwire.FailureMessage) *lnwire.ChannelUpdate { failure lnwire.FailureMessage) *lnwire.ChannelUpdate1 {
var update *lnwire.ChannelUpdate var update *lnwire.ChannelUpdate1
switch onionErr := failure.(type) { switch onionErr := failure.(type) {
case *lnwire.FailExpiryTooSoon: case *lnwire.FailExpiryTooSoon:
update = &onionErr.Update update = &onionErr.Update

View file

@ -220,7 +220,7 @@ func createTestCtxFromFile(t *testing.T,
// Add valid signature to channel update simulated as error received from the // Add valid signature to channel update simulated as error received from the
// network. // network.
func signErrChanUpdate(t *testing.T, key *btcec.PrivateKey, func signErrChanUpdate(t *testing.T, key *btcec.PrivateKey,
errChanUpdate *lnwire.ChannelUpdate) { errChanUpdate *lnwire.ChannelUpdate1) {
chanUpdateMsg, err := errChanUpdate.DataToSign() chanUpdateMsg, err := errChanUpdate.DataToSign()
require.NoError(t, err, "failed to retrieve data to sign") require.NoError(t, err, "failed to retrieve data to sign")
@ -485,7 +485,7 @@ func TestChannelUpdateValidation(t *testing.T) {
// Set up a channel update message with an invalid signature to be // Set up a channel update message with an invalid signature to be
// returned to the sender. // returned to the sender.
var invalidSignature lnwire.Sig var invalidSignature lnwire.Sig
errChanUpdate := lnwire.ChannelUpdate{ errChanUpdate := lnwire.ChannelUpdate1{
Signature: invalidSignature, Signature: invalidSignature,
FeeRate: 500, FeeRate: 500,
ShortChannelID: lnwire.NewShortChanIDFromInt(1), ShortChannelID: lnwire.NewShortChanIDFromInt(1),
@ -590,7 +590,7 @@ func TestSendPaymentErrorRepeatedFeeInsufficient(t *testing.T) {
) )
require.NoError(t, err, "unable to fetch chan id") require.NoError(t, err, "unable to fetch chan id")
errChanUpdate := lnwire.ChannelUpdate{ errChanUpdate := lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt( ShortChannelID: lnwire.NewShortChanIDFromInt(
songokuSophonChanID, songokuSophonChanID,
), ),
@ -709,7 +709,7 @@ func TestSendPaymentErrorFeeInsufficientPrivateEdge(t *testing.T) {
// Prepare an error update for the private channel, with twice the // Prepare an error update for the private channel, with twice the
// original fee. // original fee.
updatedFeeBaseMSat := feeBaseMSat * 2 updatedFeeBaseMSat := feeBaseMSat * 2
errChanUpdate := lnwire.ChannelUpdate{ errChanUpdate := lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(privateChannelID), ShortChannelID: lnwire.NewShortChanIDFromInt(privateChannelID),
Timestamp: uint32(testTime.Add(time.Minute).Unix()), Timestamp: uint32(testTime.Add(time.Minute).Unix()),
BaseFee: updatedFeeBaseMSat, BaseFee: updatedFeeBaseMSat,
@ -835,7 +835,7 @@ func TestSendPaymentPrivateEdgeUpdateFeeExceedsLimit(t *testing.T) {
// Prepare an error update for the private channel. The updated fee // Prepare an error update for the private channel. The updated fee
// will exceeds the feeLimit. // will exceeds the feeLimit.
updatedFeeBaseMSat := feeBaseMSat + uint32(feeLimit) updatedFeeBaseMSat := feeBaseMSat + uint32(feeLimit)
errChanUpdate := lnwire.ChannelUpdate{ errChanUpdate := lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(privateChannelID), ShortChannelID: lnwire.NewShortChanIDFromInt(privateChannelID),
Timestamp: uint32(testTime.Add(time.Minute).Unix()), Timestamp: uint32(testTime.Add(time.Minute).Unix()),
BaseFee: updatedFeeBaseMSat, BaseFee: updatedFeeBaseMSat,
@ -936,7 +936,7 @@ func TestSendPaymentErrorNonFinalTimeLockErrors(t *testing.T) {
_, _, edgeUpdateToFail, err := ctx.graph.FetchChannelEdgesByID(chanID) _, _, edgeUpdateToFail, err := ctx.graph.FetchChannelEdgesByID(chanID)
require.NoError(t, err, "unable to fetch chan id") require.NoError(t, err, "unable to fetch chan id")
errChanUpdate := lnwire.ChannelUpdate{ errChanUpdate := lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(chanID), ShortChannelID: lnwire.NewShortChanIDFromInt(chanID),
Timestamp: uint32(edgeUpdateToFail.LastUpdate.Unix()), Timestamp: uint32(edgeUpdateToFail.LastUpdate.Unix()),
MessageFlags: edgeUpdateToFail.MessageFlags, MessageFlags: edgeUpdateToFail.MessageFlags,
@ -1399,7 +1399,7 @@ func TestSendToRouteStructuredError(t *testing.T) {
testCases := map[int]lnwire.FailureMessage{ testCases := map[int]lnwire.FailureMessage{
finalHopIndex: lnwire.NewFailIncorrectDetails(payAmt, 100), finalHopIndex: lnwire.NewFailIncorrectDetails(payAmt, 100),
1: &lnwire.FailFeeInsufficient{ 1: &lnwire.FailFeeInsufficient{
Update: lnwire.ChannelUpdate{}, Update: lnwire.ChannelUpdate1{},
}, },
} }
@ -2943,7 +2943,7 @@ func (m *mockGraphBuilder) setNextReject(reject bool) {
m.rejectUpdate = reject m.rejectUpdate = reject
} }
func (m *mockGraphBuilder) ApplyChannelUpdate(msg *lnwire.ChannelUpdate) bool { func (m *mockGraphBuilder) ApplyChannelUpdate(msg *lnwire.ChannelUpdate1) bool {
if m.rejectUpdate { if m.rejectUpdate {
return false return false
} }

View file

@ -1741,7 +1741,7 @@ func (s *server) UpdateRoutingConfig(cfg *routing.MissionControlConfig) {
// signAliasUpdate takes a ChannelUpdate and returns the signature. This is // signAliasUpdate takes a ChannelUpdate and returns the signature. This is
// used for option_scid_alias channels where the ChannelUpdate to be sent back // used for option_scid_alias channels where the ChannelUpdate to be sent back
// may differ from what is on disk. // may differ from what is on disk.
func (s *server) signAliasUpdate(u *lnwire.ChannelUpdate) (*ecdsa.Signature, func (s *server) signAliasUpdate(u *lnwire.ChannelUpdate1) (*ecdsa.Signature,
error) { error) {
data, err := u.DataToSign() data, err := u.DataToSign()
@ -4814,10 +4814,10 @@ func (s *server) fetchNodeAdvertisedAddrs(pub *btcec.PublicKey) ([]net.Addr, err
// fetchLastChanUpdate returns a function which is able to retrieve our latest // fetchLastChanUpdate returns a function which is able to retrieve our latest
// channel update for a target channel. // channel update for a target channel.
func (s *server) fetchLastChanUpdate() func(lnwire.ShortChannelID) ( func (s *server) fetchLastChanUpdate() func(lnwire.ShortChannelID) (
*lnwire.ChannelUpdate, error) { *lnwire.ChannelUpdate1, error) {
ourPubKey := s.identityECDH.PubKey().SerializeCompressed() ourPubKey := s.identityECDH.PubKey().SerializeCompressed()
return func(cid lnwire.ShortChannelID) (*lnwire.ChannelUpdate, error) { return func(cid lnwire.ShortChannelID) (*lnwire.ChannelUpdate1, error) {
info, edge1, edge2, err := s.graphBuilder.GetChannelByID(cid) info, edge1, edge2, err := s.graphBuilder.GetChannelByID(cid)
if err != nil { if err != nil {
return nil, err return nil, err
@ -4832,7 +4832,7 @@ func (s *server) fetchLastChanUpdate() func(lnwire.ShortChannelID) (
// applyChannelUpdate applies the channel update to the different sub-systems of // applyChannelUpdate applies the channel update to the different sub-systems of
// the server. The useAlias boolean denotes whether or not to send an alias in // the server. The useAlias boolean denotes whether or not to send an alias in
// place of the real SCID. // place of the real SCID.
func (s *server) applyChannelUpdate(update *lnwire.ChannelUpdate, func (s *server) applyChannelUpdate(update *lnwire.ChannelUpdate1,
op *wire.OutPoint, useAlias bool) error { op *wire.OutPoint, useAlias bool) error {
var ( var (