Merge pull request #1324 from Roasbeef/fix-routing-hint-panic
rpc: ensure we don't attempt to create a routing hint with a nil edge
This commit is contained in:
commit
3cb24e57cc
12
rpcserver.go
12
rpcserver.go
@ -2321,7 +2321,7 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
|
|||||||
|
|
||||||
// Fetch the policies for each end of the channel.
|
// Fetch the policies for each end of the channel.
|
||||||
chanID := channel.ShortChanID().ToUint64()
|
chanID := channel.ShortChanID().ToUint64()
|
||||||
_, p1, p2, err := graph.FetchChannelEdgesByID(chanID)
|
info, p1, p2, err := graph.FetchChannelEdgesByID(chanID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rpcsLog.Errorf("Unable to fetch the routing "+
|
rpcsLog.Errorf("Unable to fetch the routing "+
|
||||||
"policies for the edges of the channel "+
|
"policies for the edges of the channel "+
|
||||||
@ -2332,14 +2332,20 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
|
|||||||
// Now, we'll need to determine which is the correct
|
// Now, we'll need to determine which is the correct
|
||||||
// policy for HTLCs being sent from the remote node.
|
// policy for HTLCs being sent from the remote node.
|
||||||
var remotePolicy *channeldb.ChannelEdgePolicy
|
var remotePolicy *channeldb.ChannelEdgePolicy
|
||||||
|
|
||||||
remotePub := channel.IdentityPub.SerializeCompressed()
|
remotePub := channel.IdentityPub.SerializeCompressed()
|
||||||
if bytes.Equal(remotePub, p1.Node.PubKeyBytes[:]) {
|
if bytes.Equal(remotePub, info.NodeKey1Bytes[:]) {
|
||||||
remotePolicy = p1
|
remotePolicy = p1
|
||||||
} else {
|
} else {
|
||||||
remotePolicy = p2
|
remotePolicy = p2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If for some reason we don't yet have the edge for
|
||||||
|
// the remote party, then we'll just skip adding this
|
||||||
|
// channel as a routing hint.
|
||||||
|
if remotePolicy == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Finally, create the routing hint for this channel and
|
// Finally, create the routing hint for this channel and
|
||||||
// add it to our list of route hints.
|
// add it to our list of route hints.
|
||||||
hint := routing.HopHint{
|
hint := routing.HopHint{
|
||||||
|
Loading…
Reference in New Issue
Block a user