1

According to the Bitcoin core developer reference, the RPC call getPeerInfo has in its output a field called "addrlocal" which holds our IP from the worldview of the peer.

Why is this output there? Is it used anywhere? Does it have a use case?

Furthermore, they commented that "Most SPV nodes set this to 127.0.0.1:8333", why would an SPV node do that?

2 Answers 2

2

Why is this output there?

Because it is part of the version P2P message. getpeerinfo largely outputs the information provided by the version message.

Is it used anywhere? Does it have a use case?

Currently, no. However it may have been included in the version message because Bitcoin was originally designed for things to go directly to IP addresses. There used to be a Pay-to-IP thing where this could have been useful.

Furthermore, they commented that "Most SPV nodes set this to 127.0.0.1:8333", why would an SPV node do that?

Because it is easier to implement and no one actually uses it.

0
0

Why is this output there?

It is sent to the Bitcoin node by its peers in their version P2P messages.

Is it used anywhere? Does it have a use case?

Yes. Foremost, it is used in Bitcoin's P2P networking. When a node wishes to accept incoming Bitcoin network connections over the Internet but doesn't know its own IP address on the Internet, it can use the addrLocal reported by an outbound peer to discover what IP address the outbound peer sees this node's connection coming from. If this IP address is within valid Internet ranges, this node may then advertise this IP for future incoming connections. In Bitcoin Core, this discovery behavior is enabled or disabled by supplying the -discover option to bitcoind or bitcoin-qt.

addrLocal can also be used by applications that receive the information via the getPeerInfo RPC procedure you mention. If an application is wanting to make its own decisions about what IP address to advertise for a node, such as for a website, it can include this peer-supplied data in its decision. An application might also wish to determine how a peer connected to a node when this node offers multiple routes for peers to connect (e.g. via NAT, reverse proxies, forward proxies, tunnels, anonymizers, etc.)

Furthermore, they commented that "Most SPV nodes set this to 127.0.0.1:8333", why would an SPV node do that?

Either because the SPV node is actually running and connected locally or because the SPV node has lied. A use-case for any type of node lying might be the developer leaving in a placeholder value while they haven't finished implementing the network protocol's requirements fully, or if the connecting node wishes to obscure what route it took to connect to this node when there are multiple options available.

The "most SPV nodes" wording has largely been removed from documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.