@@ -572,10 +572,11 @@ static UniValue getnodeaddresses(const JSONRPCRequest& request)
572572 " \n Result:\n "
573573 " [\n "
574574 " {\n "
575- " \" time\" : ttt, (numeric) Timestamp in seconds since epoch (Jan 1 1970 GMT) keeping track of when the node was last seen\n "
576- " \" services\" : n, (numeric) The services offered\n "
575+ " \" time\" : ttt, (numeric) Timestamp in seconds since epoch (Jan 1 1970 GMT) when the node was last seen\n "
576+ " \" services\" : n, (numeric) The services offered by the node \n "
577577 " \" address\" : \" host\" , (string) The address of the node\n "
578- " \" port\" : n (numeric) The port of the node\n "
578+ " \" port\" : n, (numeric) The port number of the node\n "
579+ " \" network\" : \" xxxx\" (string) The network (ipv4, ipv6, onion) the node connected through\n "
579580 " }\n "
580581 " ,...\n "
581582 " ]\n "
@@ -589,15 +590,11 @@ static UniValue getnodeaddresses(const JSONRPCRequest& request)
589590 throw JSONRPCError (RPC_CLIENT_P2P_DISABLED, " Error: Peer-to-peer functionality missing or disabled" );
590591 }
591592
592- int count = 1 ;
593- if (!request.params [0 ].isNull ()) {
594- count = request.params [0 ].get_int ();
595- if (count < 0 ) {
596- throw JSONRPCError (RPC_INVALID_PARAMETER, " Address count out of range" );
597- }
598- }
593+ const int count{request.params [0 ].isNull () ? 1 : request.params [0 ].get_int ()};
594+ if (count < 0 ) throw JSONRPCError (RPC_INVALID_PARAMETER, " Address count out of range" );
595+
599596 // returns a shuffled list of CAddress
600- std::vector<CAddress> vAddr = g_connman->GetAddresses (count, /* max_pct */ 0 );
597+ const std::vector<CAddress> vAddr{ g_connman->GetAddresses (count, /* max_pct */ 0 )} ;
601598 UniValue ret (UniValue::VARR);
602599
603600 for (const CAddress& addr : vAddr) {
@@ -606,6 +603,7 @@ static UniValue getnodeaddresses(const JSONRPCRequest& request)
606603 obj.pushKV (" services" , (uint64_t )addr.nServices );
607604 obj.pushKV (" address" , addr.ToStringIP ());
608605 obj.pushKV (" port" , addr.GetPort ());
606+ obj.pushKV (" network" , GetNetworkName (addr.GetNetClass ()));
609607 ret.push_back (obj);
610608 }
611609 return ret;
0 commit comments