| 475 | } |
| 476 | |
| 477 | Value getnetworkinfo(const Array& params, bool fHelp) { |
| 478 | if (fHelp || params.size() != 0) |
| 479 | throw runtime_error( |
| 480 | "getnetworkinfo\n" |
| 481 | "\nget various information about network.\n" |
| 482 | "Returns an object containing various state info regarding P2P networking.\n" |
| 483 | "\nResult:\n" |
| 484 | "{\n" |
| 485 | " \"version\": xxxxx, (numeric) the server version\n" |
| 486 | " \"protocolversion\": xxxxx, (numeric) the protocol version\n" |
| 487 | " \"timeoffset\": xxxxx, (numeric) the time offset\n" |
| 488 | " \"connections\": xxxxx, (numeric) the number of connections\n" |
| 489 | " \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n" |
| 490 | " \"relayfee\": x.xxxx, (numeric) minimum relay fee for non-free transactions in btc/kb\n" |
| 491 | " \"localaddresses\": [, (array) list of local addresses\n" |
| 492 | " \"address\": \"xxxx\", (string) network address\n" |
| 493 | " \"port\": xxx, (numeric) network port\n" |
| 494 | " \"score\": xxx (numeric) relative score\n" |
| 495 | " ]\n" |
| 496 | "}\n" |
| 497 | "\nExamples:\n" + |
| 498 | HelpExampleCli("getnetworkinfo", "") + "\nAs json rpc\n" + HelpExampleRpc("getnetworkinfo", "")); |
| 499 | |
| 500 | ProxyType proxy; |
| 501 | GetProxy(NET_IPV4, proxy); |
| 502 | |
| 503 | Object obj; |
| 504 | obj.push_back(Pair("version", (int32_t)CLIENT_VERSION)); |
| 505 | obj.push_back(Pair("protocolversion", (int32_t)PROTOCOL_VERSION)); |
| 506 | obj.push_back(Pair("timeoffset", GetTimeOffset())); |
| 507 | obj.push_back(Pair("connections", (int32_t)vNodes.size())); |
| 508 | obj.push_back(Pair("proxy", (proxy.first.IsValid() ? proxy.first.ToStringIPPort() : string()))); |
| 509 | obj.push_back(Pair("relayfee", JsonValueFromAmount(MIN_RELAY_TX_FEE))); |
| 510 | Array localAddresses; |
| 511 | { |
| 512 | LOCK(cs_mapLocalHost); |
| 513 | for(const auto &item: mapLocalHost) |
| 514 | { |
| 515 | Object rec; |
| 516 | rec.push_back(Pair("address", item.first.ToString())); |
| 517 | rec.push_back(Pair("port", item.second.nPort)); |
| 518 | rec.push_back(Pair("score", item.second.nScore)); |
| 519 | localAddresses.push_back(rec); |
| 520 | } |
| 521 | } |
| 522 | obj.push_back(Pair("localaddresses", localAddresses)); |
| 523 | return obj; |
| 524 | } |
| 525 | |
| 526 | Value getchaininfo(const Array& params, bool fHelp) { |
| 527 | if (fHelp || params.size() < 1 || params.size() > 2) |
nothing calls this directly
no test coverage detected