Expected behavior
addnode
should not open a second connection even if the destination port is different for I2P nodes.
Actual behavior
A second connection is being opened even though ports are irrelevant and we actually connect to the same node two times.
To reproduce
0# Set up two I2P nodes A and B.
1
2node_a$ bitcoin-cli addnode bbb.b32.i2p:8333 onetry
3# If we would try the same again it would not open a second connection,
4# but trying on a different port does.
5node_a$ bitcoin-cli addnode bbb.b32.i2p:8833 onetry # notice it is different port
6node_a$ bitcoin-cli getpeerinfo |jq 'map(select(.network == "i2p")) |map({inbound: .inbound, addr: .addr, addrbind: .addrbind})'
7[
8 {
9 "inbound": false,
10 "addr": "bbb.b32.i2p:8333",
11 "addrbind": "aaa.b32.i2p:8333"
12 },
13 {
14 "inbound": false,
15 "addr": "bbb.b32.i2p:8833",
16 "addrbind": "aaa.b32.i2p:8333"
17 }
18]
19
20# Both connections are established, but in I2P ports are ignored,
21# so we actually connected two times to the same node.
22
23# This is how it looks on the B's end:
24
25node_b$ bitcoin-cli getpeerinfo |jq 'map(select(.network == "i2p")) |map({inbound: .inbound, addr: .addr, addrbind: .addrbind})'
26[
27 {
28 "inbound": true,
29 "addr": "aaa.b32.i2p:8333",
30 "addrbind": "bbb.b32.i2p:8333"
31 },
32 {
33 "inbound": true,
34 "addr": "aaa.b32.i2p:8333",
35 "addrbind": "bbb.b32.i2p:8333"
36 }
37]