<p>A reachable Bitcoin Core node self-advertises its own address regularly so other nodes can know about it and connect to it. In order to do that, it must know the address(es) under which it is reachable.</p>
<p>There exists discovery logic that attempts to detect the address under which a node is reachable, but it doesn't work perfectly under all local network conditions, and sometimes it can yield multiple results, leading to the question which one is the &quot;best&quot; that should be used.</p>
<p>This is where <code>addr_recv</code> comes in - it is used in the logic to decide which address should be advertised.</p>
<ol>
<li><p>Occasionally (rng-based), a node advertises the address they see us under back to the peer, instead of using one of our self-detected addresses (see <a href="https://github.com/bitcoin/bitcoin/blob/4b1196a9855dcd188a24f393aa2fa21e2d61f061/src/net.cpp#L237-L270" rel="nofollow noreferrer">GetLocalAddrForPeer</a>)</p>
</li>
<li><p><code>addr_recv</code> is used in a scoring mechanism to &quot;vote&quot; for one of the previously self-detected addressess (see <a href="https://github.com/bitcoin/bitcoin/blob/4b1196a9855dcd188a24f393aa2fa21e2d61f061/src/net.cpp#L313-L321" rel="nofollow noreferrer">SeenLocal</a>). This increases the probability of this address being picked for self-advertisements in the future - for all peers.</p>
</li>
</ol>
<p>However, <code>addr_recv</code> cannot be trusted and could be easily manipulated by a malicious peer.
Therefore, <code>addr_recv</code> received from one peer is never used in an advertisement to a different peer. If an attacker would send an incorrect address in that field, all they would achieve is to get that incorrect address relayed back to themselves occasionally (see point 1 above). They wouldn't impact the voting mechanism of point 2 because the incorrect address wouldn't be among the self-detected addresses.</p>

CC BY-SA 4.0
2023-12-28T16:53:57.407Z
2023-12-28T16:53:57.407Z
Lightlike
<p>I found <a href="https://bitcoin.stackexchange.com/a/73451/143602">here</a> the purposes of addr_recv and addr_from.</p>
<blockquote>
<p>Bitcoin Core actually ignores <code>addr_from</code> in received version messages.
<code>addr_recv</code> is used to influence the heuristic that determines which of
the receiving node's IP addresses is publicly reachable.</p>
</blockquote>
<p>However, I can't figure out this what is written for <code>addr_recv</code>.</p>
<p>Can someone explain the purpose of <code>addr_recv</code> in more detail? How does addr_recv influences the heuristic for determining which of the receiving nodes IP is public?</p>

<network><protocol>
What is the purpose of addr_recv? What does it mean that addr_recv influences the heuristic for determining which of the receiving nodes IP is public?
Qwerty M3
# What is the purpose of addr_recv? What does it mean that addr_recv influences the heuristic for determining which of the receiving nodes IP is public?

(Asked by: username_0 on 2023-12-26)

I found [here](https://bitcoin.stackexchange.com/a/73451/143602) the purposes of addr\_recv and addr\_from.

> Bitcoin Core actually ignores `addr_from` in received version messages.
> `addr_recv` is used to influence the heuristic that determines which of
> the receiving node's IP addresses is publicly reachable.

However, I can't figure out this what is written for `addr_recv`.

Can someone explain the purpose of `addr_recv` in more detail? How does addr\_recv influences the heuristic for determining which of the receiving nodes IP is public?

**Tags:** network, protocol


---

## 1 answers

### Answer by username_1 on 2023-12-28. Score: 3 | Accepted answer

A reachable Bitcoin Core node self-advertises its own address regularly so other nodes can know about it and connect to it. In order to do that, it must know the address(es) under which it is reachable.

There exists discovery logic that attempts to detect the address under which a node is reachable, but it doesn't work perfectly under all local network conditions, and sometimes it can yield multiple results, leading to the question which one is the "best" that should be used.

This is where `addr_recv` comes in - it is used in the logic to decide which address should be advertised.

1. Occasionally (rng-based), a node advertises the address they see us under back to the peer, instead of using one of our self-detected addresses (see [GetLocalAddrForPeer](https://github.com/bitcoin/bitcoin/blob/4b1196a9855dcd188a24f393aa2fa21e2d61f061/src/net.cpp#L237-L270))
2. `addr_recv` is used in a scoring mechanism to "vote" for one of the previously self-detected addressess (see [SeenLocal](https://github.com/bitcoin/bitcoin/blob/4b1196a9855dcd188a24f393aa2fa21e2d61f061/src/net.cpp#L313-L321)). This increases the probability of this address being picked for self-advertisements in the future - for all peers.

However, `addr_recv` cannot be trusted and could be easily manipulated by a malicious peer.
Therefore, `addr_recv` received from one peer is never used in an advertisement to a different peer. If an attacker would send an incorrect address in that field, all they would achieve is to get that incorrect address relayed back to themselves occasionally (see point 1 above). They wouldn't impact the voting mechanism of point 2 because the incorrect address wouldn't be among the self-detected addresses.


---

