UniValue getmininginfo(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 0) throw std::runtime_error( "getmininginfo\n" "\nReturns a json object containing mining-related information." "\nResult:\n" "{\n" " \"blocks\": nnn, (numeric) The current block\n" " \"currentblocksize\": nnn, (numeric) The last block size\n" " \"currentblockweight\": nnn, (numeric) The last block weight\n" " \"currentblocktx\": nnn, (numeric) The last block transaction\n" " \"difficulty\": xxx.xxxxx (numeric) The current difficulty\n" " \"errors\": \"...\" (string) Current errors\n" " \"networkhashps\": nnn, (numeric) The network hashes per second\n" " \"pooledtx\": n (numeric) The size of the mempool\n" " \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n" "}\n" "\nExamples:\n" + HelpExampleCli("getmininginfo", "") + HelpExampleRpc("getmininginfo", "") ); LOCK(cs_main); UniValue obj(UniValue::VOBJ); obj.push_back(Pair("blocks", (int)chainActive.Height())); obj.push_back(Pair("currentblocksize", (uint64_t)nLastBlockSize)); obj.push_back(Pair("currentblockweight", (uint64_t)nLastBlockWeight)); obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx)); obj.push_back(Pair("difficulty", (double)GetDifficulty())); obj.push_back(Pair("errors", GetWarnings("statusbar"))); obj.push_back(Pair("networkhashps", getnetworkhashps(request))); obj.push_back(Pair("pooledtx", (uint64_t)mempool.size())); obj.push_back(Pair("chain", Params().NetworkIDString())); return obj; }
static duk_ret_t API__getmininginfo ( duk_context * ctx ) { duk_idx_t idx; idx = duk_push_object(ctx); duk_push_int ( ctx, nBestHeight ); duk_put_prop_string ( ctx, idx, "blocks" ); duk_push_int ( ctx, nLastBlockSize ); duk_put_prop_string ( ctx, idx, "currentblocksize" ); duk_push_int ( ctx, nLastBlockTx ); duk_put_prop_string ( ctx, idx, "currentblocktx" ); duk_push_number ( ctx, GetDifficulty(NULL) ); duk_put_prop_string ( ctx, idx, "difficulty" ); duk_push_string ( ctx, GetWarnings("statusbar").c_str() ); duk_put_prop_string ( ctx, idx, "errors" ); duk_push_boolean ( ctx, GetBoolArg ("-gen") ); duk_put_prop_string ( ctx, idx, "generate" ); duk_push_int ( ctx, GetArg ( "-genproclimit", -1 ) ); duk_put_prop_string ( ctx, idx, "genproclimit" ); duk_push_int ( ctx, 0 ); /* (TODO) */ duk_put_prop_string ( ctx, idx, "hashespersec" ); duk_push_number ( ctx, mempool.size() ); duk_put_prop_string ( ctx, idx, "pooledtx" ); duk_push_boolean ( ctx, fTestNet ); duk_put_prop_string ( ctx, idx, "testnet" ); return 1; }
QString ClientModel::getStatusBarWarnings() const { return QString::fromStdString(GetWarnings("statusbar")); }
static UniValue getnetworkinfo(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 0) throw std::runtime_error( "getnetworkinfo\n" "Returns an object containing various state info regarding P2P networking.\n" "\nResult:\n" "{\n" " \"version\": xxxxx, (numeric) the server version\n" " \"subversion\": \"/Satoshi:x.x.x/\", (string) the server subversion string\n" " \"protocolversion\": xxxxx, (numeric) the protocol version\n" " \"localservices\": \"xxxxxxxxxxxxxxxx\", (string) the services we offer to the network\n" " \"localrelay\": true|false, (bool) true if transaction relay is requested from peers\n" " \"timeoffset\": xxxxx, (numeric) the time offset\n" " \"connections\": xxxxx, (numeric) the number of connections\n" " \"networkactive\": true|false, (bool) whether p2p networking is enabled\n" " \"networks\": [ (array) information per network\n" " {\n" " \"name\": \"xxx\", (string) network (ipv4, ipv6 or onion)\n" " \"limited\": true|false, (boolean) is the network limited using -onlynet?\n" " \"reachable\": true|false, (boolean) is the network reachable?\n" " \"proxy\": \"host:port\" (string) the proxy that is used for this network, or empty if none\n" " \"proxy_randomize_credentials\": true|false, (string) Whether randomized credentials are used\n" " }\n" " ,...\n" " ],\n" " \"relayfee\": x.xxxxxxxx, (numeric) minimum relay fee for transactions in " + CURRENCY_UNIT + "/kB\n" " \"incrementalfee\": x.xxxxxxxx, (numeric) minimum fee increment for mempool limiting or BIP 125 replacement in " + CURRENCY_UNIT + "/kB\n" " \"localaddresses\": [ (array) list of local addresses\n" " {\n" " \"address\": \"xxxx\", (string) network address\n" " \"port\": xxx, (numeric) network port\n" " \"score\": xxx (numeric) relative score\n" " }\n" " ,...\n" " ]\n" " \"warnings\": \"...\" (string) any network and blockchain warnings\n" "}\n" "\nExamples:\n" + HelpExampleCli("getnetworkinfo", "") + HelpExampleRpc("getnetworkinfo", "") ); LOCK(cs_main); UniValue obj(UniValue::VOBJ); obj.pushKV("version", CLIENT_VERSION); obj.pushKV("subversion", strSubVersion); obj.pushKV("protocolversion",PROTOCOL_VERSION); if(g_connman) obj.pushKV("localservices", strprintf("%016x", g_connman->GetLocalServices())); obj.pushKV("localrelay", fRelayTxes); obj.pushKV("timeoffset", GetTimeOffset()); if (g_connman) { obj.pushKV("networkactive", g_connman->GetNetworkActive()); obj.pushKV("connections", (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL)); } obj.pushKV("networks", GetNetworksInfo()); obj.pushKV("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK())); obj.pushKV("incrementalfee", ValueFromAmount(::incrementalRelayFee.GetFeePerK())); UniValue localAddresses(UniValue::VARR); { LOCK(cs_mapLocalHost); for (const std::pair<const CNetAddr, LocalServiceInfo> &item : mapLocalHost) { UniValue rec(UniValue::VOBJ); rec.pushKV("address", item.first.ToString()); rec.pushKV("port", item.second.nPort); rec.pushKV("score", item.second.nScore); localAddresses.push_back(rec); } } obj.pushKV("localaddresses", localAddresses); obj.pushKV("warnings", GetWarnings("statusbar")); return obj; }
/** * @note Do not add or change anything in the information returned by this * method. `getinfo` exists for backwards-compatibility only. It combines * information from wildly different sources in the program, which is a mess, * and is thus planned to be deprecated eventually. * * Based on the source of the information, new information should be added to: * - `getblockchaininfo`, * - `getnetworkinfo` or * - `getwalletinfo` * * Or alternatively, create a specific query method for the information. **/ UniValue getinfo(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 0) throw std::runtime_error( "getinfo\n" "\nDEPRECATED. Returns an object containing various state info.\n" "\nResult:\n" "{\n" " \"deprecation-warning\": \"...\" (string) warning that the getinfo command is deprecated and will be removed in 0.16\n" " \"version\": xxxxx, (numeric) the server version\n" " \"protocolversion\": xxxxx, (numeric) the protocol version\n" " \"walletversion\": xxxxx, (numeric) the wallet version\n" " \"balance\": xxxxxxx, (numeric) the total bitcoin balance of the wallet\n" " \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n" " \"timeoffset\": xxxxx, (numeric) the time offset\n" " \"connections\": xxxxx, (numeric) the number of connections\n" " \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n" " \"difficulty\": xxxxxx, (numeric) the current difficulty\n" " \"testnet\": true|false, (boolean) if the server is using testnet or not\n" " \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since Unix epoch) of the oldest pre-generated key in the key pool\n" " \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n" " \"unlocked_until\": ttt, (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n" " \"paytxfee\": x.xxxx, (numeric) the transaction fee set in " + CURRENCY_UNIT + "/kB\n" " \"relayfee\": x.xxxx, (numeric) minimum relay fee for transactions in " + CURRENCY_UNIT + "/kB\n" " \"errors\": \"...\" (string) any error messages\n" "}\n" "\nExamples:\n" + HelpExampleCli("getinfo", "") + HelpExampleRpc("getinfo", "") ); #ifdef ENABLE_WALLET CWallet * const pwallet = GetWalletForJSONRPCRequest(request); LOCK2(cs_main, pwallet ? &pwallet->cs_wallet : NULL); #else LOCK(cs_main); #endif proxyType proxy; GetProxy(NET_IPV4, proxy); UniValue obj(UniValue::VOBJ); obj.push_back(Pair("deprecation-warning", "WARNING: getinfo is deprecated and will be fully removed in 0.16." " Projects should transition to using getblockchaininfo, getnetworkinfo, and getwalletinfo before upgrading to 0.16")); obj.push_back(Pair("version", CLIENT_VERSION)); obj.push_back(Pair("protocolversion", PROTOCOL_VERSION)); #ifdef ENABLE_WALLET if (pwallet) { obj.push_back(Pair("walletversion", pwallet->GetVersion())); obj.push_back(Pair("balance", ValueFromAmount(pwallet->GetBalance()))); } #endif obj.push_back(Pair("blocks", (int)chainActive.Height())); obj.push_back(Pair("timeoffset", GetTimeOffset())); if(g_connman) obj.push_back(Pair("connections", (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL))); obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : std::string()))); obj.push_back(Pair("difficulty", (double)GetDifficulty())); obj.push_back(Pair("testnet", Params().NetworkIDString() == CBaseChainParams::TESTNET)); #ifdef ENABLE_WALLET if (pwallet) { obj.push_back(Pair("keypoololdest", pwallet->GetOldestKeyPoolTime())); obj.push_back(Pair("keypoolsize", (int)pwallet->GetKeyPoolSize())); } if (pwallet && pwallet->IsCrypted()) { obj.push_back(Pair("unlocked_until", pwallet->nRelockTime)); } obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); #endif obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); obj.push_back(Pair("errors", GetWarnings("statusbar"))); return obj; }
static duk_ret_t API__getinfo ( duk_context * ctx ) { duk_idx_t idx; idx = duk_push_object(ctx); duk_push_string ( ctx, FormatFullVersion().c_str() ); duk_put_prop_string ( ctx, idx, "version" ); duk_push_int ( ctx, PROTOCOL_VERSION ); duk_put_prop_string ( ctx, idx, "protocolversion" ); duk_push_int ( ctx, pwalletMain->GetVersion() ); duk_put_prop_string ( ctx, idx, "walletversion" ); duk_push_number ( ctx, (double) pwalletMain->GetBalance() / COIN ); duk_put_prop_string ( ctx, idx, "balance" ); duk_push_number ( ctx, (double) pwalletMain->GetNewMint() / COIN ); duk_put_prop_string ( ctx, idx, "newmint" ); duk_push_number ( ctx, (double) pwalletMain->GetStake() / COIN ); duk_put_prop_string ( ctx, idx, "stake" ); duk_push_int ( ctx, nBestHeight ); duk_put_prop_string ( ctx, idx, "blocks" ); duk_push_number ( ctx, (double) pindexBest->nMoneySupply / COIN ); duk_put_prop_string ( ctx, idx, "moneysupply" ); duk_push_int ( ctx, vNodes.size() ); duk_put_prop_string ( ctx, idx, "connections" ); duk_push_string ( ctx, (fUseProxy ? addrProxy.ToStringIPPort().c_str() : "") ); duk_put_prop_string ( ctx, idx, "proxy" ); duk_push_string ( ctx, addrSeenByPeer.ToStringIP().c_str() ); duk_put_prop_string ( ctx, idx, "ip" ); duk_push_number ( ctx, GetDifficulty(NULL) ); duk_put_prop_string ( ctx, idx, "difficulty" ); duk_push_boolean ( ctx, fTestNet ); duk_put_prop_string ( ctx, idx, "testnet" ); duk_push_number ( ctx, pwalletMain->GetOldestKeyPoolTime() ); duk_put_prop_string ( ctx, idx, "keypoololdest" ); duk_push_int ( ctx, pwalletMain->GetKeyPoolSize() ); duk_put_prop_string ( ctx, idx, "keypoolsize" ); duk_push_number ( ctx, nTransactionFee ); duk_put_prop_string ( ctx, idx, "paytxfee" ); if (pwalletMain->IsCrypted()) { duk_push_int ( ctx, nWalletUnlockTime / 1000 ); duk_put_prop_string ( ctx, idx, "unlocked_until" ); } duk_push_string ( ctx, GetWarnings("statusbar").c_str() ); duk_put_prop_string ( ctx, idx, "errors" ); return 1; }