rpcserver: fix potential panic when opening channel to peer_id
This commit fixes a potential panic that could arise when one was attempting to open a channel with the target peer identified by it’s peerID and an error occurred. In this case, the nodepubKey pointer would be nil, resulting in a panic when attempting to propagate the error. This commit fixes this bug by using a nil byte slice for the node’s serialized pubkey in the case that the node was identified according to ti’s peer ID.
This commit is contained in:
parent
24a569b047
commit
3f6afa51b9
@ -259,6 +259,7 @@ func (r *rpcServer) OpenChannel(in *lnrpc.OpenChannelRequest,
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
nodepubKey *btcec.PublicKey
|
nodepubKey *btcec.PublicKey
|
||||||
|
nodepubKeyBytes []byte
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -270,6 +271,7 @@ func (r *rpcServer) OpenChannel(in *lnrpc.OpenChannelRequest,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
nodepubKeyBytes = nodepubKey.SerializeCompressed()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Instruct the server to trigger the necessary events to attempt to
|
// Instruct the server to trigger the necessary events to attempt to
|
||||||
@ -285,8 +287,7 @@ out:
|
|||||||
case err := <-errChan:
|
case err := <-errChan:
|
||||||
rpcsLog.Errorf("unable to open channel to "+
|
rpcsLog.Errorf("unable to open channel to "+
|
||||||
"identityPub(%x) nor peerID(%v): %v",
|
"identityPub(%x) nor peerID(%v): %v",
|
||||||
nodepubKey.SerializeCompressed(),
|
nodepubKeyBytes, in.TargetPeerId, err)
|
||||||
in.TargetPeerId, err)
|
|
||||||
return err
|
return err
|
||||||
case fundingUpdate := <-updateChan:
|
case fundingUpdate := <-updateChan:
|
||||||
rpcsLog.Tracef("[openchannel] sending update: %v",
|
rpcsLog.Tracef("[openchannel] sending update: %v",
|
||||||
@ -426,6 +427,8 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
|||||||
// As the first part of the force closure, we first fetch the
|
// As the first part of the force closure, we first fetch the
|
||||||
// channel from the database, then execute a direct force
|
// channel from the database, then execute a direct force
|
||||||
// closure broadcasting our current commitment transaction.
|
// closure broadcasting our current commitment transaction.
|
||||||
|
// TODO(roasbeef): d/c peer if connected?
|
||||||
|
// * otherwise safety no guaranteed
|
||||||
channel, err := r.fetchActiveChannel(*chanPoint)
|
channel, err := r.fetchActiveChannel(*chanPoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user