| 414 | } |
| 415 | |
| 416 | static UniValue getnetworkinfo(const JSONRPCRequest& request) |
| 417 | { |
| 418 | if (request.fHelp || request.params.size() != 0) |
| 419 | throw std::runtime_error( |
| 420 | "getnetworkinfo\n" |
| 421 | "Returns an object containing various state info regarding P2P networking.\n" |
| 422 | "\nResult:\n" |
| 423 | "{\n" |
| 424 | " \"version\": xxxxx, (numeric) the server version\n" |
| 425 | " \"subversion\": \"/Satoshi:x.x.x/\", (string) the server subversion string\n" |
| 426 | " \"protocolversion\": xxxxx, (numeric) the protocol version\n" |
| 427 | " \"localservices\": \"xxxxxxxxxxxxxxxx\", (string) the services we offer to the network\n" |
| 428 | " \"localrelay\": true|false, (bool) true if transaction relay is requested from peers\n" |
| 429 | " \"timeoffset\": xxxxx, (numeric) the time offset\n" |
| 430 | " \"connections\": xxxxx, (numeric) the number of connections\n" |
| 431 | " \"networkactive\": true|false, (bool) whether p2p networking is enabled\n" |
| 432 | " \"networks\": [ (array) information per network\n" |
| 433 | " {\n" |
| 434 | " \"name\": \"xxx\", (string) network (ipv4, ipv6 or onion)\n" |
| 435 | " \"limited\": true|false, (boolean) is the network limited using -onlynet?\n" |
| 436 | " \"reachable\": true|false, (boolean) is the network reachable?\n" |
| 437 | " \"proxy\": \"host:port\" (string) the proxy that is used for this network, or empty if none\n" |
| 438 | " \"proxy_randomize_credentials\": true|false, (string) Whether randomized credentials are used\n" |
| 439 | " }\n" |
| 440 | " ,...\n" |
| 441 | " ],\n" |
| 442 | " \"relayfee\": x.xxxxxxxx, (numeric) minimum relay fee for transactions in " + CURRENCY_UNIT + "/kB\n" |
| 443 | " \"incrementalfee\": x.xxxxxxxx, (numeric) minimum fee increment for mempool limiting or BIP 125 replacement in " + CURRENCY_UNIT + "/kB\n" |
| 444 | " \"localaddresses\": [ (array) list of local addresses\n" |
| 445 | " {\n" |
| 446 | " \"address\": \"xxxx\", (string) network address\n" |
| 447 | " \"port\": xxx, (numeric) network port\n" |
| 448 | " \"score\": xxx (numeric) relative score\n" |
| 449 | " }\n" |
| 450 | " ,...\n" |
| 451 | " ]\n" |
| 452 | " \"warnings\": \"...\" (string) any network and blockchain warnings\n" |
| 453 | "}\n" |
| 454 | "\nExamples:\n" |
| 455 | + HelpExampleCli("getnetworkinfo", "") |
| 456 | + HelpExampleRpc("getnetworkinfo", "") |
| 457 | ); |
| 458 | |
| 459 | LOCK(cs_main); |
| 460 | UniValue obj(UniValue::VOBJ); |
| 461 | obj.pushKV("version", CLIENT_VERSION); |
| 462 | obj.pushKV("subversion", strSubVersion); |
| 463 | obj.pushKV("protocolversion",PROTOCOL_VERSION); |
| 464 | if(g_connman) |
| 465 | obj.pushKV("localservices", strprintf("%016x", g_connman->GetLocalServices())); |
| 466 | obj.pushKV("localrelay", fRelayTxes); |
| 467 | obj.pushKV("timeoffset", GetTimeOffset()); |
| 468 | if (g_connman) { |
| 469 | obj.pushKV("networkactive", g_connman->GetNetworkActive()); |
| 470 | obj.pushKV("connections", (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL)); |
| 471 | } |
| 472 | obj.pushKV("networks", GetNetworksInfo()); |
| 473 | obj.pushKV("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK())); |
nothing calls this directly
no test coverage detected