mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
rpc: add network field to rpc getnodeaddresses
This commit is contained in:
parent
ad4bf8a945
commit
3bb6e7b655
3 changed files with 7 additions and 1 deletions
|
@ -126,6 +126,9 @@ Changes to Wallet or GUI related settings can be found in the GUI or Wallet sect
|
||||||
|
|
||||||
- Passing an invalid `-rpcauth` argument now cause bitcoind to fail to start. (#20461)
|
- Passing an invalid `-rpcauth` argument now cause bitcoind to fail to start. (#20461)
|
||||||
|
|
||||||
|
- The `getnodeaddresses` RPC now returns a "network" field indicating the
|
||||||
|
network type (ipv4, ipv6, onion, or i2p) for each address. (#21594)
|
||||||
|
|
||||||
Tools and Utilities
|
Tools and Utilities
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
|
|
@ -848,6 +848,7 @@ static RPCHelpMan getnodeaddresses()
|
||||||
{RPCResult::Type::NUM, "services", "The services offered"},
|
{RPCResult::Type::NUM, "services", "The services offered"},
|
||||||
{RPCResult::Type::STR, "address", "The address of the node"},
|
{RPCResult::Type::STR, "address", "The address of the node"},
|
||||||
{RPCResult::Type::NUM, "port", "The port of the node"},
|
{RPCResult::Type::NUM, "port", "The port of the node"},
|
||||||
|
{RPCResult::Type::STR, "network", "The network (" + Join(GetNetworkNames(), ", ") + ") the node connected through"},
|
||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -879,6 +880,7 @@ static RPCHelpMan getnodeaddresses()
|
||||||
obj.pushKV("services", (uint64_t)addr.nServices);
|
obj.pushKV("services", (uint64_t)addr.nServices);
|
||||||
obj.pushKV("address", addr.ToStringIP());
|
obj.pushKV("address", addr.ToStringIP());
|
||||||
obj.pushKV("port", addr.GetPort());
|
obj.pushKV("port", addr.GetPort());
|
||||||
|
obj.pushKV("network", GetNetworkName(addr.GetNetClass()));
|
||||||
ret.push_back(obj);
|
ret.push_back(obj);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -195,7 +195,7 @@ class NetTest(BitcoinTestFramework):
|
||||||
for i in range(10000):
|
for i in range(10000):
|
||||||
first_octet = i >> 8
|
first_octet = i >> 8
|
||||||
second_octet = i % 256
|
second_octet = i % 256
|
||||||
a = "{}.{}.1.1".format(first_octet, second_octet)
|
a = "{}.{}.1.1".format(first_octet, second_octet) # IPV4
|
||||||
imported_addrs.append(a)
|
imported_addrs.append(a)
|
||||||
self.nodes[0].addpeeraddress(a, 8333)
|
self.nodes[0].addpeeraddress(a, 8333)
|
||||||
|
|
||||||
|
@ -212,6 +212,7 @@ class NetTest(BitcoinTestFramework):
|
||||||
assert_equal(a["services"], NODE_NETWORK | NODE_WITNESS)
|
assert_equal(a["services"], NODE_NETWORK | NODE_WITNESS)
|
||||||
assert a["address"] in imported_addrs
|
assert a["address"] in imported_addrs
|
||||||
assert_equal(a["port"], 8333)
|
assert_equal(a["port"], 8333)
|
||||||
|
assert_equal(a["network"], "ipv4")
|
||||||
|
|
||||||
node_addresses = self.nodes[0].getnodeaddresses(1)
|
node_addresses = self.nodes[0].getnodeaddresses(1)
|
||||||
assert_equal(len(node_addresses), 1)
|
assert_equal(len(node_addresses), 1)
|
||||||
|
|
Loading…
Add table
Reference in a new issue