Can a Bitcoin node create an outgoing connection to a inbound node?

by Jan Telov   Last Updated May 15, 2019 12:27 PM

I'm trying to figure out if we can create an outgoing connection to a inbound node (a node which we are already connected to, but the remote peer has initiated the connection). I know that this does not make much sense since we exchange information to inbound and outbound nodes. However, I have looked at the source code and did not find the code that prevents a node from doing that. Is anyone out there more successful?

Answers 1

There’s explicit logic to prevent this, namely a nonce in the connection handshake that is used to detect if a connection is to yourself, even if on a different interface or via a proxy.

    // Disconnect if we connected to ourself

    if (pfrom->fInbound && !connman->CheckIncomingNonce(nNonce))


        LogPrintf("connected to self at %s, disconnecting\n", pfrom->addr.ToString());

        pfrom->fDisconnect = true;

        return true;


May 15, 2019 12:16 PM

Related Questions

Updated April 06, 2018 14:27 PM

Updated April 27, 2018 03:27 AM

Updated November 23, 2017 19:27 PM

Updated July 06, 2017 00:27 AM