<p><code>CAddress</code> is serialized differently for different purposes. When serialized to disk, the node version and the time are serialized. This is because this information is relevant to the address manager.</p>
<p>However, when serializing to be sent to another node, both the version and the time are omitted because they aren't necessary. These aren't being sent to other nodes, just the IP address and port themselves. You can see that these are skipped for non-disk operations because it is doing <code>if (s.GetType() &amp; SER_DISK)</code> before the <code>READWRITE</code> (which indicates de/serialization) for both <code>nVersion</code> and <code>nTime</code>.</p>
<p>The output you see is because <code>addrMe</code> and <code>addrFrom</code> are local variables which don't need to have the correct version and time. So the version used is the version for the stream which is the minimum protocol version (this is just a safety thing to ensure compatibility). The time is the default minimum time. Since these values don't matter, using these defaults is okay.</p>

CC BY-SA 4.0
2020-07-08T02:38:55.377Z
2020-07-08T02:38:55.377Z
Ava Chow
<p>Why does Bitcoin use INIT_PROTO_VERSION (209) in the addrme and addryou message of the Version Message? Why is it not using the nodes protocolVersion which had been advertised in the same Message.</p>
<p>This is part why the nTime from the node in the Version Message will be ignored</p>
<p>Code used for Debug in protocol.h</p>
<pre><code>   SERIALIZE_METHODS(CAddress, obj)
    {
        SER_READ(obj, obj.nTime = TIME_INIT);
        int nVersion = s.GetVersion();
        if (s.GetType() &amp; SER_DISK) {
            printf(&quot;nVersion %d\n&quot;, nVersion);
            READWRITE(nVersion);
        } else {
            printf(&quot;Not evaluated nVersion %d Type %d\n&quot;, nVersion, s.GetType());
        }
        if ((s.GetType() &amp; SER_DISK) ||
            (nVersion &gt;= CADDR_TIME_VERSION &amp;&amp; !(s.GetType() &amp; SER_GETHASH))) {
            READWRITE(obj.nTime);
            printf(&quot;nTime %d\n&quot;, obj.nTime);
        } else {
            printf(&quot;Not evaluated nTime %d\n&quot;, obj.nTime);
        }
        READWRITE(Using&lt;CustomUintFormatter&lt;8&gt;&gt;(obj.nServices));
        printf(&quot;nServicesInt %d\n&quot;, obj.nServices);
        READWRITEAS(CService, obj);
    }
</code></pre>
<p>See below the Output</p>
<p>BTC's</p>
<pre><code>Receive addrMe
Not evaluated nVersion 209 Type 1
Not evaluated nTime 100000000
nServicesInt 0
Receive addrFrom
Not evaluated nVersion 209 Type 1
Not evaluated nTime 100000000
nServicesInt 1033
2020-07-07T01:35:08Z New outbound peer connected: version: 70015, blocks=638069, peer=1 (full-relay)
</code></pre>
<p>Is this a wanted behavior?</p>

CC BY-SA 4.0
2020-07-08T02:31:55.767Z
Where did the CAddress that you deserialize in that output come from?
Ava Chow
<bitcoin-core>
Why does bitcoin uses INIT_PROTO_VERSION (209) for addrme and addryou in the Version Message
Aviator
# Why does bitcoin uses INIT_PROTO_VERSION (209) for addrme and addryou in the Version Message

(Asked by: username_0 on 2020-07-08)

Why does Bitcoin use INIT\_PROTO\_VERSION (209) in the addrme and addryou message of the Version Message? Why is it not using the nodes protocolVersion which had been advertised in the same Message.

This is part why the nTime from the node in the Version Message will be ignored

Code used for Debug in protocol.h

```
   SERIALIZE_METHODS(CAddress, obj)
    {
        SER_READ(obj, obj.nTime = TIME_INIT);
        int nVersion = s.GetVersion();
        if (s.GetType() & SER_DISK) {
            printf("nVersion %d\n", nVersion);
            READWRITE(nVersion);
        } else {
            printf("Not evaluated nVersion %d Type %d\n", nVersion, s.GetType());
        }
        if ((s.GetType() & SER_DISK) ||
            (nVersion >= CADDR_TIME_VERSION && !(s.GetType() & SER_GETHASH))) {
            READWRITE(obj.nTime);
            printf("nTime %d\n", obj.nTime);
        } else {
            printf("Not evaluated nTime %d\n", obj.nTime);
        }
        READWRITE(Using<CustomUintFormatter<8>>(obj.nServices));
        printf("nServicesInt %d\n", obj.nServices);
        READWRITEAS(CService, obj);
    }

```

See below the Output

BTC's

```
Receive addrMe
Not evaluated nVersion 209 Type 1
Not evaluated nTime 100000000
nServicesInt 0
Receive addrFrom
Not evaluated nVersion 209 Type 1
Not evaluated nTime 100000000
nServicesInt 1033
2020-07-07T01:35:08Z New outbound peer connected: version: 70015, blocks=638069, peer=1 (full-relay)

```

Is this a wanted behavior?

**Tags:** bitcoin-core

> **Comments:**
> **username_1**: Where did the CAddress that you deserialize in that output come from?  

---

## 1 answers

### Answer by username_1 on 2020-07-08. Score: 1

`CAddress` is serialized differently for different purposes. When serialized to disk, the node version and the time are serialized. This is because this information is relevant to the address manager.

However, when serializing to be sent to another node, both the version and the time are omitted because they aren't necessary. These aren't being sent to other nodes, just the IP address and port themselves. You can see that these are skipped for non-disk operations because it is doing `if (s.GetType() & SER_DISK)` before the `READWRITE` (which indicates de/serialization) for both `nVersion` and `nTime`.

The output you see is because `addrMe` and `addrFrom` are local variables which don't need to have the correct version and time. So the version used is the version for the stream which is the minimum protocol version (this is just a safety thing to ensure compatibility). The time is the default minimum time. Since these values don't matter, using these defaults is okay.


---

