mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
rpc/net: decode the services flags in a new entry
This commit is contained in:
@@ -82,6 +82,10 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
|
|||||||
" \"addrbind\":\"ip:port\", (string) Bind address of the connection to the peer\n"
|
" \"addrbind\":\"ip:port\", (string) Bind address of the connection to the peer\n"
|
||||||
" \"addrlocal\":\"ip:port\", (string) Local address as reported by the peer\n"
|
" \"addrlocal\":\"ip:port\", (string) Local address as reported by the peer\n"
|
||||||
" \"services\":\"xxxxxxxxxxxxxxxx\", (string) The services offered\n"
|
" \"services\":\"xxxxxxxxxxxxxxxx\", (string) The services offered\n"
|
||||||
|
" \"servicesnames\":[ (array) the services offered, in human-readable form\n"
|
||||||
|
" \"SERVICE_NAME\", (string) the service name if it is recognised\n"
|
||||||
|
" ...\n"
|
||||||
|
" ],\n"
|
||||||
" \"relaytxes\":true|false, (boolean) Whether peer has asked us to relay transactions to it\n"
|
" \"relaytxes\":true|false, (boolean) Whether peer has asked us to relay transactions to it\n"
|
||||||
" \"lastsend\": ttt, (numeric) The time in seconds since epoch (Jan 1 1970 GMT) of the last send\n"
|
" \"lastsend\": ttt, (numeric) The time in seconds since epoch (Jan 1 1970 GMT) of the last send\n"
|
||||||
" \"lastrecv\": ttt, (numeric) The time in seconds since epoch (Jan 1 1970 GMT) of the last receive\n"
|
" \"lastrecv\": ttt, (numeric) The time in seconds since epoch (Jan 1 1970 GMT) of the last receive\n"
|
||||||
@@ -147,6 +151,7 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
|
|||||||
if (stats.addrBind.IsValid())
|
if (stats.addrBind.IsValid())
|
||||||
obj.pushKV("addrbind", stats.addrBind.ToString());
|
obj.pushKV("addrbind", stats.addrBind.ToString());
|
||||||
obj.pushKV("services", strprintf("%016x", stats.nServices));
|
obj.pushKV("services", strprintf("%016x", stats.nServices));
|
||||||
|
obj.pushKV("servicesnames", GetServicesNames(stats.nServices));
|
||||||
obj.pushKV("relaytxes", stats.fRelayTxes);
|
obj.pushKV("relaytxes", stats.fRelayTxes);
|
||||||
obj.pushKV("lastsend", stats.nLastSend);
|
obj.pushKV("lastsend", stats.nLastSend);
|
||||||
obj.pushKV("lastrecv", stats.nLastRecv);
|
obj.pushKV("lastrecv", stats.nLastRecv);
|
||||||
@@ -446,6 +451,10 @@ static UniValue getnetworkinfo(const JSONRPCRequest& request)
|
|||||||
" \"subversion\": \"/Satoshi:x.x.x/\", (string) the server subversion string\n"
|
" \"subversion\": \"/Satoshi:x.x.x/\", (string) the server subversion string\n"
|
||||||
" \"protocolversion\": xxxxx, (numeric) the protocol version\n"
|
" \"protocolversion\": xxxxx, (numeric) the protocol version\n"
|
||||||
" \"localservices\": \"xxxxxxxxxxxxxxxx\", (string) the services we offer to the network\n"
|
" \"localservices\": \"xxxxxxxxxxxxxxxx\", (string) the services we offer to the network\n"
|
||||||
|
" \"localservicesnames\": [ (array) the services we offer to the network, in human-readable form\n"
|
||||||
|
" \"SERVICE_NAME\", (string) the service name\n"
|
||||||
|
" ...\n"
|
||||||
|
" ],\n"
|
||||||
" \"localrelay\": true|false, (bool) true if transaction relay is requested from peers\n"
|
" \"localrelay\": true|false, (bool) true if transaction relay is requested from peers\n"
|
||||||
" \"timeoffset\": xxxxx, (numeric) the time offset\n"
|
" \"timeoffset\": xxxxx, (numeric) the time offset\n"
|
||||||
" \"connections\": xxxxx, (numeric) the number of connections\n"
|
" \"connections\": xxxxx, (numeric) the number of connections\n"
|
||||||
@@ -484,8 +493,11 @@ static UniValue getnetworkinfo(const JSONRPCRequest& request)
|
|||||||
obj.pushKV("version", CLIENT_VERSION);
|
obj.pushKV("version", CLIENT_VERSION);
|
||||||
obj.pushKV("subversion", strSubVersion);
|
obj.pushKV("subversion", strSubVersion);
|
||||||
obj.pushKV("protocolversion",PROTOCOL_VERSION);
|
obj.pushKV("protocolversion",PROTOCOL_VERSION);
|
||||||
if(g_connman)
|
if (g_connman) {
|
||||||
obj.pushKV("localservices", strprintf("%016x", g_connman->GetLocalServices()));
|
ServiceFlags services = g_connman->GetLocalServices();
|
||||||
|
obj.pushKV("localservices", strprintf("%016x", services));
|
||||||
|
obj.pushKV("localservicesnames", GetServicesNames(services));
|
||||||
|
}
|
||||||
obj.pushKV("localrelay", g_relay_txes);
|
obj.pushKV("localrelay", g_relay_txes);
|
||||||
obj.pushKV("timeoffset", GetTimeOffset());
|
obj.pushKV("timeoffset", GetTimeOffset());
|
||||||
if (g_connman) {
|
if (g_connman) {
|
||||||
|
|||||||
@@ -733,3 +733,21 @@ std::vector<CScript> EvalDescriptorStringOrObject(const UniValue& scanobject, Fl
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UniValue GetServicesNames(ServiceFlags services)
|
||||||
|
{
|
||||||
|
UniValue servicesNames(UniValue::VARR);
|
||||||
|
|
||||||
|
if (services & NODE_NETWORK)
|
||||||
|
servicesNames.push_back("NETWORK");
|
||||||
|
if (services & NODE_GETUTXO)
|
||||||
|
servicesNames.push_back("GETUTXO");
|
||||||
|
if (services & NODE_BLOOM)
|
||||||
|
servicesNames.push_back("BLOOM");
|
||||||
|
if (services & NODE_WITNESS)
|
||||||
|
servicesNames.push_back("WITNESS");
|
||||||
|
if (services & NODE_NETWORK_LIMITED)
|
||||||
|
servicesNames.push_back("NETWORK_LIMITED");
|
||||||
|
|
||||||
|
return servicesNames;
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <node/transaction.h>
|
#include <node/transaction.h>
|
||||||
#include <outputtype.h>
|
#include <outputtype.h>
|
||||||
#include <pubkey.h>
|
#include <pubkey.h>
|
||||||
|
#include <protocol.h>
|
||||||
#include <rpc/protocol.h>
|
#include <rpc/protocol.h>
|
||||||
#include <rpc/request.h>
|
#include <rpc/request.h>
|
||||||
#include <script/script.h>
|
#include <script/script.h>
|
||||||
@@ -90,6 +91,9 @@ std::pair<int64_t, int64_t> ParseDescriptorRange(const UniValue& value);
|
|||||||
/** Evaluate a descriptor given as a string, or as a {"desc":...,"range":...} object, with default range of 1000. */
|
/** Evaluate a descriptor given as a string, or as a {"desc":...,"range":...} object, with default range of 1000. */
|
||||||
std::vector<CScript> EvalDescriptorStringOrObject(const UniValue& scanobject, FlatSigningProvider& provider);
|
std::vector<CScript> EvalDescriptorStringOrObject(const UniValue& scanobject, FlatSigningProvider& provider);
|
||||||
|
|
||||||
|
/** Returns, given services flags, a list of humanly readable (known) network services */
|
||||||
|
UniValue GetServicesNames(ServiceFlags services);
|
||||||
|
|
||||||
struct RPCArg {
|
struct RPCArg {
|
||||||
enum class Type {
|
enum class Type {
|
||||||
OBJ,
|
OBJ,
|
||||||
|
|||||||
Reference in New Issue
Block a user