From c1f9c56e5b5a2ebfb6013b4dd0644db97472103e Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Mon, 30 Mar 2020 15:15:15 -0700 Subject: [PATCH] rpcserver: add self-node check in OpenChannelSync --- rpcserver.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rpcserver.go b/rpcserver.go index f9753bbb..5ff15de2 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -1867,6 +1867,12 @@ func (r *rpcServer) OpenChannelSync(ctx context.Context, } } + // Making a channel to ourselves wouldn't be of any use, so we + // explicitly disallow them. + if nodePubKey.IsEqual(r.server.identityPriv.PubKey()) { + return nil, fmt.Errorf("cannot open channel to self") + } + localFundingAmt := btcutil.Amount(in.LocalFundingAmount) remoteInitialBalance := btcutil.Amount(in.PushSat) minHtlcIn := lnwire.MilliSatoshi(in.MinHtlcMsat)