discovery+funding: update wire message usage to latest API changes
This commit is contained in:
parent
08a95ead6a
commit
0ab1c47d31
@ -369,7 +369,7 @@ func (d *AuthenticatedGossiper) networkHandler() {
|
|||||||
// Iterate over our channels and construct the
|
// Iterate over our channels and construct the
|
||||||
// announcements array.
|
// announcements array.
|
||||||
err := d.cfg.Router.ForAllOutgoingChannels(func(p *channeldb.ChannelEdgePolicy) error {
|
err := d.cfg.Router.ForAllOutgoingChannels(func(p *channeldb.ChannelEdgePolicy) error {
|
||||||
c := &lnwire.ChannelUpdateAnnouncement{
|
c := &lnwire.ChannelUpdate{
|
||||||
Signature: p.Signature,
|
Signature: p.Signature,
|
||||||
ShortChannelID: lnwire.NewShortChanIDFromInt(p.ChannelID),
|
ShortChannelID: lnwire.NewShortChanIDFromInt(p.ChannelID),
|
||||||
Timestamp: uint32(p.LastUpdate.Unix()),
|
Timestamp: uint32(p.LastUpdate.Unix()),
|
||||||
@ -561,7 +561,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(nMsg *networkMsg) []l
|
|||||||
// A new authenticated channel edge update has arrived. This indicates
|
// A new authenticated channel edge update has arrived. This indicates
|
||||||
// that the directional information for an already known channel has
|
// that the directional information for an already known channel has
|
||||||
// been updated.
|
// been updated.
|
||||||
case *lnwire.ChannelUpdateAnnouncement:
|
case *lnwire.ChannelUpdate:
|
||||||
blockHeight := msg.ShortChannelID.BlockHeight
|
blockHeight := msg.ShortChannelID.BlockHeight
|
||||||
shortChanID := msg.ShortChannelID.ToUint64()
|
shortChanID := msg.ShortChannelID.ToUint64()
|
||||||
|
|
||||||
@ -662,8 +662,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(nMsg *networkMsg) []l
|
|||||||
prefix = "remote"
|
prefix = "remote"
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("Received new channel announcement: %v",
|
log.Infof("Received new channel announcement: %v", spew.Sdump(msg))
|
||||||
spew.Sdump(msg))
|
|
||||||
|
|
||||||
// By the specification, channel announcement proofs should be
|
// By the specification, channel announcement proofs should be
|
||||||
// sent after some number of confirmations after channel was
|
// sent after some number of confirmations after channel was
|
||||||
@ -721,7 +720,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(nMsg *networkMsg) []l
|
|||||||
key := newProofKey(chanInfo.ChannelID, nMsg.isRemote)
|
key := newProofKey(chanInfo.ChannelID, nMsg.isRemote)
|
||||||
d.waitingProofs[key] = msg
|
d.waitingProofs[key] = msg
|
||||||
|
|
||||||
// If proof was sent b a local sub-system, then we'll
|
// If proof was sent by a local sub-system, then we'll
|
||||||
// send the announcement signature to the remote node
|
// send the announcement signature to the remote node
|
||||||
// so they can also reconstruct the full channel
|
// so they can also reconstruct the full channel
|
||||||
// announcement.
|
// announcement.
|
||||||
@ -863,17 +862,12 @@ func (d *AuthenticatedGossiper) synchronizeWithNode(syncReq *syncRequest) error
|
|||||||
// for the announcement we originally retrieved.
|
// for the announcement we originally retrieved.
|
||||||
var numNodes uint32
|
var numNodes uint32
|
||||||
if err := d.cfg.Router.ForEachNode(func(node *channeldb.LightningNode) error {
|
if err := d.cfg.Router.ForEachNode(func(node *channeldb.LightningNode) error {
|
||||||
alias, err := lnwire.NewAlias(node.Alias)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
ann := &lnwire.NodeAnnouncement{
|
ann := &lnwire.NodeAnnouncement{
|
||||||
Signature: node.AuthSig,
|
Signature: node.AuthSig,
|
||||||
Timestamp: uint32(node.LastUpdate.Unix()),
|
Timestamp: uint32(node.LastUpdate.Unix()),
|
||||||
Addresses: node.Addresses,
|
Addresses: node.Addresses,
|
||||||
NodeID: node.PubKey,
|
NodeID: node.PubKey,
|
||||||
Alias: alias,
|
Alias: lnwire.NewAlias(node.Alias),
|
||||||
Features: node.Features,
|
Features: node.Features,
|
||||||
}
|
}
|
||||||
announceMessages = append(announceMessages, ann)
|
announceMessages = append(announceMessages, ann)
|
||||||
|
@ -43,7 +43,7 @@ func (k waitingProofKey) ToBytes() []byte {
|
|||||||
func createChanAnnouncement(chanProof *channeldb.ChannelAuthProof,
|
func createChanAnnouncement(chanProof *channeldb.ChannelAuthProof,
|
||||||
chanInfo *channeldb.ChannelEdgeInfo,
|
chanInfo *channeldb.ChannelEdgeInfo,
|
||||||
e1, e2 *channeldb.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement,
|
e1, e2 *channeldb.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement,
|
||||||
*lnwire.ChannelUpdateAnnouncement, *lnwire.ChannelUpdateAnnouncement) {
|
*lnwire.ChannelUpdate, *lnwire.ChannelUpdate) {
|
||||||
|
|
||||||
// First, using the parameters of the channel, along with the channel
|
// First, using the parameters of the channel, along with the channel
|
||||||
// authentication chanProof, we'll create re-create the original
|
// authentication chanProof, we'll create re-create the original
|
||||||
@ -68,9 +68,9 @@ func createChanAnnouncement(chanProof *channeldb.ChannelAuthProof,
|
|||||||
// Since it's up to a node's policy as to whether they advertise the
|
// Since it's up to a node's policy as to whether they advertise the
|
||||||
// edge in dire direction, we don't create an advertisement if the edge
|
// edge in dire direction, we don't create an advertisement if the edge
|
||||||
// is nil.
|
// is nil.
|
||||||
var edge1Ann, edge2Ann *lnwire.ChannelUpdateAnnouncement
|
var edge1Ann, edge2Ann *lnwire.ChannelUpdate
|
||||||
if e1 != nil {
|
if e1 != nil {
|
||||||
edge1Ann = &lnwire.ChannelUpdateAnnouncement{
|
edge1Ann = &lnwire.ChannelUpdate{
|
||||||
Signature: e1.Signature,
|
Signature: e1.Signature,
|
||||||
ShortChannelID: chanID,
|
ShortChannelID: chanID,
|
||||||
Timestamp: uint32(e1.LastUpdate.Unix()),
|
Timestamp: uint32(e1.LastUpdate.Unix()),
|
||||||
@ -82,7 +82,7 @@ func createChanAnnouncement(chanProof *channeldb.ChannelAuthProof,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if e2 != nil {
|
if e2 != nil {
|
||||||
edge2Ann = &lnwire.ChannelUpdateAnnouncement{
|
edge2Ann = &lnwire.ChannelUpdate{
|
||||||
Signature: e2.Signature,
|
Signature: e2.Signature,
|
||||||
ShortChannelID: chanID,
|
ShortChannelID: chanID,
|
||||||
Timestamp: uint32(e2.LastUpdate.Unix()),
|
Timestamp: uint32(e2.LastUpdate.Unix()),
|
||||||
@ -120,7 +120,7 @@ func SignAnnouncement(signer lnwallet.MessageSigner, pubKey *btcec.PublicKey,
|
|||||||
switch m := msg.(type) {
|
switch m := msg.(type) {
|
||||||
case *lnwire.ChannelAnnouncement:
|
case *lnwire.ChannelAnnouncement:
|
||||||
data, err = m.DataToSign()
|
data, err = m.DataToSign()
|
||||||
case *lnwire.ChannelUpdateAnnouncement:
|
case *lnwire.ChannelUpdate:
|
||||||
data, err = m.DataToSign()
|
data, err = m.DataToSign()
|
||||||
case *lnwire.NodeAnnouncement:
|
case *lnwire.NodeAnnouncement:
|
||||||
data, err = m.DataToSign()
|
data, err = m.DataToSign()
|
||||||
|
@ -72,7 +72,7 @@ func (d *AuthenticatedGossiper) validateNodeAnn(a *lnwire.NodeAnnouncement) erro
|
|||||||
// checking that the included signature covers he announcement and has been
|
// checking that the included signature covers he announcement and has been
|
||||||
// signed by the node's private key.
|
// signed by the node's private key.
|
||||||
func (d *AuthenticatedGossiper) validateChannelUpdateAnn(pubKey *btcec.PublicKey,
|
func (d *AuthenticatedGossiper) validateChannelUpdateAnn(pubKey *btcec.PublicKey,
|
||||||
a *lnwire.ChannelUpdateAnnouncement) error {
|
a *lnwire.ChannelUpdate) error {
|
||||||
|
|
||||||
data, err := a.DataToSign()
|
data, err := a.DataToSign()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1051,7 +1051,7 @@ type channelProof struct {
|
|||||||
// 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.ChannelAnnouncement
|
||||||
chanUpdateAnn *lnwire.ChannelUpdateAnnouncement
|
chanUpdateAnn *lnwire.ChannelUpdate
|
||||||
chanProof *lnwire.AnnounceSignatures
|
chanProof *lnwire.AnnounceSignatures
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1107,7 +1107,7 @@ func (f *fundingManager) newChanAnnouncement(localPubKey, remotePubKey *btcec.Pu
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO(roasbeef): populate proper FeeSchema
|
// TODO(roasbeef): populate proper FeeSchema
|
||||||
chanUpdateAnn := &lnwire.ChannelUpdateAnnouncement{
|
chanUpdateAnn := &lnwire.ChannelUpdate{
|
||||||
ShortChannelID: shortChanID,
|
ShortChannelID: shortChanID,
|
||||||
Timestamp: uint32(time.Now().Unix()),
|
Timestamp: uint32(time.Now().Unix()),
|
||||||
Flags: chanFlags,
|
Flags: chanFlags,
|
||||||
|
Loading…
Reference in New Issue
Block a user