mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-18 21:02:42 +02:00
multi: rename ChannelAnnouncement to ChannelAnnouncment1
In preparation for adding the new ChannelAnnouncement2 message along with a ChannelAnnouncement interface, we rename the existing message to ChannelAnnouncement1.
This commit is contained in:
parent
05d76b696d
commit
bb44efa21f
@ -849,9 +849,9 @@ func (d *AuthenticatedGossiper) ProcessRemoteAnnouncement(msg lnwire.Message,
|
|||||||
// To avoid inserting edges in the graph for our own channels that we
|
// To avoid inserting edges in the graph for our own channels that we
|
||||||
// have already closed, we ignore such channel announcements coming
|
// have already closed, we ignore such channel announcements coming
|
||||||
// from the remote.
|
// from the remote.
|
||||||
case *lnwire.ChannelAnnouncement:
|
case *lnwire.ChannelAnnouncement1:
|
||||||
ownKey := d.selfKey.SerializeCompressed()
|
ownKey := d.selfKey.SerializeCompressed()
|
||||||
ownErr := fmt.Errorf("ignoring remote ChannelAnnouncement " +
|
ownErr := fmt.Errorf("ignoring remote ChannelAnnouncement1 " +
|
||||||
"for own channel")
|
"for own channel")
|
||||||
|
|
||||||
if bytes.Equal(m.NodeID1[:], ownKey) ||
|
if bytes.Equal(m.NodeID1[:], ownKey) ||
|
||||||
@ -1011,7 +1011,7 @@ func (d *deDupedAnnouncements) addMsg(message networkMsg) {
|
|||||||
switch msg := message.msg.(type) {
|
switch msg := message.msg.(type) {
|
||||||
|
|
||||||
// Channel announcements are identified by the short channel id field.
|
// Channel announcements are identified by the short channel id field.
|
||||||
case *lnwire.ChannelAnnouncement:
|
case *lnwire.ChannelAnnouncement1:
|
||||||
deDupKey := msg.ShortChannelID
|
deDupKey := msg.ShortChannelID
|
||||||
sender := route.NewVertex(message.source)
|
sender := route.NewVertex(message.source)
|
||||||
|
|
||||||
@ -1585,7 +1585,7 @@ func (d *AuthenticatedGossiper) isRecentlyRejectedMsg(msg lnwire.Message,
|
|||||||
case *lnwire.ChannelUpdate:
|
case *lnwire.ChannelUpdate:
|
||||||
scid = m.ShortChannelID.ToUint64()
|
scid = m.ShortChannelID.ToUint64()
|
||||||
|
|
||||||
case *lnwire.ChannelAnnouncement:
|
case *lnwire.ChannelAnnouncement1:
|
||||||
scid = m.ShortChannelID.ToUint64()
|
scid = m.ShortChannelID.ToUint64()
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1844,7 +1844,7 @@ func remotePubFromChanInfo(chanInfo *models.ChannelEdgeInfo,
|
|||||||
// to receive the remote peer's proof, while the remote peer is able to fully
|
// to receive the remote peer's proof, while the remote peer is able to fully
|
||||||
// assemble the proof and craft the ChannelAnnouncement.
|
// assemble the proof and craft the ChannelAnnouncement.
|
||||||
func (d *AuthenticatedGossiper) processRejectedEdge(
|
func (d *AuthenticatedGossiper) processRejectedEdge(
|
||||||
chanAnnMsg *lnwire.ChannelAnnouncement,
|
chanAnnMsg *lnwire.ChannelAnnouncement1,
|
||||||
proof *models.ChannelAuthProof) ([]networkMsg, error) {
|
proof *models.ChannelAuthProof) ([]networkMsg, error) {
|
||||||
|
|
||||||
// First, we'll fetch the state of the channel as we know if from the
|
// First, we'll fetch the state of the channel as we know if from the
|
||||||
@ -2029,7 +2029,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
|
|||||||
// *creation* of a new channel within the network. This only advertises
|
// *creation* of a new channel within the network. This only advertises
|
||||||
// the existence of a channel and not yet the routing policies in
|
// the existence of a channel and not yet the routing policies in
|
||||||
// either direction of the channel.
|
// either direction of the channel.
|
||||||
case *lnwire.ChannelAnnouncement:
|
case *lnwire.ChannelAnnouncement1:
|
||||||
return d.handleChanAnnouncement(nMsg, msg, schedulerOp)
|
return d.handleChanAnnouncement(nMsg, msg, schedulerOp)
|
||||||
|
|
||||||
// A new authenticated channel edge update has arrived. This indicates
|
// A new authenticated channel edge update has arrived. This indicates
|
||||||
@ -2195,7 +2195,7 @@ func (d *AuthenticatedGossiper) isMsgStale(msg lnwire.Message) bool {
|
|||||||
// updateChannel creates a new fully signed update for the channel, and updates
|
// updateChannel creates a new fully signed update for the channel, and updates
|
||||||
// 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.ChannelAnnouncement,
|
edge *models.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement1,
|
||||||
*lnwire.ChannelUpdate, error) {
|
*lnwire.ChannelUpdate, error) {
|
||||||
|
|
||||||
// Parse the unsigned edge into a channel update.
|
// Parse the unsigned edge into a channel update.
|
||||||
@ -2234,10 +2234,10 @@ func (d *AuthenticatedGossiper) updateChannel(info *models.ChannelEdgeInfo,
|
|||||||
// We'll also create the original channel announcement so the two can
|
// We'll also create the original channel announcement so the two can
|
||||||
// be broadcast along side each other (if necessary), but only if we
|
// be broadcast along side each other (if necessary), but only if we
|
||||||
// have a full channel announcement for this channel.
|
// have a full channel announcement for this channel.
|
||||||
var chanAnn *lnwire.ChannelAnnouncement
|
var chanAnn *lnwire.ChannelAnnouncement1
|
||||||
if info.AuthProof != nil {
|
if info.AuthProof != nil {
|
||||||
chanID := lnwire.NewShortChanIDFromInt(info.ChannelID)
|
chanID := lnwire.NewShortChanIDFromInt(info.ChannelID)
|
||||||
chanAnn = &lnwire.ChannelAnnouncement{
|
chanAnn = &lnwire.ChannelAnnouncement1{
|
||||||
ShortChannelID: chanID,
|
ShortChannelID: chanID,
|
||||||
NodeID1: info.NodeKey1Bytes,
|
NodeID1: info.NodeKey1Bytes,
|
||||||
NodeID2: info.NodeKey2Bytes,
|
NodeID2: info.NodeKey2Bytes,
|
||||||
@ -2409,18 +2409,18 @@ func (d *AuthenticatedGossiper) handleNodeAnnouncement(nMsg *networkMsg,
|
|||||||
|
|
||||||
// handleChanAnnouncement processes a new channel announcement.
|
// handleChanAnnouncement processes a new channel announcement.
|
||||||
func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
|
func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
|
||||||
ann *lnwire.ChannelAnnouncement,
|
ann *lnwire.ChannelAnnouncement1,
|
||||||
ops []batch.SchedulerOption) ([]networkMsg, bool) {
|
ops []batch.SchedulerOption) ([]networkMsg, bool) {
|
||||||
|
|
||||||
scid := ann.ShortChannelID
|
scid := ann.ShortChannelID
|
||||||
|
|
||||||
log.Debugf("Processing ChannelAnnouncement: peer=%v, short_chan_id=%v",
|
log.Debugf("Processing ChannelAnnouncement1: peer=%v, short_chan_id=%v",
|
||||||
nMsg.peer, scid.ToUint64())
|
nMsg.peer, scid.ToUint64())
|
||||||
|
|
||||||
// We'll ignore any channel announcements that target any chain other
|
// We'll ignore any channel announcements that target any chain other
|
||||||
// than the set of chains we know of.
|
// than the set of chains we know of.
|
||||||
if !bytes.Equal(ann.ChainHash[:], d.cfg.ChainHash[:]) {
|
if !bytes.Equal(ann.ChainHash[:], d.cfg.ChainHash[:]) {
|
||||||
err := fmt.Errorf("ignoring ChannelAnnouncement from chain=%v"+
|
err := fmt.Errorf("ignoring ChannelAnnouncement1 from chain=%v"+
|
||||||
", gossiper on chain=%v", ann.ChainHash,
|
", gossiper on chain=%v", ann.ChainHash,
|
||||||
d.cfg.ChainHash)
|
d.cfg.ChainHash)
|
||||||
log.Errorf(err.Error())
|
log.Errorf(err.Error())
|
||||||
@ -2788,7 +2788,7 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
|
|||||||
|
|
||||||
nMsg.err <- nil
|
nMsg.err <- nil
|
||||||
|
|
||||||
log.Debugf("Processed ChannelAnnouncement: peer=%v, short_chan_id=%v",
|
log.Debugf("Processed ChannelAnnouncement1: peer=%v, short_chan_id=%v",
|
||||||
nMsg.peer, scid.ToUint64())
|
nMsg.peer, scid.ToUint64())
|
||||||
|
|
||||||
return announcements, true
|
return announcements, true
|
||||||
|
@ -476,7 +476,7 @@ type annBatch struct {
|
|||||||
nodeAnn1 *lnwire.NodeAnnouncement
|
nodeAnn1 *lnwire.NodeAnnouncement
|
||||||
nodeAnn2 *lnwire.NodeAnnouncement
|
nodeAnn2 *lnwire.NodeAnnouncement
|
||||||
|
|
||||||
chanAnn *lnwire.ChannelAnnouncement
|
chanAnn *lnwire.ChannelAnnouncement1
|
||||||
|
|
||||||
chanUpdAnn1 *lnwire.ChannelUpdate
|
chanUpdAnn1 *lnwire.ChannelUpdate
|
||||||
chanUpdAnn2 *lnwire.ChannelUpdate
|
chanUpdAnn2 *lnwire.ChannelUpdate
|
||||||
@ -635,9 +635,9 @@ func signUpdate(nodeKey *btcec.PrivateKey, a *lnwire.ChannelUpdate) error {
|
|||||||
|
|
||||||
func createAnnouncementWithoutProof(blockHeight uint32,
|
func createAnnouncementWithoutProof(blockHeight uint32,
|
||||||
key1, key2 *btcec.PublicKey,
|
key1, key2 *btcec.PublicKey,
|
||||||
extraBytes ...[]byte) *lnwire.ChannelAnnouncement {
|
extraBytes ...[]byte) *lnwire.ChannelAnnouncement1 {
|
||||||
|
|
||||||
a := &lnwire.ChannelAnnouncement{
|
a := &lnwire.ChannelAnnouncement1{
|
||||||
ShortChannelID: lnwire.ShortChannelID{
|
ShortChannelID: lnwire.ShortChannelID{
|
||||||
BlockHeight: blockHeight,
|
BlockHeight: blockHeight,
|
||||||
TxIndex: 0,
|
TxIndex: 0,
|
||||||
@ -657,13 +657,13 @@ func createAnnouncementWithoutProof(blockHeight uint32,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createRemoteChannelAnnouncement(blockHeight uint32,
|
func createRemoteChannelAnnouncement(blockHeight uint32,
|
||||||
extraBytes ...[]byte) (*lnwire.ChannelAnnouncement, error) {
|
extraBytes ...[]byte) (*lnwire.ChannelAnnouncement1, error) {
|
||||||
|
|
||||||
return createChannelAnnouncement(blockHeight, remoteKeyPriv1, remoteKeyPriv2, extraBytes...)
|
return createChannelAnnouncement(blockHeight, remoteKeyPriv1, remoteKeyPriv2, extraBytes...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createChannelAnnouncement(blockHeight uint32, key1, key2 *btcec.PrivateKey,
|
func createChannelAnnouncement(blockHeight uint32, key1, key2 *btcec.PrivateKey,
|
||||||
extraBytes ...[]byte) (*lnwire.ChannelAnnouncement, error) {
|
extraBytes ...[]byte) (*lnwire.ChannelAnnouncement1, error) {
|
||||||
|
|
||||||
a := createAnnouncementWithoutProof(blockHeight, key1.PubKey(), key2.PubKey(), extraBytes...)
|
a := createAnnouncementWithoutProof(blockHeight, key1.PubKey(), key2.PubKey(), extraBytes...)
|
||||||
|
|
||||||
@ -1768,9 +1768,10 @@ func TestSignatureAnnouncementFullProofWhenRemoteProof(t *testing.T) {
|
|||||||
// We expect the gossiper to send this message to the remote peer.
|
// We expect the gossiper to send this message to the remote peer.
|
||||||
select {
|
select {
|
||||||
case msg := <-sentToPeer:
|
case msg := <-sentToPeer:
|
||||||
_, ok := msg.(*lnwire.ChannelAnnouncement)
|
_, ok := msg.(*lnwire.ChannelAnnouncement1)
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("expected ChannelAnnouncement, instead got %T", msg)
|
t.Fatalf("expected ChannelAnnouncement1, instead got "+
|
||||||
|
"%T", msg)
|
||||||
}
|
}
|
||||||
case <-time.After(2 * time.Second):
|
case <-time.After(2 * time.Second):
|
||||||
t.Fatal("did not send local proof to peer")
|
t.Fatal("did not send local proof to peer")
|
||||||
@ -2811,7 +2812,7 @@ func TestRetransmit(t *testing.T) {
|
|||||||
var chanAnn, chanUpd, nodeAnn int
|
var chanAnn, chanUpd, nodeAnn int
|
||||||
for _, msg := range anns {
|
for _, msg := range anns {
|
||||||
switch msg.(type) {
|
switch msg.(type) {
|
||||||
case *lnwire.ChannelAnnouncement:
|
case *lnwire.ChannelAnnouncement1:
|
||||||
chanAnn++
|
chanAnn++
|
||||||
case *lnwire.ChannelUpdate:
|
case *lnwire.ChannelUpdate:
|
||||||
chanUpd++
|
chanUpd++
|
||||||
|
@ -1447,7 +1447,7 @@ func (g *GossipSyncer) FilterGossipMsgs(msgs ...msgWithSenders) {
|
|||||||
// For each channel announcement message, we'll only send this
|
// For each channel announcement message, we'll only send this
|
||||||
// message if the channel updates for the channel are between
|
// message if the channel updates for the channel are between
|
||||||
// our time range.
|
// our time range.
|
||||||
case *lnwire.ChannelAnnouncement:
|
case *lnwire.ChannelAnnouncement1:
|
||||||
// First, we'll check if the channel updates are in
|
// First, we'll check if the channel updates are in
|
||||||
// this message batch.
|
// this message batch.
|
||||||
chanUpdates, ok := chanUpdateIndex[msg.ShortChannelID]
|
chanUpdates, ok := chanUpdateIndex[msg.ShortChannelID]
|
||||||
|
@ -306,7 +306,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Ann tuple below horizon.
|
// Ann tuple below horizon.
|
||||||
msg: &lnwire.ChannelAnnouncement{
|
msg: &lnwire.ChannelAnnouncement1{
|
||||||
ShortChannelID: lnwire.NewShortChanIDFromInt(10),
|
ShortChannelID: lnwire.NewShortChanIDFromInt(10),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -318,7 +318,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Ann tuple above horizon.
|
// Ann tuple above horizon.
|
||||||
msg: &lnwire.ChannelAnnouncement{
|
msg: &lnwire.ChannelAnnouncement1{
|
||||||
ShortChannelID: lnwire.NewShortChanIDFromInt(15),
|
ShortChannelID: lnwire.NewShortChanIDFromInt(15),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -330,7 +330,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Ann tuple beyond horizon.
|
// Ann tuple beyond horizon.
|
||||||
msg: &lnwire.ChannelAnnouncement{
|
msg: &lnwire.ChannelAnnouncement1{
|
||||||
ShortChannelID: lnwire.NewShortChanIDFromInt(20),
|
ShortChannelID: lnwire.NewShortChanIDFromInt(20),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -343,7 +343,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
|
|||||||
{
|
{
|
||||||
// Ann w/o an update at all, the update in the DB will
|
// Ann w/o an update at all, the update in the DB will
|
||||||
// be below the horizon.
|
// be below the horizon.
|
||||||
msg: &lnwire.ChannelAnnouncement{
|
msg: &lnwire.ChannelAnnouncement1{
|
||||||
ShortChannelID: lnwire.NewShortChanIDFromInt(25),
|
ShortChannelID: lnwire.NewShortChanIDFromInt(25),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -706,7 +706,7 @@ func TestGossipSyncerReplyShortChanIDs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
queryReply := []lnwire.Message{
|
queryReply := []lnwire.Message{
|
||||||
&lnwire.ChannelAnnouncement{
|
&lnwire.ChannelAnnouncement1{
|
||||||
ShortChannelID: lnwire.NewShortChanIDFromInt(20),
|
ShortChannelID: lnwire.NewShortChanIDFromInt(20),
|
||||||
},
|
},
|
||||||
&lnwire.ChannelUpdate{
|
&lnwire.ChannelUpdate{
|
||||||
|
@ -4143,7 +4143,7 @@ func (f *Manager) ensureInitialForwardingPolicy(chanID lnwire.ChannelID,
|
|||||||
// chanAnnouncement encapsulates the two authenticated announcements that we
|
// chanAnnouncement encapsulates the two authenticated announcements that we
|
||||||
// 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.ChannelAnnouncement
|
chanAnn *lnwire.ChannelAnnouncement1
|
||||||
chanUpdateAnn *lnwire.ChannelUpdate
|
chanUpdateAnn *lnwire.ChannelUpdate
|
||||||
chanProof *lnwire.AnnounceSignatures1
|
chanProof *lnwire.AnnounceSignatures1
|
||||||
}
|
}
|
||||||
@ -4168,7 +4168,7 @@ func (f *Manager) newChanAnnouncement(localPubKey,
|
|||||||
// The unconditional section of the announcement is the ShortChannelID
|
// The unconditional section of the announcement is the ShortChannelID
|
||||||
// itself which compactly encodes the location of the funding output
|
// itself which compactly encodes the location of the funding output
|
||||||
// within the blockchain.
|
// within the blockchain.
|
||||||
chanAnn := &lnwire.ChannelAnnouncement{
|
chanAnn := &lnwire.ChannelAnnouncement1{
|
||||||
ShortChannelID: shortChanID,
|
ShortChannelID: shortChanID,
|
||||||
Features: lnwire.NewRawFeatureVector(),
|
Features: lnwire.NewRawFeatureVector(),
|
||||||
ChainHash: chainHash,
|
ChainHash: chainHash,
|
||||||
|
@ -1208,7 +1208,7 @@ func assertChannelAnnouncements(t *testing.T, alice, bob *testNode,
|
|||||||
gotChannelUpdate := false
|
gotChannelUpdate := false
|
||||||
for _, msg := range announcements {
|
for _, msg := range announcements {
|
||||||
switch m := msg.(type) {
|
switch m := msg.(type) {
|
||||||
case *lnwire.ChannelAnnouncement:
|
case *lnwire.ChannelAnnouncement1:
|
||||||
gotChannelAnnouncement = true
|
gotChannelAnnouncement = true
|
||||||
case *lnwire.ChannelUpdate:
|
case *lnwire.ChannelUpdate:
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
// ValidateChannelAnn validates the channel announcement message and checks
|
// ValidateChannelAnn validates the channel announcement message and checks
|
||||||
// that node signatures covers the announcement message, and that the bitcoin
|
// that node signatures covers the announcement message, and that the bitcoin
|
||||||
// signatures covers the node keys.
|
// signatures covers the node keys.
|
||||||
func ValidateChannelAnn(a *lnwire.ChannelAnnouncement) error {
|
func ValidateChannelAnn(a *lnwire.ChannelAnnouncement1) error {
|
||||||
// First, we'll compute the digest (h) which is to be signed by each of
|
// First, we'll compute the digest (h) which is to be signed by each of
|
||||||
// the keys included within the node announcement message. This hash
|
// the keys included within the node announcement message. This hash
|
||||||
// digest includes all the keys, so the (up to 4 signatures) will
|
// digest includes all the keys, so the (up to 4 signatures) will
|
||||||
|
@ -102,7 +102,7 @@ func (v *ValidationBarrier) InitJobDependencies(job interface{}) {
|
|||||||
// ChannelUpdates for the same channel, or NodeAnnouncements of nodes
|
// ChannelUpdates for the same channel, or NodeAnnouncements of nodes
|
||||||
// that are involved in this channel. This goes for both the wire
|
// that are involved in this channel. This goes for both the wire
|
||||||
// type,s and also the types that we use within the database.
|
// type,s and also the types that we use within the database.
|
||||||
case *lnwire.ChannelAnnouncement:
|
case *lnwire.ChannelAnnouncement1:
|
||||||
|
|
||||||
// We ensure that we only create a new announcement signal iff,
|
// We ensure that we only create a new announcement signal iff,
|
||||||
// one doesn't already exist, as there may be duplicate
|
// one doesn't already exist, as there may be duplicate
|
||||||
@ -219,7 +219,7 @@ func (v *ValidationBarrier) WaitForDependants(job interface{}) error {
|
|||||||
case *lnwire.AnnounceSignatures1:
|
case *lnwire.AnnounceSignatures1:
|
||||||
// TODO(roasbeef): need to wait on chan ann?
|
// TODO(roasbeef): need to wait on chan ann?
|
||||||
case *models.ChannelEdgeInfo:
|
case *models.ChannelEdgeInfo:
|
||||||
case *lnwire.ChannelAnnouncement:
|
case *lnwire.ChannelAnnouncement1:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release the lock once the above read is finished.
|
// Release the lock once the above read is finished.
|
||||||
@ -275,7 +275,7 @@ func (v *ValidationBarrier) SignalDependants(job interface{}, allow bool) {
|
|||||||
}
|
}
|
||||||
delete(v.chanAnnFinSignal, shortID)
|
delete(v.chanAnnFinSignal, shortID)
|
||||||
}
|
}
|
||||||
case *lnwire.ChannelAnnouncement:
|
case *lnwire.ChannelAnnouncement1:
|
||||||
finSignals, ok := v.chanAnnFinSignal[msg.ShortChannelID]
|
finSignals, ok := v.chanAnnFinSignal[msg.ShortChannelID]
|
||||||
if ok {
|
if ok {
|
||||||
if allow {
|
if allow {
|
||||||
|
@ -73,9 +73,9 @@ func TestValidationBarrierQuit(t *testing.T) {
|
|||||||
|
|
||||||
// Create a set of unique channel announcements that we will prep for
|
// Create a set of unique channel announcements that we will prep for
|
||||||
// validation.
|
// validation.
|
||||||
anns := make([]*lnwire.ChannelAnnouncement, 0, numTasks)
|
anns := make([]*lnwire.ChannelAnnouncement1, 0, numTasks)
|
||||||
for i := 0; i < numTasks; i++ {
|
for i := 0; i < numTasks; i++ {
|
||||||
anns = append(anns, &lnwire.ChannelAnnouncement{
|
anns = append(anns, &lnwire.ChannelAnnouncement1{
|
||||||
ShortChannelID: lnwire.NewShortChanIDFromInt(uint64(i)),
|
ShortChannelID: lnwire.NewShortChanIDFromInt(uint64(i)),
|
||||||
NodeID1: nodeIDFromInt(uint64(2 * i)),
|
NodeID1: nodeIDFromInt(uint64(2 * i)),
|
||||||
NodeID2: nodeIDFromInt(uint64(2*i + 1)),
|
NodeID2: nodeIDFromInt(uint64(2*i + 1)),
|
||||||
|
@ -7,10 +7,10 @@ import (
|
|||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ChannelAnnouncement message is used to announce the existence of a channel
|
// ChannelAnnouncement1 message is used to announce the existence of a channel
|
||||||
// between two peers in the overlay, which is propagated by the discovery
|
// between two peers in the overlay, which is propagated by the discovery
|
||||||
// service over broadcast handler.
|
// service over broadcast handler.
|
||||||
type ChannelAnnouncement struct {
|
type ChannelAnnouncement1 struct {
|
||||||
// This signatures are used by nodes in order to create cross
|
// This signatures are used by nodes in order to create cross
|
||||||
// references between node's channel and node. Requiring both nodes
|
// references between node's channel and node. Requiring both nodes
|
||||||
// to sign indicates they are both willing to route other payments via
|
// to sign indicates they are both willing to route other payments via
|
||||||
@ -60,13 +60,13 @@ type ChannelAnnouncement struct {
|
|||||||
|
|
||||||
// A compile time check to ensure ChannelAnnouncement implements the
|
// A compile time check to ensure ChannelAnnouncement implements the
|
||||||
// lnwire.Message interface.
|
// lnwire.Message interface.
|
||||||
var _ Message = (*ChannelAnnouncement)(nil)
|
var _ Message = (*ChannelAnnouncement1)(nil)
|
||||||
|
|
||||||
// Decode deserializes a serialized ChannelAnnouncement stored in the passed
|
// Decode deserializes a serialized ChannelAnnouncement 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 *ChannelAnnouncement) Decode(r io.Reader, pver uint32) error {
|
func (a *ChannelAnnouncement1) Decode(r io.Reader, pver uint32) error {
|
||||||
return ReadElements(r,
|
return ReadElements(r,
|
||||||
&a.NodeSig1,
|
&a.NodeSig1,
|
||||||
&a.NodeSig2,
|
&a.NodeSig2,
|
||||||
@ -87,7 +87,7 @@ func (a *ChannelAnnouncement) 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 *ChannelAnnouncement) Encode(w *bytes.Buffer, pver uint32) error {
|
func (a *ChannelAnnouncement1) Encode(w *bytes.Buffer, pver uint32) error {
|
||||||
if err := WriteSig(w, a.NodeSig1); err != nil {
|
if err := WriteSig(w, a.NodeSig1); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -139,13 +139,13 @@ func (a *ChannelAnnouncement) 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 *ChannelAnnouncement) MsgType() MessageType {
|
func (a *ChannelAnnouncement1) MsgType() MessageType {
|
||||||
return MsgChannelAnnouncement
|
return MsgChannelAnnouncement
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 *ChannelAnnouncement) DataToSign() ([]byte, error) {
|
func (a *ChannelAnnouncement1) 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)
|
||||||
|
@ -979,7 +979,7 @@ func TestLightningWireProtocol(t *testing.T) {
|
|||||||
},
|
},
|
||||||
MsgChannelAnnouncement: func(v []reflect.Value, r *rand.Rand) {
|
MsgChannelAnnouncement: func(v []reflect.Value, r *rand.Rand) {
|
||||||
var err error
|
var err error
|
||||||
req := ChannelAnnouncement{
|
req := ChannelAnnouncement1{
|
||||||
ShortChannelID: NewShortChanIDFromInt(uint64(r.Int63())),
|
ShortChannelID: NewShortChanIDFromInt(uint64(r.Int63())),
|
||||||
Features: randRawFeatureVector(r),
|
Features: randRawFeatureVector(r),
|
||||||
ExtraOpaqueData: make([]byte, 0),
|
ExtraOpaqueData: make([]byte, 0),
|
||||||
@ -1631,7 +1631,7 @@ func TestLightningWireProtocol(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
msgType: MsgChannelAnnouncement,
|
msgType: MsgChannelAnnouncement,
|
||||||
scenario: func(m ChannelAnnouncement) bool {
|
scenario: func(m ChannelAnnouncement1) bool {
|
||||||
return mainScenario(&m)
|
return mainScenario(&m)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -259,7 +259,7 @@ func makeEmptyMessage(msgType MessageType) (Message, error) {
|
|||||||
case MsgError:
|
case MsgError:
|
||||||
msg = &Error{}
|
msg = &Error{}
|
||||||
case MsgChannelAnnouncement:
|
case MsgChannelAnnouncement:
|
||||||
msg = &ChannelAnnouncement{}
|
msg = &ChannelAnnouncement1{}
|
||||||
case MsgChannelUpdate:
|
case MsgChannelUpdate:
|
||||||
msg = &ChannelUpdate{}
|
msg = &ChannelUpdate{}
|
||||||
case MsgNodeAnnouncement:
|
case MsgNodeAnnouncement:
|
||||||
|
@ -645,11 +645,11 @@ func newMsgChannelReestablish(t testing.TB,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newMsgChannelAnnouncement(t testing.TB,
|
func newMsgChannelAnnouncement(t testing.TB,
|
||||||
r *rand.Rand) *lnwire.ChannelAnnouncement {
|
r *rand.Rand) *lnwire.ChannelAnnouncement1 {
|
||||||
|
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
msg := &lnwire.ChannelAnnouncement{
|
msg := &lnwire.ChannelAnnouncement1{
|
||||||
ShortChannelID: lnwire.NewShortChanIDFromInt(uint64(r.Int63())),
|
ShortChannelID: lnwire.NewShortChanIDFromInt(uint64(r.Int63())),
|
||||||
Features: rawFeatureVector(),
|
Features: rawFeatureVector(),
|
||||||
NodeID1: randRawKey(t),
|
NodeID1: randRawKey(t),
|
||||||
|
@ -14,14 +14,14 @@ import (
|
|||||||
// peer's initial routing table upon connect.
|
// peer's initial routing table upon connect.
|
||||||
func CreateChanAnnouncement(chanProof *models.ChannelAuthProof,
|
func CreateChanAnnouncement(chanProof *models.ChannelAuthProof,
|
||||||
chanInfo *models.ChannelEdgeInfo,
|
chanInfo *models.ChannelEdgeInfo,
|
||||||
e1, e2 *models.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement,
|
e1, e2 *models.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement1,
|
||||||
*lnwire.ChannelUpdate, *lnwire.ChannelUpdate, error) {
|
*lnwire.ChannelUpdate, *lnwire.ChannelUpdate, 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
|
||||||
// authenticated channel announcement.
|
// authenticated channel announcement.
|
||||||
chanID := lnwire.NewShortChanIDFromInt(chanInfo.ChannelID)
|
chanID := lnwire.NewShortChanIDFromInt(chanInfo.ChannelID)
|
||||||
chanAnn := &lnwire.ChannelAnnouncement{
|
chanAnn := &lnwire.ChannelAnnouncement1{
|
||||||
ShortChannelID: chanID,
|
ShortChannelID: chanID,
|
||||||
NodeID1: chanInfo.NodeKey1Bytes,
|
NodeID1: chanInfo.NodeKey1Bytes,
|
||||||
NodeID2: chanInfo.NodeKey2Bytes,
|
NodeID2: chanInfo.NodeKey2Bytes,
|
||||||
|
@ -24,7 +24,7 @@ func TestCreateChanAnnouncement(t *testing.T) {
|
|||||||
t.Fatalf("unable to encode features: %v", err)
|
t.Fatalf("unable to encode features: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
expChanAnn := &lnwire.ChannelAnnouncement{
|
expChanAnn := &lnwire.ChannelAnnouncement1{
|
||||||
ChainHash: chainhash.Hash{0x1},
|
ChainHash: chainhash.Hash{0x1},
|
||||||
ShortChannelID: lnwire.ShortChannelID{BlockHeight: 1},
|
ShortChannelID: lnwire.ShortChannelID{BlockHeight: 1},
|
||||||
NodeID1: key,
|
NodeID1: key,
|
||||||
|
@ -20,7 +20,7 @@ func SignAnnouncement(signer lnwallet.MessageSigner, keyLoc keychain.KeyLocator,
|
|||||||
)
|
)
|
||||||
|
|
||||||
switch m := msg.(type) {
|
switch m := msg.(type) {
|
||||||
case *lnwire.ChannelAnnouncement:
|
case *lnwire.ChannelAnnouncement1:
|
||||||
data, err = m.DataToSign()
|
data, err = m.DataToSign()
|
||||||
case *lnwire.ChannelUpdate:
|
case *lnwire.ChannelUpdate:
|
||||||
data, err = m.DataToSign()
|
data, err = m.DataToSign()
|
||||||
|
@ -1964,7 +1964,7 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
case *lnwire.ChannelUpdate,
|
case *lnwire.ChannelUpdate,
|
||||||
*lnwire.ChannelAnnouncement,
|
*lnwire.ChannelAnnouncement1,
|
||||||
*lnwire.NodeAnnouncement,
|
*lnwire.NodeAnnouncement,
|
||||||
*lnwire.AnnounceSignatures1,
|
*lnwire.AnnounceSignatures1,
|
||||||
*lnwire.GossipTimestampRange,
|
*lnwire.GossipTimestampRange,
|
||||||
@ -2229,7 +2229,7 @@ func messageSummary(msg lnwire.Message) string {
|
|||||||
return fmt.Sprintf("chan_id=%v, short_chan_id=%v", msg.ChannelID,
|
return fmt.Sprintf("chan_id=%v, short_chan_id=%v", msg.ChannelID,
|
||||||
msg.ShortChannelID.ToUint64())
|
msg.ShortChannelID.ToUint64())
|
||||||
|
|
||||||
case *lnwire.ChannelAnnouncement:
|
case *lnwire.ChannelAnnouncement1:
|
||||||
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())
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user