lnd: fully integrate the ChannelRouter of the new routing package
This commit fully integrates the ChannelRouter of the new routing package into the main lnd daemon. A number of changes have been made to properly support the new authenticated gossiping scheme. Two new messages have been added to the server which allow outside services to: send a message to all peers possible excluding one, and send a series of messages to a single peer. These two new capabilities are used by the ChannelRouter to gossip new accepted announcements and also to synchronize graph state with a new peer on initial connect. The switch no longer needs a pointer to the routing state machine as it no longer needs to report when channels closed since the channel closures will be detected by the ChannelRouter during graph pruning when a new block comes in. Finally, the funding manager now crafts the proper authenticated announcement to send to the ChannelRouter once a new channel has bene fully confirmed. As a place holder we have fake signatures everywhere since we don’t properly store the funding keys and haven’t yet adapted the Signer interface (or create a new one) that abstracts out the process of signing a generic interface.
This commit is contained in:
5 files changed
+391
-171
No files matched your search
@@ -19,7 +19,6 @@ import (
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/rt/graph"
|
||||
"github.com/roasbeef/btcd/btcec"
|
||||
"github.com/roasbeef/btcd/txscript"
|
||||
"github.com/roasbeef/btcd/wire"
|
||||
@@ -233,17 +232,7 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error {
|
||||
|
||||
peerLog.Infof("peerID(%v) loaded ChannelPoint(%v)", p.id, chanPoint)
|
||||
|
||||
// Notify the routing table of this newly loaded channel.
|
||||
chanInfo := lnChan.StateSnapshot()
|
||||
capacity := int64(chanInfo.LocalBalance + chanInfo.RemoteBalance)
|
||||
pubSerialized := p.addr.IdentityKey.SerializeCompressed()
|
||||
p.server.routingMgr.OpenChannel(
|
||||
graph.NewVertex(pubSerialized),
|
||||
graph.NewEdgeID(*chanInfo.ChannelPoint),
|
||||
&graph.ChannelInfo{
|
||||
Cpt: capacity,
|
||||
},
|
||||
)
|
||||
// TODO(roasbeef): register active channel with breach observer
|
||||
|
||||
// Register this new channel link with the HTLC Switch. This is
|
||||
// necessary to properly route multi-hop payments, and forward
|
||||
@@ -379,7 +368,6 @@ out:
|
||||
case *lnwire.Ping:
|
||||
p.queueMsg(lnwire.NewPong(msg.Nonce), nil)
|
||||
|
||||
// TODO(roasbeef): consolidate into predicate (single vs dual)
|
||||
case *lnwire.SingleFundingRequest:
|
||||
p.server.fundingMgr.processFundingRequest(msg, p)
|
||||
case *lnwire.SingleFundingResponse:
|
||||
@@ -392,11 +380,10 @@ out:
|
||||
p.server.fundingMgr.processFundingOpenProof(msg, p)
|
||||
case *lnwire.CloseRequest:
|
||||
p.remoteCloseChanReqs <- msg
|
||||
// TODO(roasbeef): interface for htlc update msgs
|
||||
// * .(CommitmentUpdater)
|
||||
|
||||
case *lnwire.ErrorGeneric:
|
||||
p.server.fundingMgr.processErrorGeneric(msg, p)
|
||||
|
||||
case *lnwire.HTLCAddRequest:
|
||||
isChanUpdate = true
|
||||
targetChan = msg.ChannelPoint
|
||||
@@ -409,14 +396,13 @@ out:
|
||||
case *lnwire.CommitSignature:
|
||||
isChanUpdate = true
|
||||
targetChan = msg.ChannelPoint
|
||||
case *lnwire.NeighborAckMessage,
|
||||
*lnwire.NeighborHelloMessage,
|
||||
*lnwire.NeighborRstMessage,
|
||||
*lnwire.NeighborUpdMessage:
|
||||
|
||||
// Convert to base routing message and set sender and receiver
|
||||
vertex := p.addr.IdentityKey.SerializeCompressed()
|
||||
p.server.routingMgr.ReceiveRoutingMessage(msg, graph.NewVertex(vertex))
|
||||
case *lnwire.NodeAnnouncement,
|
||||
*lnwire.ChannelAnnouncement,
|
||||
*lnwire.ChannelUpdateAnnouncement:
|
||||
|
||||
p.server.chanRouter.ProcessRoutingMessage(msg,
|
||||
p.addr.IdentityKey)
|
||||
}
|
||||
|
||||
if isChanUpdate {
|
||||
|
||||
Reference in new issue
Block a user