mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 14:22:37 +01:00
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:
parent
bb44efa21f
commit
60f331edb1
43 changed files with 198 additions and 172 deletions
|
@ -61,7 +61,8 @@ type ChannelGraphTimeSeries interface {
|
|||
// specified short channel ID. If no channel updates are known for the
|
||||
// channel, then an empty slice will be returned.
|
||||
FetchChanUpdates(chain chainhash.Hash,
|
||||
shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate, error)
|
||||
shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate1,
|
||||
error)
|
||||
}
|
||||
|
||||
// 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.
|
||||
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(
|
||||
shortChanID.ToUint64(),
|
||||
|
@ -335,7 +336,7 @@ func (c *ChanSeries) FetchChanUpdates(chain chainhash.Hash,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
chanUpdates := make([]*lnwire.ChannelUpdate, 0, 2)
|
||||
chanUpdates := make([]*lnwire.ChannelUpdate1, 0, 2)
|
||||
if e1 != nil {
|
||||
chanUpdate, err := netann.ChannelUpdateFromEdge(chanInfo, e1)
|
||||
if err != nil {
|
||||
|
|
|
@ -322,7 +322,7 @@ type Config struct {
|
|||
|
||||
// SignAliasUpdate is used to re-sign a channel update using the
|
||||
// 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)
|
||||
|
||||
// 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,
|
||||
// channelflags) tuple.
|
||||
case *lnwire.ChannelUpdate:
|
||||
case *lnwire.ChannelUpdate1:
|
||||
sender := route.NewVertex(message.source)
|
||||
deDupKey := channelUpdateID{
|
||||
msg.ShortChannelID,
|
||||
|
@ -1047,7 +1047,15 @@ func (d *deDupedAnnouncements) addMsg(message networkMsg) {
|
|||
if ok {
|
||||
// If we already have seen this message, record its
|
||||
// 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
|
||||
|
@ -1582,7 +1590,7 @@ func (d *AuthenticatedGossiper) isRecentlyRejectedMsg(msg lnwire.Message,
|
|||
|
||||
var scid uint64
|
||||
switch m := msg.(type) {
|
||||
case *lnwire.ChannelUpdate:
|
||||
case *lnwire.ChannelUpdate1:
|
||||
scid = m.ShortChannelID.ToUint64()
|
||||
|
||||
case *lnwire.ChannelAnnouncement1:
|
||||
|
@ -2035,7 +2043,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
|
|||
// A new authenticated channel edge update has arrived. This indicates
|
||||
// that the directional information for an already known channel has
|
||||
// been updated.
|
||||
case *lnwire.ChannelUpdate:
|
||||
case *lnwire.ChannelUpdate1:
|
||||
return d.handleChanUpdate(nMsg, msg, schedulerOp)
|
||||
|
||||
// A new signature announcement has been received. This indicates
|
||||
|
@ -2058,7 +2066,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
|
|||
// should be inspected.
|
||||
func (d *AuthenticatedGossiper) processZombieUpdate(
|
||||
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
|
||||
// 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.
|
||||
return chanInfo.AuthProof != nil
|
||||
|
||||
case *lnwire.ChannelUpdate:
|
||||
case *lnwire.ChannelUpdate1:
|
||||
_, p1, p2, err := d.cfg.Graph.GetChannelByID(msg.ShortChannelID)
|
||||
|
||||
// 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.
|
||||
func (d *AuthenticatedGossiper) updateChannel(info *models.ChannelEdgeInfo,
|
||||
edge *models.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement1,
|
||||
*lnwire.ChannelUpdate, error) {
|
||||
*lnwire.ChannelUpdate1, error) {
|
||||
|
||||
// Parse the unsigned edge into a channel update.
|
||||
chanUpdate := netann.UnsignedChannelUpdateFromEdge(info, edge)
|
||||
|
@ -2284,7 +2292,7 @@ func (d *AuthenticatedGossiper) SyncManager() *SyncManager {
|
|||
// IsKeepAliveUpdate determines whether this channel update is considered a
|
||||
// keep-alive update based on the previous channel update processed for the same
|
||||
// direction.
|
||||
func IsKeepAliveUpdate(update *lnwire.ChannelUpdate,
|
||||
func IsKeepAliveUpdate(update *lnwire.ChannelUpdate1,
|
||||
prev *models.ChannelEdgePolicy) bool {
|
||||
|
||||
// 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
|
||||
// error to the original caller in case the gossiper
|
||||
// shuts down.
|
||||
case *lnwire.ChannelUpdate:
|
||||
case *lnwire.ChannelUpdate1:
|
||||
log.Debugf("Reprocessing ChannelUpdate for "+
|
||||
"shortChanID=%v", scid.ToUint64())
|
||||
|
||||
|
@ -2796,7 +2804,7 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
|
|||
|
||||
// handleChanUpdate processes a new channel update.
|
||||
func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
|
||||
upd *lnwire.ChannelUpdate,
|
||||
upd *lnwire.ChannelUpdate1,
|
||||
ops []batch.SchedulerOption) ([]networkMsg, bool) {
|
||||
|
||||
log.Debugf("Processing ChannelUpdate: peer=%v, short_chan_id=%v, ",
|
||||
|
|
|
@ -478,8 +478,8 @@ type annBatch struct {
|
|||
|
||||
chanAnn *lnwire.ChannelAnnouncement1
|
||||
|
||||
chanUpdAnn1 *lnwire.ChannelUpdate
|
||||
chanUpdAnn2 *lnwire.ChannelUpdate
|
||||
chanUpdAnn1 *lnwire.ChannelUpdate1
|
||||
chanUpdAnn2 *lnwire.ChannelUpdate1
|
||||
|
||||
localProofAnn *lnwire.AnnounceSignatures1
|
||||
remoteProofAnn *lnwire.AnnounceSignatures1
|
||||
|
@ -585,12 +585,12 @@ func createNodeAnnouncement(priv *btcec.PrivateKey,
|
|||
func createUpdateAnnouncement(blockHeight uint32,
|
||||
flags lnwire.ChanUpdateChanFlags,
|
||||
nodeKey *btcec.PrivateKey, timestamp uint32,
|
||||
extraBytes ...[]byte) (*lnwire.ChannelUpdate, error) {
|
||||
extraBytes ...[]byte) (*lnwire.ChannelUpdate1, error) {
|
||||
|
||||
var err error
|
||||
|
||||
htlcMinMsat := lnwire.MilliSatoshi(prand.Int63())
|
||||
a := &lnwire.ChannelUpdate{
|
||||
a := &lnwire.ChannelUpdate1{
|
||||
ShortChannelID: lnwire.ShortChannelID{
|
||||
BlockHeight: blockHeight,
|
||||
},
|
||||
|
@ -618,7 +618,7 @@ func createUpdateAnnouncement(blockHeight uint32,
|
|||
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}
|
||||
sig, err := netann.SignAnnouncement(&signer, testKeyLoc, a)
|
||||
if err != nil {
|
||||
|
@ -749,7 +749,7 @@ func createTestCtx(t *testing.T, startHeight uint32, isChanPeer bool) (
|
|||
return false
|
||||
}
|
||||
|
||||
signAliasUpdate := func(*lnwire.ChannelUpdate) (*ecdsa.Signature,
|
||||
signAliasUpdate := func(*lnwire.ChannelUpdate1) (*ecdsa.Signature,
|
||||
error) {
|
||||
|
||||
return nil, nil
|
||||
|
@ -1462,7 +1462,7 @@ func TestSignatureAnnouncementRetryAtStartup(t *testing.T) {
|
|||
return false
|
||||
}
|
||||
|
||||
signAliasUpdate := func(*lnwire.ChannelUpdate) (*ecdsa.Signature,
|
||||
signAliasUpdate := func(*lnwire.ChannelUpdate1) (*ecdsa.Signature,
|
||||
error) {
|
||||
|
||||
return nil, nil
|
||||
|
@ -1868,7 +1868,7 @@ func TestDeDuplicatedAnnouncements(t *testing.T) {
|
|||
t.Fatal("channel update not replaced in batch")
|
||||
}
|
||||
|
||||
assertChannelUpdate := func(channelUpdate *lnwire.ChannelUpdate) {
|
||||
assertChannelUpdate := func(channelUpdate *lnwire.ChannelUpdate1) {
|
||||
channelKey := channelUpdateID{
|
||||
ua3.ShortChannelID,
|
||||
ua3.ChannelFlags,
|
||||
|
@ -2814,7 +2814,7 @@ func TestRetransmit(t *testing.T) {
|
|||
switch msg.(type) {
|
||||
case *lnwire.ChannelAnnouncement1:
|
||||
chanAnn++
|
||||
case *lnwire.ChannelUpdate:
|
||||
case *lnwire.ChannelUpdate1:
|
||||
chanUpd++
|
||||
case *lnwire.NodeAnnouncement:
|
||||
nodeAnn++
|
||||
|
@ -3247,7 +3247,7 @@ func TestSendChannelUpdateReliably(t *testing.T) {
|
|||
// already been announced. We'll keep track of the old message that is
|
||||
// now stale to use later on.
|
||||
staleChannelUpdate := batch.chanUpdAnn1
|
||||
newChannelUpdate := &lnwire.ChannelUpdate{}
|
||||
newChannelUpdate := &lnwire.ChannelUpdate1{}
|
||||
*newChannelUpdate = *staleChannelUpdate
|
||||
newChannelUpdate.Timestamp++
|
||||
if err := signUpdate(selfKeyPriv, newChannelUpdate); err != nil {
|
||||
|
@ -3301,7 +3301,7 @@ func TestSendChannelUpdateReliably(t *testing.T) {
|
|||
}
|
||||
|
||||
switch msg := msg.(type) {
|
||||
case *lnwire.ChannelUpdate:
|
||||
case *lnwire.ChannelUpdate1:
|
||||
assertMessage(t, staleChannelUpdate, msg)
|
||||
case *lnwire.AnnounceSignatures1:
|
||||
assertMessage(t, batch.localProofAnn, msg)
|
||||
|
@ -3505,7 +3505,7 @@ out:
|
|||
// being the channel our first private channel.
|
||||
for i := 0; i < numChannels-1; i++ {
|
||||
assertBroadcastMsg(t, ctx, func(msg lnwire.Message) error {
|
||||
upd, ok := msg.(*lnwire.ChannelUpdate)
|
||||
upd, ok := msg.(*lnwire.ChannelUpdate1)
|
||||
if !ok {
|
||||
return fmt.Errorf("channel update not "+
|
||||
"broadcast, instead %T was", msg)
|
||||
|
@ -3529,7 +3529,7 @@ out:
|
|||
// remote peer via the reliable sender.
|
||||
select {
|
||||
case msg := <-sentMsgs:
|
||||
upd, ok := msg.(*lnwire.ChannelUpdate)
|
||||
upd, ok := msg.(*lnwire.ChannelUpdate1)
|
||||
if !ok {
|
||||
t.Fatalf("channel update not "+
|
||||
"broadcast, instead %T was", msg)
|
||||
|
@ -3553,7 +3553,7 @@ out:
|
|||
for {
|
||||
select {
|
||||
case msg := <-ctx.broadcastedMessage:
|
||||
if upd, ok := msg.msg.(*lnwire.ChannelUpdate); ok {
|
||||
if upd, ok := msg.msg.(*lnwire.ChannelUpdate1); ok {
|
||||
if upd.ShortChannelID == firstChanID {
|
||||
t.Fatalf("chan update msg received: %v",
|
||||
spew.Sdump(msg))
|
||||
|
@ -3885,7 +3885,7 @@ func TestRateLimitChannelUpdates(t *testing.T) {
|
|||
|
||||
// We'll define a helper to assert whether updates should be rate
|
||||
// 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) {
|
||||
|
||||
t.Helper()
|
||||
|
|
|
@ -85,7 +85,7 @@ func msgShortChanID(msg lnwire.Message) (lnwire.ShortChannelID, error) {
|
|||
switch msg := msg.(type) {
|
||||
case *lnwire.AnnounceSignatures1:
|
||||
shortChanID = msg.ShortChannelID
|
||||
case *lnwire.ChannelUpdate:
|
||||
case *lnwire.ChannelUpdate1:
|
||||
shortChanID = msg.ShortChannelID
|
||||
default:
|
||||
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
|
||||
// from the store, we'll make sure that we're actually deleting
|
||||
// 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
|
||||
// acts as a NOP, so we'll return if a message doesn't
|
||||
// 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
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,8 +59,8 @@ func randAnnounceSignatures() *lnwire.AnnounceSignatures1 {
|
|||
}
|
||||
}
|
||||
|
||||
func randChannelUpdate() *lnwire.ChannelUpdate {
|
||||
return &lnwire.ChannelUpdate{
|
||||
func randChannelUpdate() *lnwire.ChannelUpdate1 {
|
||||
return &lnwire.ChannelUpdate1{
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(rand.Uint64()),
|
||||
ExtraOpaqueData: make([]byte, 0),
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ func TestMessageStoreMessages(t *testing.T) {
|
|||
switch msg := msg.(type) {
|
||||
case *lnwire.AnnounceSignatures1:
|
||||
shortChanID = msg.ShortChannelID.ToUint64()
|
||||
case *lnwire.ChannelUpdate:
|
||||
case *lnwire.ChannelUpdate1:
|
||||
shortChanID = msg.ShortChannelID.ToUint64()
|
||||
default:
|
||||
t.Fatalf("found unexpected message type %T", msg)
|
||||
|
|
|
@ -1406,9 +1406,11 @@ func (g *GossipSyncer) FilterGossipMsgs(msgs ...msgWithSenders) {
|
|||
// 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
|
||||
// channel updates for a channel.
|
||||
chanUpdateIndex := make(map[lnwire.ShortChannelID][]*lnwire.ChannelUpdate)
|
||||
chanUpdateIndex := make(
|
||||
map[lnwire.ShortChannelID][]*lnwire.ChannelUpdate1,
|
||||
)
|
||||
for _, msg := range msgs {
|
||||
chanUpdate, ok := msg.msg.(*lnwire.ChannelUpdate)
|
||||
chanUpdate, ok := msg.msg.(*lnwire.ChannelUpdate1)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
@ -1478,7 +1480,7 @@ func (g *GossipSyncer) FilterGossipMsgs(msgs ...msgWithSenders) {
|
|||
|
||||
// For each channel update, we'll only send if it the timestamp
|
||||
// is between our time range.
|
||||
case *lnwire.ChannelUpdate:
|
||||
case *lnwire.ChannelUpdate1:
|
||||
if passesFilter(msg.Timestamp) {
|
||||
msgsToSend = append(msgsToSend, msg)
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ type mockChannelGraphTimeSeries struct {
|
|||
annResp chan []lnwire.Message
|
||||
|
||||
updateReq chan lnwire.ShortChannelID
|
||||
updateResp chan []*lnwire.ChannelUpdate
|
||||
updateResp chan []*lnwire.ChannelUpdate1
|
||||
}
|
||||
|
||||
func newMockChannelGraphTimeSeries(
|
||||
|
@ -74,7 +74,7 @@ func newMockChannelGraphTimeSeries(
|
|||
annResp: make(chan []lnwire.Message, 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
|
||||
}
|
||||
func (m *mockChannelGraphTimeSeries) FetchChanUpdates(chain chainhash.Hash,
|
||||
shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate, error) {
|
||||
shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate1, error) {
|
||||
|
||||
m.updateReq <- shortChanID
|
||||
|
||||
|
@ -311,7 +311,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
msg: &lnwire.ChannelUpdate{
|
||||
msg: &lnwire.ChannelUpdate1{
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(10),
|
||||
Timestamp: unixStamp(5),
|
||||
},
|
||||
|
@ -323,7 +323,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
msg: &lnwire.ChannelUpdate{
|
||||
msg: &lnwire.ChannelUpdate1{
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(15),
|
||||
Timestamp: unixStamp(25002),
|
||||
},
|
||||
|
@ -335,7 +335,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
msg: &lnwire.ChannelUpdate{
|
||||
msg: &lnwire.ChannelUpdate1{
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(20),
|
||||
Timestamp: unixStamp(999999),
|
||||
},
|
||||
|
@ -369,7 +369,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
|
|||
}
|
||||
|
||||
// If so, then we'll send back the missing update.
|
||||
chanSeries.updateResp <- []*lnwire.ChannelUpdate{
|
||||
chanSeries.updateResp <- []*lnwire.ChannelUpdate1{
|
||||
{
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(25),
|
||||
Timestamp: unixStamp(5),
|
||||
|
@ -551,7 +551,7 @@ func TestGossipSyncerApplyGossipFilter(t *testing.T) {
|
|||
// For this first response, we'll send back a proper
|
||||
// set of messages that should be echoed back.
|
||||
chanSeries.horizonResp <- []lnwire.Message{
|
||||
&lnwire.ChannelUpdate{
|
||||
&lnwire.ChannelUpdate1{
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(25),
|
||||
Timestamp: unixStamp(5),
|
||||
},
|
||||
|
@ -709,7 +709,7 @@ func TestGossipSyncerReplyShortChanIDs(t *testing.T) {
|
|||
&lnwire.ChannelAnnouncement1{
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(20),
|
||||
},
|
||||
&lnwire.ChannelUpdate{
|
||||
&lnwire.ChannelUpdate1{
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(20),
|
||||
Timestamp: unixStamp(999999),
|
||||
},
|
||||
|
|
|
@ -4144,7 +4144,7 @@ func (f *Manager) ensureInitialForwardingPolicy(chanID lnwire.ChannelID,
|
|||
// send out to the network after a new channel has been created locally.
|
||||
type chanAnnouncement struct {
|
||||
chanAnn *lnwire.ChannelAnnouncement1
|
||||
chanUpdateAnn *lnwire.ChannelUpdate
|
||||
chanUpdateAnn *lnwire.ChannelUpdate1
|
||||
chanProof *lnwire.AnnounceSignatures1
|
||||
}
|
||||
|
||||
|
@ -4238,7 +4238,7 @@ func (f *Manager) newChanAnnouncement(localPubKey,
|
|||
|
||||
// We announce the channel with the default values. Some of
|
||||
// these values can later be changed by crafting a new ChannelUpdate.
|
||||
chanUpdateAnn := &lnwire.ChannelUpdate{
|
||||
chanUpdateAnn := &lnwire.ChannelUpdate1{
|
||||
ShortChannelID: shortChanID,
|
||||
ChainHash: chainHash,
|
||||
Timestamp: uint32(time.Now().Unix()),
|
||||
|
|
|
@ -1210,7 +1210,7 @@ func assertChannelAnnouncements(t *testing.T, alice, bob *testNode,
|
|||
switch m := msg.(type) {
|
||||
case *lnwire.ChannelAnnouncement1:
|
||||
gotChannelAnnouncement = true
|
||||
case *lnwire.ChannelUpdate:
|
||||
case *lnwire.ChannelUpdate1:
|
||||
|
||||
// The channel update sent by the node should
|
||||
// advertise the MinHTLC value required by the
|
||||
|
|
|
@ -127,7 +127,7 @@ func ValidateNodeAnn(a *lnwire.NodeAnnouncement) error {
|
|||
// signed by the node's private key, and (2) that the announcement's message
|
||||
// flags and optional fields are sane.
|
||||
func ValidateChannelUpdateAnn(pubKey *btcec.PublicKey, capacity btcutil.Amount,
|
||||
a *lnwire.ChannelUpdate) error {
|
||||
a *lnwire.ChannelUpdate1) error {
|
||||
|
||||
if err := ValidateChannelUpdateFields(capacity, a); err != nil {
|
||||
return err
|
||||
|
@ -138,7 +138,7 @@ func ValidateChannelUpdateAnn(pubKey *btcec.PublicKey, capacity btcutil.Amount,
|
|||
|
||||
// VerifyChannelUpdateSignature verifies that the channel update message was
|
||||
// signed by the party with the given node public key.
|
||||
func VerifyChannelUpdateSignature(msg *lnwire.ChannelUpdate,
|
||||
func VerifyChannelUpdateSignature(msg *lnwire.ChannelUpdate1,
|
||||
pubKey *btcec.PublicKey) error {
|
||||
|
||||
data, err := msg.DataToSign()
|
||||
|
@ -163,7 +163,7 @@ func VerifyChannelUpdateSignature(msg *lnwire.ChannelUpdate,
|
|||
// ValidateChannelUpdateFields validates a channel update's message flags and
|
||||
// corresponding update fields.
|
||||
func ValidateChannelUpdateFields(capacity btcutil.Amount,
|
||||
msg *lnwire.ChannelUpdate) error {
|
||||
msg *lnwire.ChannelUpdate1) error {
|
||||
|
||||
// The maxHTLC flag is mandatory.
|
||||
if !msg.MessageFlags.HasMaxHtlc() {
|
||||
|
|
|
@ -1521,7 +1521,7 @@ type routingMsg struct {
|
|||
|
||||
// ApplyChannelUpdate validates a channel update and if valid, applies it to the
|
||||
// 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)
|
||||
if err != nil {
|
||||
log.Errorf("Unable to retrieve channel by id: %v", err)
|
||||
|
|
|
@ -146,7 +146,7 @@ func (v *ValidationBarrier) InitJobDependencies(job interface{}) {
|
|||
// initialization needs to be done beyond just occupying a job slot.
|
||||
case *models.ChannelEdgePolicy:
|
||||
return
|
||||
case *lnwire.ChannelUpdate:
|
||||
case *lnwire.ChannelUpdate1:
|
||||
return
|
||||
case *lnwire.NodeAnnouncement:
|
||||
// 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",
|
||||
vertex)
|
||||
|
||||
case *lnwire.ChannelUpdate:
|
||||
case *lnwire.ChannelUpdate1:
|
||||
signals, ok = v.chanEdgeDependencies[msg.ShortChannelID]
|
||||
|
||||
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))
|
||||
case *lnwire.NodeAnnouncement:
|
||||
delete(v.nodeAnnDependencies, route.Vertex(msg.NodeID))
|
||||
case *lnwire.ChannelUpdate:
|
||||
case *lnwire.ChannelUpdate1:
|
||||
delete(v.chanEdgeDependencies, msg.ShortChannelID)
|
||||
case *models.ChannelEdgePolicy:
|
||||
shortID := lnwire.NewShortChanIDFromInt(msg.ChannelID)
|
||||
|
|
|
@ -85,9 +85,9 @@ func TestValidationBarrierQuit(t *testing.T) {
|
|||
|
||||
// Create a set of channel updates, that must wait until their
|
||||
// associated channel announcement has been verified.
|
||||
chanUpds := make([]*lnwire.ChannelUpdate, 0, numTasks)
|
||||
chanUpds := make([]*lnwire.ChannelUpdate1, 0, numTasks)
|
||||
for i := 0; i < numTasks; i++ {
|
||||
chanUpds = append(chanUpds, &lnwire.ChannelUpdate{
|
||||
chanUpds = append(chanUpds, &lnwire.ChannelUpdate1{
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(uint64(i)),
|
||||
})
|
||||
barrier.InitJobDependencies(chanUpds[i])
|
||||
|
|
|
@ -86,7 +86,7 @@ type scidAliasHandler interface {
|
|||
// HTLCs on option_scid_alias channels.
|
||||
attachFailAliasUpdate(failClosure func(
|
||||
sid lnwire.ShortChannelID,
|
||||
incoming bool) *lnwire.ChannelUpdate)
|
||||
incoming bool) *lnwire.ChannelUpdate1)
|
||||
|
||||
// getAliases fetches the link's underlying aliases. This is used by
|
||||
// the Switch to determine whether to forward an HTLC and where to
|
||||
|
|
|
@ -120,7 +120,8 @@ type ChannelLinkConfig struct {
|
|||
// specified when we receive an incoming HTLC. This will be used to
|
||||
// provide payment senders our latest policy when sending encrypted
|
||||
// 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
|
||||
// opened.
|
||||
|
@ -262,7 +263,7 @@ type ChannelLinkConfig struct {
|
|||
// FailAliasUpdate is a function used to fail an HTLC for an
|
||||
// option_scid_alias channel.
|
||||
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
|
||||
// aliases for a given link.
|
||||
|
@ -765,7 +766,7 @@ func shouldAdjustCommitFee(netFee, chanFee,
|
|||
}
|
||||
|
||||
// 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
|
||||
// outgoing HTLC. It may return a FailureMessage that references a channel's
|
||||
|
@ -2949,7 +2950,7 @@ func (l *channelLink) getAliases() []lnwire.ShortChannelID {
|
|||
//
|
||||
// Part of the scidAliasHandler interface.
|
||||
func (l *channelLink) attachFailAliasUpdate(closure func(
|
||||
sid lnwire.ShortChannelID, incoming bool) *lnwire.ChannelUpdate) {
|
||||
sid lnwire.ShortChannelID, incoming bool) *lnwire.ChannelUpdate1) {
|
||||
|
||||
l.Lock()
|
||||
l.cfg.FailAliasUpdate = closure
|
||||
|
@ -3041,7 +3042,7 @@ func (l *channelLink) CheckHtlcForward(payHash [32]byte,
|
|||
|
||||
// As part of the returned error, we'll send our latest routing
|
||||
// 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)
|
||||
}
|
||||
failure := l.createFailureWithUpdate(false, originalScid, cb)
|
||||
|
@ -3069,7 +3070,7 @@ func (l *channelLink) CheckHtlcForward(payHash [32]byte,
|
|||
|
||||
// Grab the latest routing policy so the sending node is up to
|
||||
// date with our current policy.
|
||||
cb := func(upd *lnwire.ChannelUpdate) lnwire.FailureMessage {
|
||||
cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
|
||||
return lnwire.NewIncorrectCltvExpiry(
|
||||
incomingTimeout, *upd,
|
||||
)
|
||||
|
@ -3118,7 +3119,7 @@ func (l *channelLink) canSendHtlc(policy models.ForwardingPolicy,
|
|||
|
||||
// As part of the returned error, we'll send our latest routing
|
||||
// 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)
|
||||
}
|
||||
failure := l.createFailureWithUpdate(false, originalScid, cb)
|
||||
|
@ -3133,7 +3134,7 @@ func (l *channelLink) canSendHtlc(policy models.ForwardingPolicy,
|
|||
|
||||
// As part of the returned error, we'll send our latest routing
|
||||
// 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)
|
||||
}
|
||||
failure := l.createFailureWithUpdate(false, originalScid, cb)
|
||||
|
@ -3148,7 +3149,7 @@ func (l *channelLink) canSendHtlc(policy models.ForwardingPolicy,
|
|||
"outgoing_expiry=%v, best_height=%v", payHash[:],
|
||||
timeout, heightNow)
|
||||
|
||||
cb := func(upd *lnwire.ChannelUpdate) lnwire.FailureMessage {
|
||||
cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
|
||||
return lnwire.NewExpiryTooSoon(*upd)
|
||||
}
|
||||
failure := l.createFailureWithUpdate(false, originalScid, cb)
|
||||
|
@ -3168,7 +3169,7 @@ func (l *channelLink) canSendHtlc(policy models.ForwardingPolicy,
|
|||
if amt > l.Bandwidth() {
|
||||
l.log.Warnf("insufficient bandwidth to route htlc: %v is "+
|
||||
"larger than %v", amt, l.Bandwidth())
|
||||
cb := func(upd *lnwire.ChannelUpdate) lnwire.FailureMessage {
|
||||
cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
|
||||
return lnwire.NewTemporaryChannelFailure(upd)
|
||||
}
|
||||
failure := l.createFailureWithUpdate(false, originalScid, cb)
|
||||
|
@ -3680,7 +3681,7 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg) {
|
|||
l.log.Errorf("unable to encode the "+
|
||||
"remaining route %v", err)
|
||||
|
||||
cb := func(upd *lnwire.ChannelUpdate) lnwire.FailureMessage {
|
||||
cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage { //nolint:lll
|
||||
return lnwire.NewTemporaryChannelFailure(upd)
|
||||
}
|
||||
|
||||
|
|
|
@ -6166,13 +6166,13 @@ func TestForwardingAsymmetricTimeLockPolicies(t *testing.T) {
|
|||
// forwarding policy.
|
||||
func TestCheckHtlcForward(t *testing.T) {
|
||||
fetchLastChannelUpdate := func(lnwire.ShortChannelID) (
|
||||
*lnwire.ChannelUpdate, error) {
|
||||
*lnwire.ChannelUpdate1, error) {
|
||||
|
||||
return &lnwire.ChannelUpdate{}, nil
|
||||
return &lnwire.ChannelUpdate1{}, nil
|
||||
}
|
||||
|
||||
failAliasUpdate := func(sid lnwire.ShortChannelID,
|
||||
incoming bool) *lnwire.ChannelUpdate {
|
||||
incoming bool) *lnwire.ChannelUpdate1 {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ type mockServer struct {
|
|||
var _ lnpeer.Peer = (*mockServer)(nil)
|
||||
|
||||
func initSwitchWithDB(startingHeight uint32, db *channeldb.DB) (*Switch, error) {
|
||||
signAliasUpdate := func(u *lnwire.ChannelUpdate) (*ecdsa.Signature,
|
||||
signAliasUpdate := func(u *lnwire.ChannelUpdate1) (*ecdsa.Signature,
|
||||
error) {
|
||||
|
||||
return testSig, nil
|
||||
|
@ -183,9 +183,9 @@ func initSwitchWithDB(startingHeight uint32, db *channeldb.DB) (*Switch, error)
|
|||
events: make(map[time.Time]channeldb.ForwardingEvent),
|
||||
},
|
||||
FetchLastChannelUpdate: func(scid lnwire.ShortChannelID) (
|
||||
*lnwire.ChannelUpdate, error) {
|
||||
*lnwire.ChannelUpdate1, error) {
|
||||
|
||||
return &lnwire.ChannelUpdate{
|
||||
return &lnwire.ChannelUpdate1{
|
||||
ShortChannelID: scid,
|
||||
}, nil
|
||||
},
|
||||
|
@ -735,7 +735,7 @@ type mockChannelLink struct {
|
|||
checkHtlcForwardResult *LinkError
|
||||
|
||||
failAliasUpdate func(sid lnwire.ShortChannelID,
|
||||
incoming bool) *lnwire.ChannelUpdate
|
||||
incoming bool) *lnwire.ChannelUpdate1
|
||||
|
||||
confirmedZC bool
|
||||
}
|
||||
|
@ -870,7 +870,7 @@ func (f *mockChannelLink) AttachMailBox(mailBox MailBox) {
|
|||
}
|
||||
|
||||
func (f *mockChannelLink) attachFailAliasUpdate(closure func(
|
||||
sid lnwire.ShortChannelID, incoming bool) *lnwire.ChannelUpdate) {
|
||||
sid lnwire.ShortChannelID, incoming bool) *lnwire.ChannelUpdate1) {
|
||||
|
||||
f.failAliasUpdate = closure
|
||||
}
|
||||
|
|
|
@ -173,7 +173,8 @@ type Config struct {
|
|||
// specified when we receive an incoming HTLC. This will be used to
|
||||
// provide payment senders our latest policy when sending encrypted
|
||||
// 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
|
||||
// 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
|
||||
// replacing the public, confirmed SCID with the alias in the
|
||||
// ChannelUpdate.
|
||||
SignAliasUpdate func(u *lnwire.ChannelUpdate) (*ecdsa.Signature,
|
||||
SignAliasUpdate func(u *lnwire.ChannelUpdate1) (*ecdsa.Signature,
|
||||
error)
|
||||
|
||||
// IsAlias returns whether or not a given SCID is an alias.
|
||||
|
@ -2640,7 +2641,7 @@ func (s *Switch) failMailboxUpdate(outgoingScid,
|
|||
// and the caller is expected to handle this properly. In this case, a return
|
||||
// to the original non-alias behavior is expected.
|
||||
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
|
||||
// lookups for ChannelUpdate.
|
||||
|
|
|
@ -3951,7 +3951,7 @@ func TestSwitchHoldForward(t *testing.T) {
|
|||
// Simulate an error during the composition of the failure message.
|
||||
currentCallback := c.s.cfg.FetchLastChannelUpdate
|
||||
c.s.cfg.FetchLastChannelUpdate = func(
|
||||
lnwire.ShortChannelID) (*lnwire.ChannelUpdate, error) {
|
||||
lnwire.ShortChannelID) (*lnwire.ChannelUpdate1, error) {
|
||||
|
||||
return nil, errors.New("cannot fetch update")
|
||||
}
|
||||
|
|
|
@ -91,8 +91,10 @@ func genIDs() (lnwire.ChannelID, lnwire.ChannelID, lnwire.ShortChannelID,
|
|||
|
||||
// mockGetChanUpdateMessage helper function which returns topology update of
|
||||
// the channel
|
||||
func mockGetChanUpdateMessage(cid lnwire.ShortChannelID) (*lnwire.ChannelUpdate, error) {
|
||||
return &lnwire.ChannelUpdate{
|
||||
func mockGetChanUpdateMessage(_ lnwire.ShortChannelID) (*lnwire.ChannelUpdate1,
|
||||
error) {
|
||||
|
||||
return &lnwire.ChannelUpdate1{
|
||||
Signature: wireSig,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -1626,7 +1626,7 @@ func marshallWireError(msg lnwire.FailureMessage,
|
|||
|
||||
// marshallChannelUpdate marshalls a channel update as received over the wire to
|
||||
// the router rpc format.
|
||||
func marshallChannelUpdate(update *lnwire.ChannelUpdate) *lnrpc.ChannelUpdate {
|
||||
func marshallChannelUpdate(update *lnwire.ChannelUpdate1) *lnrpc.ChannelUpdate {
|
||||
if update == nil {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -56,11 +56,11 @@ func (c ChanUpdateChanFlags) String() string {
|
|||
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
|
||||
// other parameters. Also this message is used to redeclare initially set
|
||||
// channel parameters.
|
||||
type ChannelUpdate struct {
|
||||
type ChannelUpdate1 struct {
|
||||
// Signature is used to validate the announced data and prove the
|
||||
// ownership of node id.
|
||||
Signature Sig
|
||||
|
@ -122,13 +122,13 @@ type ChannelUpdate struct {
|
|||
|
||||
// A compile time check to ensure ChannelUpdate implements the lnwire.Message
|
||||
// interface.
|
||||
var _ Message = (*ChannelUpdate)(nil)
|
||||
var _ Message = (*ChannelUpdate1)(nil)
|
||||
|
||||
// Decode deserializes a serialized ChannelUpdate stored in the passed
|
||||
// io.Reader observing the specified protocol version.
|
||||
//
|
||||
// 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,
|
||||
&a.Signature,
|
||||
a.ChainHash[:],
|
||||
|
@ -159,7 +159,7 @@ func (a *ChannelUpdate) Decode(r io.Reader, pver uint32) error {
|
|||
// observing the protocol version specified.
|
||||
//
|
||||
// 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 {
|
||||
return err
|
||||
}
|
||||
|
@ -217,13 +217,13 @@ func (a *ChannelUpdate) Encode(w *bytes.Buffer, pver uint32) error {
|
|||
// wire.
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (a *ChannelUpdate) MsgType() MessageType {
|
||||
func (a *ChannelUpdate1) MsgType() MessageType {
|
||||
return MsgChannelUpdate
|
||||
}
|
||||
|
||||
// DataToSign is used to retrieve part of the announcement message which should
|
||||
// be signed.
|
||||
func (a *ChannelUpdate) DataToSign() ([]byte, error) {
|
||||
func (a *ChannelUpdate1) DataToSign() ([]byte, error) {
|
||||
// We should not include the signatures itself.
|
||||
b := make([]byte, 0, MaxMsgBody)
|
||||
buf := bytes.NewBuffer(b)
|
||||
|
|
|
@ -1100,7 +1100,7 @@ func TestLightningWireProtocol(t *testing.T) {
|
|||
maxHtlc = 0
|
||||
}
|
||||
|
||||
req := ChannelUpdate{
|
||||
req := ChannelUpdate1{
|
||||
ShortChannelID: NewShortChanIDFromInt(uint64(r.Int63())),
|
||||
Timestamp: uint32(r.Int31()),
|
||||
MessageFlags: msgFlags,
|
||||
|
@ -1643,7 +1643,7 @@ func TestLightningWireProtocol(t *testing.T) {
|
|||
},
|
||||
{
|
||||
msgType: MsgChannelUpdate,
|
||||
scenario: func(m ChannelUpdate) bool {
|
||||
scenario: func(m ChannelUpdate1) bool {
|
||||
return mainScenario(&m)
|
||||
},
|
||||
},
|
||||
|
|
|
@ -261,7 +261,7 @@ func makeEmptyMessage(msgType MessageType) (Message, error) {
|
|||
case MsgChannelAnnouncement:
|
||||
msg = &ChannelAnnouncement1{}
|
||||
case MsgChannelUpdate:
|
||||
msg = &ChannelUpdate{}
|
||||
msg = &ChannelUpdate1{}
|
||||
case MsgNodeAnnouncement:
|
||||
msg = &NodeAnnouncement{}
|
||||
case MsgPing:
|
||||
|
|
|
@ -692,7 +692,7 @@ func newMsgNodeAnnouncement(t testing.TB,
|
|||
return msg
|
||||
}
|
||||
|
||||
func newMsgChannelUpdate(t testing.TB, r *rand.Rand) *lnwire.ChannelUpdate {
|
||||
func newMsgChannelUpdate(t testing.TB, r *rand.Rand) *lnwire.ChannelUpdate1 {
|
||||
t.Helper()
|
||||
|
||||
msgFlags := lnwire.ChanUpdateMsgFlags(r.Int31())
|
||||
|
@ -706,7 +706,7 @@ func newMsgChannelUpdate(t testing.TB, r *rand.Rand) *lnwire.ChannelUpdate {
|
|||
maxHtlc = 0
|
||||
}
|
||||
|
||||
msg := &lnwire.ChannelUpdate{
|
||||
msg := &lnwire.ChannelUpdate1{
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(r.Uint64()),
|
||||
Timestamp: uint32(r.Int31()),
|
||||
MessageFlags: msgFlags,
|
||||
|
|
|
@ -601,7 +601,7 @@ func (f *FailInvalidOnionKey) Error() string {
|
|||
// 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.
|
||||
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
|
||||
// present after the channel update. Without limiting the stream, the
|
||||
|
@ -648,11 +648,13 @@ type FailTemporaryChannelFailure struct {
|
|||
// which caused the failure.
|
||||
//
|
||||
// NOTE: This field is optional.
|
||||
Update *ChannelUpdate
|
||||
Update *ChannelUpdate1
|
||||
}
|
||||
|
||||
// NewTemporaryChannelFailure creates new instance of the FailTemporaryChannelFailure.
|
||||
func NewTemporaryChannelFailure(update *ChannelUpdate) *FailTemporaryChannelFailure {
|
||||
func NewTemporaryChannelFailure(
|
||||
update *ChannelUpdate1) *FailTemporaryChannelFailure {
|
||||
|
||||
return &FailTemporaryChannelFailure{Update: update}
|
||||
}
|
||||
|
||||
|
@ -686,7 +688,7 @@ func (f *FailTemporaryChannelFailure) Decode(r io.Reader, pver uint32) error {
|
|||
}
|
||||
|
||||
if length != 0 {
|
||||
f.Update = &ChannelUpdate{}
|
||||
f.Update = &ChannelUpdate1{}
|
||||
|
||||
return parseChannelUpdateCompatibilityMode(
|
||||
r, length, f.Update, pver,
|
||||
|
@ -721,12 +723,12 @@ type FailAmountBelowMinimum struct {
|
|||
|
||||
// Update is used to update information about state of the channel
|
||||
// which caused the failure.
|
||||
Update ChannelUpdate
|
||||
Update ChannelUpdate1
|
||||
}
|
||||
|
||||
// NewAmountBelowMinimum creates new instance of the FailAmountBelowMinimum.
|
||||
func NewAmountBelowMinimum(htlcMsat MilliSatoshi,
|
||||
update ChannelUpdate) *FailAmountBelowMinimum {
|
||||
update ChannelUpdate1) *FailAmountBelowMinimum {
|
||||
|
||||
return &FailAmountBelowMinimum{
|
||||
HtlcMsat: htlcMsat,
|
||||
|
@ -762,7 +764,7 @@ func (f *FailAmountBelowMinimum) Decode(r io.Reader, pver uint32) error {
|
|||
return err
|
||||
}
|
||||
|
||||
f.Update = ChannelUpdate{}
|
||||
f.Update = ChannelUpdate1{}
|
||||
|
||||
return parseChannelUpdateCompatibilityMode(
|
||||
r, length, &f.Update, pver,
|
||||
|
@ -791,12 +793,12 @@ type FailFeeInsufficient struct {
|
|||
|
||||
// Update is used to update information about state of the channel
|
||||
// which caused the failure.
|
||||
Update ChannelUpdate
|
||||
Update ChannelUpdate1
|
||||
}
|
||||
|
||||
// NewFeeInsufficient creates new instance of the FailFeeInsufficient.
|
||||
func NewFeeInsufficient(htlcMsat MilliSatoshi,
|
||||
update ChannelUpdate) *FailFeeInsufficient {
|
||||
update ChannelUpdate1) *FailFeeInsufficient {
|
||||
return &FailFeeInsufficient{
|
||||
HtlcMsat: htlcMsat,
|
||||
Update: update,
|
||||
|
@ -831,7 +833,7 @@ func (f *FailFeeInsufficient) Decode(r io.Reader, pver uint32) error {
|
|||
return err
|
||||
}
|
||||
|
||||
f.Update = ChannelUpdate{}
|
||||
f.Update = ChannelUpdate1{}
|
||||
|
||||
return parseChannelUpdateCompatibilityMode(
|
||||
r, length, &f.Update, pver,
|
||||
|
@ -862,12 +864,12 @@ type FailIncorrectCltvExpiry struct {
|
|||
|
||||
// Update is used to update information about state of the channel
|
||||
// which caused the failure.
|
||||
Update ChannelUpdate
|
||||
Update ChannelUpdate1
|
||||
}
|
||||
|
||||
// NewIncorrectCltvExpiry creates new instance of the FailIncorrectCltvExpiry.
|
||||
func NewIncorrectCltvExpiry(cltvExpiry uint32,
|
||||
update ChannelUpdate) *FailIncorrectCltvExpiry {
|
||||
update ChannelUpdate1) *FailIncorrectCltvExpiry {
|
||||
|
||||
return &FailIncorrectCltvExpiry{
|
||||
CltvExpiry: cltvExpiry,
|
||||
|
@ -900,7 +902,7 @@ func (f *FailIncorrectCltvExpiry) Decode(r io.Reader, pver uint32) error {
|
|||
return err
|
||||
}
|
||||
|
||||
f.Update = ChannelUpdate{}
|
||||
f.Update = ChannelUpdate1{}
|
||||
|
||||
return parseChannelUpdateCompatibilityMode(
|
||||
r, length, &f.Update, pver,
|
||||
|
@ -925,11 +927,11 @@ func (f *FailIncorrectCltvExpiry) Encode(w *bytes.Buffer, pver uint32) error {
|
|||
type FailExpiryTooSoon struct {
|
||||
// Update is used to update information about state of the channel
|
||||
// which caused the failure.
|
||||
Update ChannelUpdate
|
||||
Update ChannelUpdate1
|
||||
}
|
||||
|
||||
// NewExpiryTooSoon creates new instance of the FailExpiryTooSoon.
|
||||
func NewExpiryTooSoon(update ChannelUpdate) *FailExpiryTooSoon {
|
||||
func NewExpiryTooSoon(update ChannelUpdate1) *FailExpiryTooSoon {
|
||||
return &FailExpiryTooSoon{
|
||||
Update: update,
|
||||
}
|
||||
|
@ -958,7 +960,7 @@ func (f *FailExpiryTooSoon) Decode(r io.Reader, pver uint32) error {
|
|||
return err
|
||||
}
|
||||
|
||||
f.Update = ChannelUpdate{}
|
||||
f.Update = ChannelUpdate1{}
|
||||
|
||||
return parseChannelUpdateCompatibilityMode(
|
||||
r, length, &f.Update, pver,
|
||||
|
@ -984,11 +986,13 @@ type FailChannelDisabled struct {
|
|||
|
||||
// Update is used to update information about state of the channel
|
||||
// which caused the failure.
|
||||
Update ChannelUpdate
|
||||
Update ChannelUpdate1
|
||||
}
|
||||
|
||||
// NewChannelDisabled creates new instance of the FailChannelDisabled.
|
||||
func NewChannelDisabled(flags uint16, update ChannelUpdate) *FailChannelDisabled {
|
||||
func NewChannelDisabled(flags uint16,
|
||||
update ChannelUpdate1) *FailChannelDisabled {
|
||||
|
||||
return &FailChannelDisabled{
|
||||
Flags: flags,
|
||||
Update: update,
|
||||
|
@ -1023,7 +1027,7 @@ func (f *FailChannelDisabled) Decode(r io.Reader, pver uint32) error {
|
|||
return err
|
||||
}
|
||||
|
||||
f.Update = ChannelUpdate{}
|
||||
f.Update = ChannelUpdate1{}
|
||||
|
||||
return parseChannelUpdateCompatibilityMode(
|
||||
r, length, &f.Update, pver,
|
||||
|
@ -1516,7 +1520,7 @@ func makeEmptyOnionError(code FailCode) (FailureMessage, error) {
|
|||
// writeOnionErrorChanUpdate writes out a ChannelUpdate using the onion error
|
||||
// format. The format is that we first write out the true serialized length of
|
||||
// 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 {
|
||||
|
||||
// First, we encode the channel update in a temporary buffer in order
|
||||
|
|
|
@ -21,7 +21,7 @@ var (
|
|||
testType = uint64(3)
|
||||
testOffset = uint16(24)
|
||||
sig, _ = NewSigFromSignature(testSig)
|
||||
testChannelUpdate = ChannelUpdate{
|
||||
testChannelUpdate = ChannelUpdate1{
|
||||
Signature: sig,
|
||||
ShortChannelID: NewShortChanIDFromInt(1),
|
||||
Timestamp: 1,
|
||||
|
@ -138,7 +138,7 @@ func TestChannelUpdateCompatibilityParsing(t *testing.T) {
|
|||
// 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
|
||||
// encoded channel update message.
|
||||
var newChanUpdate ChannelUpdate
|
||||
var newChanUpdate ChannelUpdate1
|
||||
err := parseChannelUpdateCompatibilityMode(
|
||||
&b, uint16(b.Len()), &newChanUpdate, 0,
|
||||
)
|
||||
|
@ -165,7 +165,7 @@ func TestChannelUpdateCompatibilityParsing(t *testing.T) {
|
|||
|
||||
// We should be able to properly parse the encoded channel update
|
||||
// message even with the extra two bytes.
|
||||
var newChanUpdate2 ChannelUpdate
|
||||
var newChanUpdate2 ChannelUpdate1
|
||||
err = parseChannelUpdateCompatibilityMode(
|
||||
&b, uint16(b.Len()), &newChanUpdate2, 0,
|
||||
)
|
||||
|
|
|
@ -60,7 +60,7 @@ type ChanStatusConfig struct {
|
|||
// ApplyChannelUpdate processes new ChannelUpdates signed by our node by
|
||||
// updating our local routing table and broadcasting the update to our
|
||||
// peers.
|
||||
ApplyChannelUpdate func(*lnwire.ChannelUpdate, *wire.OutPoint,
|
||||
ApplyChannelUpdate func(*lnwire.ChannelUpdate1, *wire.OutPoint,
|
||||
bool) error
|
||||
|
||||
// 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
|
||||
// the channel is private by checking AuthProof for nil.
|
||||
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.
|
||||
info, edge1, edge2, err := m.cfg.Graph.FetchChannelEdgesByOutpoint(&op)
|
||||
|
|
|
@ -126,7 +126,7 @@ type mockGraph struct {
|
|||
chanPols2 map[wire.OutPoint]*models.ChannelEdgePolicy
|
||||
sidToCid map[lnwire.ShortChannelID]wire.OutPoint
|
||||
|
||||
updates chan *lnwire.ChannelUpdate
|
||||
updates chan *lnwire.ChannelUpdate1
|
||||
}
|
||||
|
||||
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),
|
||||
chanPols2: make(map[wire.OutPoint]*models.ChannelEdgePolicy),
|
||||
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++ {
|
||||
|
@ -177,7 +177,7 @@ func (g *mockGraph) FetchChannelEdgesByOutpoint(
|
|||
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 {
|
||||
|
||||
g.mu.Lock()
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
func CreateChanAnnouncement(chanProof *models.ChannelAuthProof,
|
||||
chanInfo *models.ChannelEdgeInfo,
|
||||
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
|
||||
// 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
|
||||
// edge in a direction, we don't create an advertisement if the edge is
|
||||
// nil.
|
||||
var edge1Ann, edge2Ann *lnwire.ChannelUpdate
|
||||
var edge1Ann, edge2Ann *lnwire.ChannelUpdate1
|
||||
if e1 != nil {
|
||||
edge1Ann, err = ChannelUpdateFromEdge(chanInfo, e1)
|
||||
if err != nil {
|
||||
|
|
|
@ -18,12 +18,12 @@ var ErrUnableToExtractChanUpdate = fmt.Errorf("unable to extract ChannelUpdate")
|
|||
|
||||
// ChannelUpdateModifier is a closure that makes in-place modifications to an
|
||||
// lnwire.ChannelUpdate.
|
||||
type ChannelUpdateModifier func(*lnwire.ChannelUpdate)
|
||||
type ChannelUpdateModifier func(*lnwire.ChannelUpdate1)
|
||||
|
||||
// ChanUpdSetDisable is a functional option that sets the disabled channel flag
|
||||
// if disabled is true, and clears the bit otherwise.
|
||||
func ChanUpdSetDisable(disabled bool) ChannelUpdateModifier {
|
||||
return func(update *lnwire.ChannelUpdate) {
|
||||
return func(update *lnwire.ChannelUpdate1) {
|
||||
if disabled {
|
||||
// Set the bit responsible for marking a channel as
|
||||
// disabled.
|
||||
|
@ -39,7 +39,7 @@ func ChanUpdSetDisable(disabled bool) ChannelUpdateModifier {
|
|||
// 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
|
||||
// the future.
|
||||
func ChanUpdSetTimestamp(update *lnwire.ChannelUpdate) {
|
||||
func ChanUpdSetTimestamp(update *lnwire.ChannelUpdate1) {
|
||||
newTimestamp := uint32(time.Now().Unix())
|
||||
if newTimestamp <= update.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.
|
||||
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.
|
||||
for _, modifier := range mods {
|
||||
|
@ -86,7 +86,7 @@ func SignChannelUpdate(signer lnwallet.MessageSigner, keyLoc keychain.KeyLocator
|
|||
func ExtractChannelUpdate(ownerPubKey []byte,
|
||||
info *models.ChannelEdgeInfo,
|
||||
policies ...*models.ChannelEdgePolicy) (
|
||||
*lnwire.ChannelUpdate, error) {
|
||||
*lnwire.ChannelUpdate1, error) {
|
||||
|
||||
// Helper function to extract the owner of the given policy.
|
||||
owner := func(edge *models.ChannelEdgePolicy) []byte {
|
||||
|
@ -118,9 +118,9 @@ func ExtractChannelUpdate(ownerPubKey []byte,
|
|||
// UnsignedChannelUpdateFromEdge reconstructs an unsigned ChannelUpdate from the
|
||||
// given edge info and policy.
|
||||
func UnsignedChannelUpdateFromEdge(info *models.ChannelEdgeInfo,
|
||||
policy *models.ChannelEdgePolicy) *lnwire.ChannelUpdate {
|
||||
policy *models.ChannelEdgePolicy) *lnwire.ChannelUpdate1 {
|
||||
|
||||
return &lnwire.ChannelUpdate{
|
||||
return &lnwire.ChannelUpdate1{
|
||||
ChainHash: info.ChainHash,
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(policy.ChannelID),
|
||||
Timestamp: uint32(policy.LastUpdate.Unix()),
|
||||
|
@ -138,7 +138,7 @@ func UnsignedChannelUpdateFromEdge(info *models.ChannelEdgeInfo,
|
|||
// ChannelUpdateFromEdge reconstructs a signed ChannelUpdate from the given edge
|
||||
// info and policy.
|
||||
func ChannelUpdateFromEdge(info *models.ChannelEdgeInfo,
|
||||
policy *models.ChannelEdgePolicy) (*lnwire.ChannelUpdate, error) {
|
||||
policy *models.ChannelEdgePolicy) (*lnwire.ChannelUpdate1, error) {
|
||||
|
||||
update := UnsignedChannelUpdateFromEdge(info, policy)
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ func TestUpdateDisableFlag(t *testing.T) {
|
|||
// Create the initial update, the only fields we are
|
||||
// concerned with in this test are the timestamp and the
|
||||
// channel flags.
|
||||
ogUpdate := &lnwire.ChannelUpdate{
|
||||
ogUpdate := &lnwire.ChannelUpdate1{
|
||||
Timestamp: uint32(tc.startTime.Unix()),
|
||||
}
|
||||
if !tc.startEnabled {
|
||||
|
@ -122,7 +122,7 @@ func TestUpdateDisableFlag(t *testing.T) {
|
|||
// the original. UpdateDisableFlag will mutate the
|
||||
// passed channel update, so we keep the old one to test
|
||||
// against.
|
||||
newUpdate := &lnwire.ChannelUpdate{
|
||||
newUpdate := &lnwire.ChannelUpdate1{
|
||||
Timestamp: ogUpdate.Timestamp,
|
||||
ChannelFlags: ogUpdate.ChannelFlags,
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ func SignAnnouncement(signer lnwallet.MessageSigner, keyLoc keychain.KeyLocator,
|
|||
switch m := msg.(type) {
|
||||
case *lnwire.ChannelAnnouncement1:
|
||||
data, err = m.DataToSign()
|
||||
case *lnwire.ChannelUpdate:
|
||||
case *lnwire.ChannelUpdate1:
|
||||
data, err = m.DataToSign()
|
||||
case *lnwire.NodeAnnouncement:
|
||||
data, err = m.DataToSign()
|
||||
|
|
|
@ -301,7 +301,7 @@ type Config struct {
|
|||
|
||||
// FetchLastChanUpdate fetches our latest channel update for a target
|
||||
// channel.
|
||||
FetchLastChanUpdate func(lnwire.ShortChannelID) (*lnwire.ChannelUpdate,
|
||||
FetchLastChanUpdate func(lnwire.ShortChannelID) (*lnwire.ChannelUpdate1,
|
||||
error)
|
||||
|
||||
// FundingManager is an implementation of the funding.Controller interface.
|
||||
|
@ -1963,7 +1963,7 @@ out:
|
|||
nextMsg.MsgType())
|
||||
}
|
||||
|
||||
case *lnwire.ChannelUpdate,
|
||||
case *lnwire.ChannelUpdate1,
|
||||
*lnwire.ChannelAnnouncement1,
|
||||
*lnwire.NodeAnnouncement,
|
||||
*lnwire.AnnounceSignatures1,
|
||||
|
@ -2233,7 +2233,7 @@ func messageSummary(msg lnwire.Message) string {
|
|||
return fmt.Sprintf("chain_hash=%v, short_chan_id=%v",
|
||||
msg.ChainHash, msg.ShortChannelID.ToUint64())
|
||||
|
||||
case *lnwire.ChannelUpdate:
|
||||
case *lnwire.ChannelUpdate1:
|
||||
return fmt.Sprintf("chain_hash=%v, short_chan_id=%v, "+
|
||||
"mflags=%v, cflags=%v, update_time=%v", msg.ChainHash,
|
||||
msg.ShortChannelID.ToUint64(), msg.MessageFlags,
|
||||
|
|
|
@ -611,7 +611,7 @@ func createTestPeer(t *testing.T) *peerTestCtx {
|
|||
IsChannelActive: func(lnwire.ChannelID) bool {
|
||||
return true
|
||||
},
|
||||
ApplyChannelUpdate: func(*lnwire.ChannelUpdate,
|
||||
ApplyChannelUpdate: func(*lnwire.ChannelUpdate1,
|
||||
*wire.OutPoint, bool) error {
|
||||
|
||||
return nil
|
||||
|
@ -719,9 +719,9 @@ func createTestPeer(t *testing.T) *peerTestCtx {
|
|||
},
|
||||
PongBuf: make([]byte, lnwire.MaxPongBytes),
|
||||
FetchLastChanUpdate: func(chanID lnwire.ShortChannelID,
|
||||
) (*lnwire.ChannelUpdate, error) {
|
||||
) (*lnwire.ChannelUpdate1, error) {
|
||||
|
||||
return &lnwire.ChannelUpdate{}, nil
|
||||
return &lnwire.ChannelUpdate1{}, nil
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ func TestMissionControl(t *testing.T) {
|
|||
|
||||
// A node level failure should bring probability of all known channels
|
||||
// back to zero.
|
||||
ctx.reportFailure(0, lnwire.NewExpiryTooSoon(lnwire.ChannelUpdate{}))
|
||||
ctx.reportFailure(0, lnwire.NewExpiryTooSoon(lnwire.ChannelUpdate1{}))
|
||||
ctx.expectP(1000, 0)
|
||||
|
||||
// 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
|
||||
// expect a penalty.
|
||||
ctx.reportFailure(
|
||||
0, lnwire.NewFeeInsufficient(0, lnwire.ChannelUpdate{}),
|
||||
0, lnwire.NewFeeInsufficient(0, lnwire.ChannelUpdate1{}),
|
||||
)
|
||||
ctx.expectP(100, testAprioriHopProbability)
|
||||
|
||||
// Report another failure for the same channel. We expect it to be
|
||||
// pruned.
|
||||
ctx.reportFailure(
|
||||
0, lnwire.NewFeeInsufficient(0, lnwire.ChannelUpdate{}),
|
||||
0, lnwire.NewFeeInsufficient(0, lnwire.ChannelUpdate1{}),
|
||||
)
|
||||
ctx.expectP(100, 0)
|
||||
}
|
||||
|
|
|
@ -186,7 +186,7 @@ func (m *mockPaymentSessionOld) RequestRoute(_, _ lnwire.MilliSatoshi,
|
|||
return r, nil
|
||||
}
|
||||
|
||||
func (m *mockPaymentSessionOld) UpdateAdditionalEdge(_ *lnwire.ChannelUpdate,
|
||||
func (m *mockPaymentSessionOld) UpdateAdditionalEdge(_ *lnwire.ChannelUpdate1,
|
||||
_ *btcec.PublicKey, _ *models.CachedEdgePolicy) bool {
|
||||
|
||||
return false
|
||||
|
@ -710,7 +710,7 @@ func (m *mockPaymentSession) RequestRoute(maxAmt, feeLimit lnwire.MilliSatoshi,
|
|||
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 {
|
||||
|
||||
args := m.Called(msg, pubKey, policy)
|
||||
|
|
|
@ -147,8 +147,8 @@ type PaymentSession interface {
|
|||
// (private channels) and applies the update from the message. Returns
|
||||
// a boolean to indicate whether the update has been applied without
|
||||
// error.
|
||||
UpdateAdditionalEdge(msg *lnwire.ChannelUpdate, pubKey *btcec.PublicKey,
|
||||
policy *models.CachedEdgePolicy) bool
|
||||
UpdateAdditionalEdge(msg *lnwire.ChannelUpdate1,
|
||||
pubKey *btcec.PublicKey, policy *models.CachedEdgePolicy) bool
|
||||
|
||||
// GetAdditionalEdgePolicy uses the public key and channel ID to query
|
||||
// the ephemeral channel edge policy for additional edges. Returns a nil
|
||||
|
@ -436,7 +436,7 @@ func (p *paymentSession) RequestRoute(maxAmt, feeLimit lnwire.MilliSatoshi,
|
|||
// 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
|
||||
// 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 {
|
||||
|
||||
// Validate the message signature.
|
||||
|
|
|
@ -147,7 +147,7 @@ func TestUpdateAdditionalEdge(t *testing.T) {
|
|||
)
|
||||
|
||||
// Create the channel update message and sign.
|
||||
msg := &lnwire.ChannelUpdate{
|
||||
msg := &lnwire.ChannelUpdate1{
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(testChannelID),
|
||||
Timestamp: uint32(time.Now().Unix()),
|
||||
BaseFee: newFeeBaseMSat,
|
||||
|
|
|
@ -164,7 +164,7 @@ var resultTestCases = []resultTestCase{
|
|||
name: "fail expiry too soon",
|
||||
route: &routeFourHop,
|
||||
failureSrcIdx: 3,
|
||||
failure: lnwire.NewExpiryTooSoon(lnwire.ChannelUpdate{}),
|
||||
failure: lnwire.NewExpiryTooSoon(lnwire.ChannelUpdate1{}),
|
||||
|
||||
expectedResult: &interpretedResult{
|
||||
pairResults: map[DirectedNodePair]pairResult{
|
||||
|
@ -266,8 +266,9 @@ var resultTestCases = []resultTestCase{
|
|||
name: "fail fee insufficient intermediate",
|
||||
route: &routeFourHop,
|
||||
failureSrcIdx: 2,
|
||||
failure: lnwire.NewFeeInsufficient(0, lnwire.ChannelUpdate{}),
|
||||
|
||||
failure: lnwire.NewFeeInsufficient(
|
||||
0, lnwire.ChannelUpdate1{},
|
||||
),
|
||||
expectedResult: &interpretedResult{
|
||||
pairResults: map[DirectedNodePair]pairResult{
|
||||
getTestPair(0, 1): {
|
||||
|
|
|
@ -288,7 +288,7 @@ type Config struct {
|
|||
|
||||
// ApplyChannelUpdate can be called to apply a new channel update to the
|
||||
// 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.
|
||||
//
|
||||
|
@ -1329,9 +1329,9 @@ func (r *ChannelRouter) sendPayment(ctx context.Context,
|
|||
|
||||
// extractChannelUpdate examines the error and extracts the channel update.
|
||||
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) {
|
||||
case *lnwire.FailExpiryTooSoon:
|
||||
update = &onionErr.Update
|
||||
|
|
|
@ -223,7 +223,7 @@ func createTestCtxFromFile(t *testing.T,
|
|||
// Add valid signature to channel update simulated as error received from the
|
||||
// network.
|
||||
func signErrChanUpdate(t *testing.T, key *btcec.PrivateKey,
|
||||
errChanUpdate *lnwire.ChannelUpdate) {
|
||||
errChanUpdate *lnwire.ChannelUpdate1) {
|
||||
|
||||
chanUpdateMsg, err := errChanUpdate.DataToSign()
|
||||
require.NoError(t, err, "failed to retrieve data to sign")
|
||||
|
@ -488,7 +488,7 @@ func TestChannelUpdateValidation(t *testing.T) {
|
|||
// Set up a channel update message with an invalid signature to be
|
||||
// returned to the sender.
|
||||
var invalidSignature lnwire.Sig
|
||||
errChanUpdate := lnwire.ChannelUpdate{
|
||||
errChanUpdate := lnwire.ChannelUpdate1{
|
||||
Signature: invalidSignature,
|
||||
FeeRate: 500,
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(1),
|
||||
|
@ -593,7 +593,7 @@ func TestSendPaymentErrorRepeatedFeeInsufficient(t *testing.T) {
|
|||
)
|
||||
require.NoError(t, err, "unable to fetch chan id")
|
||||
|
||||
errChanUpdate := lnwire.ChannelUpdate{
|
||||
errChanUpdate := lnwire.ChannelUpdate1{
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(
|
||||
songokuSophonChanID,
|
||||
),
|
||||
|
@ -712,7 +712,7 @@ func TestSendPaymentErrorFeeInsufficientPrivateEdge(t *testing.T) {
|
|||
// Prepare an error update for the private channel, with twice the
|
||||
// original fee.
|
||||
updatedFeeBaseMSat := feeBaseMSat * 2
|
||||
errChanUpdate := lnwire.ChannelUpdate{
|
||||
errChanUpdate := lnwire.ChannelUpdate1{
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(privateChannelID),
|
||||
Timestamp: uint32(testTime.Add(time.Minute).Unix()),
|
||||
BaseFee: updatedFeeBaseMSat,
|
||||
|
@ -838,7 +838,7 @@ func TestSendPaymentPrivateEdgeUpdateFeeExceedsLimit(t *testing.T) {
|
|||
// Prepare an error update for the private channel. The updated fee
|
||||
// will exceeds the feeLimit.
|
||||
updatedFeeBaseMSat := feeBaseMSat + uint32(feeLimit)
|
||||
errChanUpdate := lnwire.ChannelUpdate{
|
||||
errChanUpdate := lnwire.ChannelUpdate1{
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(privateChannelID),
|
||||
Timestamp: uint32(testTime.Add(time.Minute).Unix()),
|
||||
BaseFee: updatedFeeBaseMSat,
|
||||
|
@ -939,7 +939,7 @@ func TestSendPaymentErrorNonFinalTimeLockErrors(t *testing.T) {
|
|||
_, _, edgeUpdateToFail, err := ctx.graph.FetchChannelEdgesByID(chanID)
|
||||
require.NoError(t, err, "unable to fetch chan id")
|
||||
|
||||
errChanUpdate := lnwire.ChannelUpdate{
|
||||
errChanUpdate := lnwire.ChannelUpdate1{
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(chanID),
|
||||
Timestamp: uint32(edgeUpdateToFail.LastUpdate.Unix()),
|
||||
MessageFlags: edgeUpdateToFail.MessageFlags,
|
||||
|
@ -1402,7 +1402,7 @@ func TestSendToRouteStructuredError(t *testing.T) {
|
|||
testCases := map[int]lnwire.FailureMessage{
|
||||
finalHopIndex: lnwire.NewFailIncorrectDetails(payAmt, 100),
|
||||
1: &lnwire.FailFeeInsufficient{
|
||||
Update: lnwire.ChannelUpdate{},
|
||||
Update: lnwire.ChannelUpdate1{},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -2967,7 +2967,7 @@ func (m *mockGraphBuilder) setNextReject(reject bool) {
|
|||
m.rejectUpdate = reject
|
||||
}
|
||||
|
||||
func (m *mockGraphBuilder) ApplyChannelUpdate(msg *lnwire.ChannelUpdate) bool {
|
||||
func (m *mockGraphBuilder) ApplyChannelUpdate(msg *lnwire.ChannelUpdate1) bool {
|
||||
if m.rejectUpdate {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -1753,7 +1753,7 @@ func (s *server) UpdateRoutingConfig(cfg *routing.MissionControlConfig) {
|
|||
// signAliasUpdate takes a ChannelUpdate and returns the signature. This is
|
||||
// used for option_scid_alias channels where the ChannelUpdate to be sent back
|
||||
// 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) {
|
||||
|
||||
data, err := u.DataToSign()
|
||||
|
@ -4826,10 +4826,10 @@ func (s *server) fetchNodeAdvertisedAddrs(pub *btcec.PublicKey) ([]net.Addr, err
|
|||
// fetchLastChanUpdate returns a function which is able to retrieve our latest
|
||||
// channel update for a target channel.
|
||||
func (s *server) fetchLastChanUpdate() func(lnwire.ShortChannelID) (
|
||||
*lnwire.ChannelUpdate, error) {
|
||||
*lnwire.ChannelUpdate1, error) {
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -4844,7 +4844,7 @@ func (s *server) fetchLastChanUpdate() func(lnwire.ShortChannelID) (
|
|||
// 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
|
||||
// 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 {
|
||||
|
||||
var (
|
||||
|
|
Loading…
Add table
Reference in a new issue