Bitcoin ABC  0.24.7
P2P Digital Currency
net.cpp
Go to the documentation of this file.
1 // Copyright (c) 2009-2019 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <rpc/server.h>
6 
7 #include <avalanche/avalanche.h>
8 #include <banman.h>
9 #include <clientversion.h>
10 #include <config.h>
11 #include <core_io.h>
12 #include <net.h>
13 #include <net_permissions.h>
14 #include <net_processing.h>
15 #include <net_types.h> // For banmap_t
16 #include <netbase.h>
17 #include <network.h>
18 #include <node/context.h>
19 #include <policy/settings.h>
20 #include <rpc/blockchain.h>
21 #include <rpc/protocol.h>
22 #include <rpc/util.h>
23 #include <sync.h>
24 #include <timedata.h>
25 #include <util/strencodings.h>
26 #include <util/string.h>
27 #include <util/system.h>
28 #include <util/translation.h>
29 #include <validation.h>
30 #include <version.h>
31 #include <warnings.h>
32 
33 #include <univalue.h>
34 
36  return RPCHelpMan{
37  "getconnectioncount",
38  "Returns the number of connections to other nodes.\n",
39  {},
40  RPCResult{RPCResult::Type::NUM, "", "The connection count"},
41  RPCExamples{HelpExampleCli("getconnectioncount", "") +
42  HelpExampleRpc("getconnectioncount", "")},
43  [&](const RPCHelpMan &self, const Config &config,
44  const JSONRPCRequest &request) -> UniValue {
45  NodeContext &node = EnsureNodeContext(request.context);
46  if (!node.connman) {
47  throw JSONRPCError(
49  "Error: Peer-to-peer functionality missing or disabled");
50  }
51 
52  return int(node.connman->GetNodeCount(CConnman::CONNECTIONS_ALL));
53  },
54  };
55 }
56 
57 static RPCHelpMan ping() {
58  return RPCHelpMan{
59  "ping",
60  "Requests that a ping be sent to all other nodes, to measure ping "
61  "time.\n"
62  "Results provided in getpeerinfo, pingtime and pingwait fields are "
63  "decimal seconds.\n"
64  "Ping command is handled in queue with all other commands, so it "
65  "measures processing backlog, not just network ping.\n",
66  {},
68  RPCExamples{HelpExampleCli("ping", "") + HelpExampleRpc("ping", "")},
69  [&](const RPCHelpMan &self, const Config &config,
70  const JSONRPCRequest &request) -> UniValue {
71  NodeContext &node = EnsureNodeContext(request.context);
72  if (!node.connman) {
73  throw JSONRPCError(
75  "Error: Peer-to-peer functionality missing or disabled");
76  }
77 
78  // Request that each node send a ping during next message processing
79  // pass
80  node.connman->ForEachNode(
81  [](CNode *pnode) { pnode->fPingQueued = true; });
82  return NullUniValue;
83  },
84  };
85 }
86 
88  return RPCHelpMan{
89  "getpeerinfo",
90  "Returns data about each connected network node as a json array of "
91  "objects.\n",
92  {},
93  RPCResult{
95  "",
96  "",
97  {{
99  "",
100  "",
101  {{
102  {RPCResult::Type::NUM, "id", "Peer index"},
103  {RPCResult::Type::STR, "addr",
104  "(host:port) The IP address and port of the peer"},
105  {RPCResult::Type::STR, "addrbind",
106  "(ip:port) Bind address of the connection to the peer"},
107  {RPCResult::Type::STR, "addrlocal",
108  "(ip:port) Local address as reported by the peer"},
109  {RPCResult::Type::STR, "network",
110  "Network (ipv4, ipv6, or onion) the peer connected "
111  "through"},
112  {RPCResult::Type::NUM, "mapped_as",
113  "The AS in the BGP route to the peer used for "
114  "diversifying\n"
115  "peer selection (only available if the asmap config flag "
116  "is set)\n"},
117  {RPCResult::Type::STR_HEX, "services",
118  "The services offered"},
120  "servicesnames",
121  "the services offered, in human-readable form",
122  {{RPCResult::Type::STR, "SERVICE_NAME",
123  "the service name if it is recognised"}}},
124  {RPCResult::Type::BOOL, "relaytxes",
125  "Whether peer has asked us to relay transactions to it"},
126  {RPCResult::Type::NUM_TIME, "lastsend",
127  "The " + UNIX_EPOCH_TIME + " of the last send"},
128  {RPCResult::Type::NUM_TIME, "lastrecv",
129  "The " + UNIX_EPOCH_TIME + " of the last receive"},
130  {RPCResult::Type::NUM_TIME, "last_transaction",
131  "The " + UNIX_EPOCH_TIME +
132  " of the last valid transaction received from this "
133  "peer"},
134  {RPCResult::Type::NUM_TIME, "last_block",
135  "The " + UNIX_EPOCH_TIME +
136  " of the last block received from this peer"},
137  {RPCResult::Type::NUM, "bytessent", "The total bytes sent"},
138  {RPCResult::Type::NUM, "bytesrecv",
139  "The total bytes received"},
140  {RPCResult::Type::NUM_TIME, "conntime",
141  "The " + UNIX_EPOCH_TIME + " of the connection"},
142  {RPCResult::Type::NUM, "timeoffset",
143  "The time offset in seconds"},
144  {RPCResult::Type::NUM, "pingtime",
145  "ping time (if available)"},
146  {RPCResult::Type::NUM, "minping",
147  "minimum observed ping time (if any at all)"},
148  {RPCResult::Type::NUM, "pingwait",
149  "ping wait (if non-zero)"},
150  {RPCResult::Type::NUM, "version",
151  "The peer version, such as 70001"},
152  {RPCResult::Type::STR, "subver", "The string version"},
153  {RPCResult::Type::BOOL, "inbound",
154  "Inbound (true) or Outbound (false)"},
155  {RPCResult::Type::BOOL, "addnode",
156  "Whether connection was due to addnode/-connect or if it "
157  "was an automatic/inbound connection\n(DEPRECATED, "
158  "returned only if the config option "
159  "-deprecatedrpc=getpeerinfo_addnode is passed)"},
160  {RPCResult::Type::STR, "connection_type",
161  "Type of connection: \n" +
162  Join(CONNECTION_TYPE_DOC, ",\n") + "."},
163  {RPCResult::Type::NUM, "startingheight",
164  "The starting height (block) of the peer"},
165  {RPCResult::Type::NUM, "banscore",
166  "The ban score (DEPRECATED, returned only if config "
167  "option -deprecatedrpc=banscore is passed)"},
168  {RPCResult::Type::NUM, "synced_headers",
169  "The last header we have in common with this peer"},
170  {RPCResult::Type::NUM, "synced_blocks",
171  "The last block we have in common with this peer"},
173  "inflight",
174  "",
175  {
176  {RPCResult::Type::NUM, "n",
177  "The heights of blocks we're currently asking from "
178  "this peer"},
179  }},
180  {RPCResult::Type::BOOL, "whitelisted", /* optional */ true,
181  "Whether the peer is whitelisted with default "
182  "permissions\n (DEPRECATED, returned only if config "
183  "option -deprecatedrpc=whitelisted is passed)"},
184  {RPCResult::Type::NUM, "minfeefilter",
185  "The minimum fee rate for transactions this peer accepts"},
187  "bytessent_per_msg",
188  "",
189  {{RPCResult::Type::NUM, "msg",
190  "The total bytes sent aggregated by message type\n"
191  "When a message type is not listed in this json object, "
192  "the bytes sent are 0.\n"
193  "Only known message types can appear as keys in the "
194  "object."}}},
196  "bytesrecv_per_msg",
197  "",
198  {{RPCResult::Type::NUM, "msg",
199  "The total bytes received aggregated by message type\n"
200  "When a message type is not listed in this json object, "
201  "the bytes received are 0.\n"
202  "Only known message types can appear as keys in the "
203  "object and all bytes received\n"
204  "of unknown message types are listed under '" +
205  NET_MESSAGE_COMMAND_OTHER + "'."}}},
206  }},
207  }},
208  },
209  RPCExamples{HelpExampleCli("getpeerinfo", "") +
210  HelpExampleRpc("getpeerinfo", "")},
211  [&](const RPCHelpMan &self, const Config &config,
212  const JSONRPCRequest &request) -> UniValue {
213  NodeContext &node = EnsureNodeContext(request.context);
214  if (!node.connman) {
215  throw JSONRPCError(
217  "Error: Peer-to-peer functionality missing or disabled");
218  }
219 
220  std::vector<CNodeStats> vstats;
221  node.connman->GetNodeStats(vstats);
222 
224 
225  for (const CNodeStats &stats : vstats) {
227  CNodeStateStats statestats;
228  bool fStateStats = GetNodeStateStats(stats.nodeid, statestats);
229  obj.pushKV("id", stats.nodeid);
230  obj.pushKV("addr", stats.addrName);
231  if (stats.addrBind.IsValid()) {
232  obj.pushKV("addrbind", stats.addrBind.ToString());
233  }
234  if (!(stats.addrLocal.empty())) {
235  obj.pushKV("addrlocal", stats.addrLocal);
236  }
237  obj.pushKV("network", stats.m_network);
238  if (stats.m_mapped_as != 0) {
239  obj.pushKV("mapped_as", uint64_t(stats.m_mapped_as));
240  }
241  obj.pushKV("services", strprintf("%016x", stats.nServices));
242  obj.pushKV("servicesnames", GetServicesNames(stats.nServices));
243  obj.pushKV("relaytxes", stats.fRelayTxes);
244  obj.pushKV("lastsend", stats.nLastSend);
245  obj.pushKV("lastrecv", stats.nLastRecv);
246  obj.pushKV("last_transaction", stats.nLastTXTime);
247  if (g_avalanche) {
248  obj.pushKV("last_proof", stats.nLastProofTime);
249  }
250  obj.pushKV("last_block", stats.nLastBlockTime);
251  obj.pushKV("bytessent", stats.nSendBytes);
252  obj.pushKV("bytesrecv", stats.nRecvBytes);
253  obj.pushKV("conntime", stats.nTimeConnected);
254  obj.pushKV("timeoffset", stats.nTimeOffset);
255  if (stats.m_ping_usec > 0) {
256  obj.pushKV("pingtime", double(stats.m_ping_usec) / 1e6);
257  }
258  if (stats.m_min_ping_usec <
259  std::numeric_limits<int64_t>::max()) {
260  obj.pushKV("minping", double(stats.m_min_ping_usec) / 1e6);
261  }
262  if (stats.m_ping_wait_usec > 0) {
263  obj.pushKV("pingwait",
264  double(stats.m_ping_wait_usec) / 1e6);
265  }
266  obj.pushKV("version", stats.nVersion);
267  // Use the sanitized form of subver here, to avoid tricksy
268  // remote peers from corrupting or modifying the JSON output by
269  // putting special characters in their ver message.
270  obj.pushKV("subver", stats.cleanSubVer);
271  obj.pushKV("inbound", stats.fInbound);
272  if (IsDeprecatedRPCEnabled(gArgs, "getpeerinfo_addnode")) {
273  // addnode is deprecated in v0.24.5 for removal in v0.25.x
274  obj.pushKV("addnode", stats.m_manual_connection);
275  }
276  obj.pushKV("startingheight", stats.nStartingHeight);
277  if (fStateStats) {
278  if (IsDeprecatedRPCEnabled(gArgs, "banscore")) {
279  // banscore is deprecated in v0.22.11 for removal in
280  // v0.23
281  obj.pushKV("banscore", statestats.m_misbehavior_score);
282  }
283  obj.pushKV("synced_headers", statestats.nSyncHeight);
284  obj.pushKV("synced_blocks", statestats.nCommonHeight);
285  UniValue heights(UniValue::VARR);
286  for (const int height : statestats.vHeightInFlight) {
287  heights.push_back(height);
288  }
289  obj.pushKV("inflight", heights);
290  }
291  if (IsDeprecatedRPCEnabled(gArgs, "whitelisted")) {
292  // whitelisted is deprecated in v0.24.7 for removal in v0.25
293  obj.pushKV("whitelisted", stats.m_legacyWhitelisted);
294  }
295  UniValue permissions(UniValue::VARR);
296  for (const auto &permission :
297  NetPermissions::ToStrings(stats.m_permissionFlags)) {
298  permissions.push_back(permission);
299  }
300  obj.pushKV("permissions", permissions);
301  obj.pushKV("minfeefilter", stats.minFeeFilter);
302 
303  UniValue sendPerMsgCmd(UniValue::VOBJ);
304  for (const auto &i : stats.mapSendBytesPerMsgCmd) {
305  if (i.second > 0) {
306  sendPerMsgCmd.pushKV(i.first, i.second);
307  }
308  }
309  obj.pushKV("bytessent_per_msg", sendPerMsgCmd);
310 
311  UniValue recvPerMsgCmd(UniValue::VOBJ);
312  for (const auto &i : stats.mapRecvBytesPerMsgCmd) {
313  if (i.second > 0) {
314  recvPerMsgCmd.pushKV(i.first, i.second);
315  }
316  }
317  obj.pushKV("bytesrecv_per_msg", recvPerMsgCmd);
318  obj.pushKV("connection_type", stats.m_conn_type_string);
319 
320  ret.push_back(obj);
321  }
322 
323  return ret;
324  },
325  };
326 }
327 
328 static RPCHelpMan addnode() {
329  return RPCHelpMan{
330  "addnode",
331  "Attempts to add or remove a node from the addnode list.\n"
332  "Or try a connection to a node once.\n"
333  "Nodes added using addnode (or -connect) are protected from "
334  "DoS disconnection and are not required to be\n"
335  "full nodes as other outbound peers are (though such peers "
336  "will not be synced from).\n",
337  {
339  "The node (see getpeerinfo for nodes)"},
341  "'add' to add a node to the list, 'remove' to remove a "
342  "node from the list, 'onetry' to try a connection to the "
343  "node once"},
344  },
346  RPCExamples{
347  HelpExampleCli("addnode", "\"192.168.0.6:8333\" \"onetry\"") +
348  HelpExampleRpc("addnode", "\"192.168.0.6:8333\", \"onetry\"")},
349  [&](const RPCHelpMan &self, const Config &config,
350  const JSONRPCRequest &request) -> UniValue {
351  std::string strCommand;
352  if (!request.params[1].isNull()) {
353  strCommand = request.params[1].get_str();
354  }
355 
356  if (request.fHelp || request.params.size() != 2 ||
357  (strCommand != "onetry" && strCommand != "add" &&
358  strCommand != "remove")) {
359  throw std::runtime_error(self.ToString());
360  }
361 
362  NodeContext &node = EnsureNodeContext(request.context);
363  if (!node.connman) {
364  throw JSONRPCError(
366  "Error: Peer-to-peer functionality missing or disabled");
367  }
368 
369  std::string strNode = request.params[0].get_str();
370 
371  if (strCommand == "onetry") {
372  CAddress addr;
373  node.connman->OpenNetworkConnection(addr, false, nullptr,
374  strNode.c_str(),
376  return NullUniValue;
377  }
378 
379  if ((strCommand == "add") && (!node.connman->AddNode(strNode))) {
381  "Error: Node already added");
382  } else if ((strCommand == "remove") &&
383  (!node.connman->RemoveAddedNode(strNode))) {
384  throw JSONRPCError(
386  "Error: Node could not be removed. It has not been "
387  "added previously.");
388  }
389 
390  return NullUniValue;
391  },
392  };
393 }
394 
396  return RPCHelpMan{
397  "disconnectnode",
398  "Immediately disconnects from the specified peer node.\n"
399  "\nStrictly one out of 'address' and 'nodeid' can be provided to "
400  "identify the node.\n"
401  "\nTo disconnect by nodeid, either set 'address' to the empty string, "
402  "or call using the named 'nodeid' argument only.\n",
403  {
404  {"address", RPCArg::Type::STR,
405  /* default */ "fallback to nodeid",
406  "The IP address/port of the node"},
407  {"nodeid", RPCArg::Type::NUM,
408  /* default */ "fallback to address",
409  "The node ID (see getpeerinfo for node IDs)"},
410  },
412  RPCExamples{HelpExampleCli("disconnectnode", "\"192.168.0.6:8333\"") +
413  HelpExampleCli("disconnectnode", "\"\" 1") +
414  HelpExampleRpc("disconnectnode", "\"192.168.0.6:8333\"") +
415  HelpExampleRpc("disconnectnode", "\"\", 1")},
416  [&](const RPCHelpMan &self, const Config &config,
417  const JSONRPCRequest &request) -> UniValue {
418  NodeContext &node = EnsureNodeContext(request.context);
419  if (!node.connman) {
420  throw JSONRPCError(
422  "Error: Peer-to-peer functionality missing or disabled");
423  }
424 
425  bool success;
426  const UniValue &address_arg = request.params[0];
427  const UniValue &id_arg = request.params[1];
428 
429  if (!address_arg.isNull() && id_arg.isNull()) {
430  /* handle disconnect-by-address */
431  success = node.connman->DisconnectNode(address_arg.get_str());
432  } else if (!id_arg.isNull() && (address_arg.isNull() ||
433  (address_arg.isStr() &&
434  address_arg.get_str().empty()))) {
435  /* handle disconnect-by-id */
436  NodeId nodeid = (NodeId)id_arg.get_int64();
437  success = node.connman->DisconnectNode(nodeid);
438  } else {
439  throw JSONRPCError(
441  "Only one of address and nodeid should be provided.");
442  }
443 
444  if (!success) {
446  "Node not found in connected nodes");
447  }
448 
449  return NullUniValue;
450  },
451  };
452 }
453 
455  return RPCHelpMan{
456  "getaddednodeinfo",
457  "Returns information about the given added node, or all added nodes\n"
458  "(note that onetry addnodes are not listed here)\n",
459  {
460  {"node", RPCArg::Type::STR, /* default */ "all nodes",
461  "If provided, return information about this specific node, "
462  "otherwise all nodes are returned."},
463  },
464  RPCResult{
466  "",
467  "",
468  {
470  "",
471  "",
472  {
473  {RPCResult::Type::STR, "addednode",
474  "The node IP address or name (as provided to addnode)"},
475  {RPCResult::Type::BOOL, "connected", "If connected"},
477  "addresses",
478  "Only when connected = true",
479  {
481  "",
482  "",
483  {
484  {RPCResult::Type::STR, "address",
485  "The bitcoin server IP and port we're "
486  "connected to"},
487  {RPCResult::Type::STR, "connected",
488  "connection, inbound or outbound"},
489  }},
490  }},
491  }},
492  }},
493  RPCExamples{HelpExampleCli("getaddednodeinfo", "\"192.168.0.201\"") +
494  HelpExampleRpc("getaddednodeinfo", "\"192.168.0.201\"")},
495  [&](const RPCHelpMan &self, const Config &config,
496  const JSONRPCRequest &request) -> UniValue {
497  NodeContext &node = EnsureNodeContext(request.context);
498  if (!node.connman) {
499  throw JSONRPCError(
501  "Error: Peer-to-peer functionality missing or disabled");
502  }
503 
504  std::vector<AddedNodeInfo> vInfo = node.connman->GetAddedNodeInfo();
505 
506  if (!request.params[0].isNull()) {
507  bool found = false;
508  for (const AddedNodeInfo &info : vInfo) {
509  if (info.strAddedNode == request.params[0].get_str()) {
510  vInfo.assign(1, info);
511  found = true;
512  break;
513  }
514  }
515  if (!found) {
517  "Error: Node has not been added.");
518  }
519  }
520 
522 
523  for (const AddedNodeInfo &info : vInfo) {
525  obj.pushKV("addednode", info.strAddedNode);
526  obj.pushKV("connected", info.fConnected);
527  UniValue addresses(UniValue::VARR);
528  if (info.fConnected) {
529  UniValue address(UniValue::VOBJ);
530  address.pushKV("address", info.resolvedAddress.ToString());
531  address.pushKV("connected",
532  info.fInbound ? "inbound" : "outbound");
533  addresses.push_back(address);
534  }
535  obj.pushKV("addresses", addresses);
536  ret.push_back(obj);
537  }
538 
539  return ret;
540  },
541  };
542 }
543 
545  return RPCHelpMan{
546  "getnettotals",
547  "Returns information about network traffic, including bytes in, "
548  "bytes out,\n"
549  "and current time.\n",
550  {},
551  RPCResult{
553  "",
554  "",
555  {
556  {RPCResult::Type::NUM, "totalbytesrecv",
557  "Total bytes received"},
558  {RPCResult::Type::NUM, "totalbytessent", "Total bytes sent"},
559  {RPCResult::Type::NUM_TIME, "timemillis",
560  "Current " + UNIX_EPOCH_TIME + " in milliseconds"},
562  "uploadtarget",
563  "",
564  {
565  {RPCResult::Type::NUM, "timeframe",
566  "Length of the measuring timeframe in seconds"},
567  {RPCResult::Type::NUM, "target", "Target in bytes"},
568  {RPCResult::Type::BOOL, "target_reached",
569  "True if target is reached"},
570  {RPCResult::Type::BOOL, "serve_historical_blocks",
571  "True if serving historical blocks"},
572  {RPCResult::Type::NUM, "bytes_left_in_cycle",
573  "Bytes left in current time cycle"},
574  {RPCResult::Type::NUM, "time_left_in_cycle",
575  "Seconds left in current time cycle"},
576  }},
577  }},
578  RPCExamples{HelpExampleCli("getnettotals", "") +
579  HelpExampleRpc("getnettotals", "")},
580  [&](const RPCHelpMan &self, const Config &config,
581  const JSONRPCRequest &request) -> UniValue {
582  NodeContext &node = EnsureNodeContext(request.context);
583  if (!node.connman) {
584  throw JSONRPCError(
586  "Error: Peer-to-peer functionality missing or disabled");
587  }
588 
590  obj.pushKV("totalbytesrecv", node.connman->GetTotalBytesRecv());
591  obj.pushKV("totalbytessent", node.connman->GetTotalBytesSent());
592  obj.pushKV("timemillis", GetTimeMillis());
593 
594  UniValue outboundLimit(UniValue::VOBJ);
595  outboundLimit.pushKV("timeframe",
596  node.connman->GetMaxOutboundTimeframe());
597  outboundLimit.pushKV("target",
598  node.connman->GetMaxOutboundTarget());
599  outboundLimit.pushKV("target_reached",
600  node.connman->OutboundTargetReached(false));
601  outboundLimit.pushKV("serve_historical_blocks",
602  !node.connman->OutboundTargetReached(true));
603  outboundLimit.pushKV("bytes_left_in_cycle",
604  node.connman->GetOutboundTargetBytesLeft());
605  outboundLimit.pushKV("time_left_in_cycle",
606  node.connman->GetMaxOutboundTimeLeftInCycle());
607  obj.pushKV("uploadtarget", outboundLimit);
608  return obj;
609  },
610  };
611 }
612 
614  UniValue networks(UniValue::VARR);
615  for (int n = 0; n < NET_MAX; ++n) {
616  enum Network network = static_cast<enum Network>(n);
617  if (network == NET_UNROUTABLE || network == NET_INTERNAL) {
618  continue;
619  }
620  proxyType proxy;
622  GetProxy(network, proxy);
623  obj.pushKV("name", GetNetworkName(network));
624  obj.pushKV("limited", !IsReachable(network));
625  obj.pushKV("reachable", IsReachable(network));
626  obj.pushKV("proxy", proxy.IsValid() ? proxy.proxy.ToStringIPPort()
627  : std::string());
628  obj.pushKV("proxy_randomize_credentials", proxy.randomize_credentials);
629  networks.push_back(obj);
630  }
631  return networks;
632 }
633 
635  const auto &ticker = Currency::get().ticker;
636  return RPCHelpMan{
637  "getnetworkinfo",
638  "Returns an object containing various state info regarding P2P "
639  "networking.\n",
640  {},
641  RPCResult{
643  "",
644  "",
645  {
646  {RPCResult::Type::NUM, "version", "the server version"},
647  {RPCResult::Type::STR, "subversion",
648  "the server subversion string"},
649  {RPCResult::Type::NUM, "protocolversion",
650  "the protocol version"},
651  {RPCResult::Type::STR_HEX, "localservices",
652  "the services we offer to the network"},
654  "localservicesnames",
655  "the services we offer to the network, in human-readable form",
656  {
657  {RPCResult::Type::STR, "SERVICE_NAME", "the service name"},
658  }},
659  {RPCResult::Type::BOOL, "localrelay",
660  "true if transaction relay is requested from peers"},
661  {RPCResult::Type::NUM, "timeoffset", "the time offset"},
662  {RPCResult::Type::NUM, "connections",
663  "the total number of connections"},
664  {RPCResult::Type::NUM, "connections_in",
665  "the number of inbound connections"},
666  {RPCResult::Type::NUM, "connections_out",
667  "the number of outbound connections"},
668  {RPCResult::Type::BOOL, "networkactive",
669  "whether p2p networking is enabled"},
671  "networks",
672  "information per network",
673  {
675  "",
676  "",
677  {
678  {RPCResult::Type::STR, "name",
679  "network (ipv4, ipv6 or onion)"},
680  {RPCResult::Type::BOOL, "limited",
681  "is the network limited using -onlynet?"},
682  {RPCResult::Type::BOOL, "reachable",
683  "is the network reachable?"},
684  {RPCResult::Type::STR, "proxy",
685  "(\"host:port\") the proxy that is used for this "
686  "network, or empty if none"},
687  {RPCResult::Type::BOOL, "proxy_randomize_credentials",
688  "Whether randomized credentials are used"},
689  }},
690  }},
691  {RPCResult::Type::NUM, "relayfee",
692  "minimum relay fee for transactions in " + ticker + "/kB"},
693  {RPCResult::Type::NUM, "excessutxocharge",
694  "minimum charge for excess utxos in " + ticker},
696  "localaddresses",
697  "list of local addresses",
698  {
700  "",
701  "",
702  {
703  {RPCResult::Type::STR, "address", "network address"},
704  {RPCResult::Type::NUM, "port", "network port"},
705  {RPCResult::Type::NUM, "score", "relative score"},
706  }},
707  }},
708  {RPCResult::Type::STR, "warnings",
709  "any network and blockchain warnings"},
710  }},
711  RPCExamples{HelpExampleCli("getnetworkinfo", "") +
712  HelpExampleRpc("getnetworkinfo", "")},
713  [&](const RPCHelpMan &self, const Config &config,
714  const JSONRPCRequest &request) -> UniValue {
715  LOCK(cs_main);
717  obj.pushKV("version", CLIENT_VERSION);
718  obj.pushKV("subversion", userAgent(config));
719  obj.pushKV("protocolversion", PROTOCOL_VERSION);
720  NodeContext &node = EnsureNodeContext(request.context);
721  if (node.connman) {
722  ServiceFlags services = node.connman->GetLocalServices();
723  obj.pushKV("localservices", strprintf("%016x", services));
724  obj.pushKV("localservicesnames", GetServicesNames(services));
725  }
726  obj.pushKV("localrelay", g_relay_txes);
727  obj.pushKV("timeoffset", GetTimeOffset());
728  if (node.connman) {
729  obj.pushKV("networkactive", node.connman->GetNetworkActive());
730  obj.pushKV("connections", int(node.connman->GetNodeCount(
732  obj.pushKV("connections_in", int(node.connman->GetNodeCount(
734  obj.pushKV("connections_out", int(node.connman->GetNodeCount(
736  }
737  obj.pushKV("networks", GetNetworksInfo());
738  obj.pushKV("relayfee", ::minRelayTxFee.GetFeePerK());
739  obj.pushKV("excessutxocharge", config.GetExcessUTXOCharge());
740  UniValue localAddresses(UniValue::VARR);
741  {
743  for (const std::pair<const CNetAddr, LocalServiceInfo> &item :
744  mapLocalHost) {
746  rec.pushKV("address", item.first.ToString());
747  rec.pushKV("port", item.second.nPort);
748  rec.pushKV("score", item.second.nScore);
749  localAddresses.push_back(rec);
750  }
751  }
752  obj.pushKV("localaddresses", localAddresses);
753  obj.pushKV("warnings", GetWarnings(false).original);
754  return obj;
755  },
756  };
757 }
758 
759 static RPCHelpMan setban() {
760  return RPCHelpMan{
761  "setban",
762  "Attempts to add or remove an IP/Subnet from the banned list.\n",
763  {
765  "The IP/Subnet (see getpeerinfo for nodes IP) with an optional "
766  "netmask (default is /32 = single IP)"},
768  "'add' to add an IP/Subnet to the list, 'remove' to remove an "
769  "IP/Subnet from the list"},
770  {"bantime", RPCArg::Type::NUM, /* default */ "0",
771  "time in seconds how long (or until when if [absolute] is set) "
772  "the IP is banned (0 or empty means using the default time of 24h "
773  "which can also be overwritten by the -bantime startup argument)"},
774  {"absolute", RPCArg::Type::BOOL, /* default */ "false",
775  "If set, the bantime must be an absolute timestamp expressed in " +
777  },
779  RPCExamples{
780  HelpExampleCli("setban", "\"192.168.0.6\" \"add\" 86400") +
781  HelpExampleCli("setban", "\"192.168.0.0/24\" \"add\"") +
782  HelpExampleRpc("setban", "\"192.168.0.6\", \"add\", 86400")},
783  [&](const RPCHelpMan &help, const Config &config,
784  const JSONRPCRequest &request) -> UniValue {
785  std::string strCommand;
786  if (!request.params[1].isNull()) {
787  strCommand = request.params[1].get_str();
788  }
789 
790  if (request.fHelp || !help.IsValidNumArgs(request.params.size()) ||
791  (strCommand != "add" && strCommand != "remove")) {
792  throw std::runtime_error(help.ToString());
793  }
794 
795  NodeContext &node = EnsureNodeContext(request.context);
796  if (!node.banman) {
798  "Error: Ban database not loaded");
799  }
800 
801  CSubNet subNet;
802  CNetAddr netAddr;
803  bool isSubnet = false;
804 
805  if (request.params[0].get_str().find('/') != std::string::npos) {
806  isSubnet = true;
807  }
808 
809  if (!isSubnet) {
810  CNetAddr resolved;
811  LookupHost(request.params[0].get_str(), resolved, false);
812  netAddr = resolved;
813  } else {
814  LookupSubNet(request.params[0].get_str(), subNet);
815  }
816 
817  if (!(isSubnet ? subNet.IsValid() : netAddr.IsValid())) {
819  "Error: Invalid IP/Subnet");
820  }
821 
822  if (strCommand == "add") {
823  if (isSubnet ? node.banman->IsBanned(subNet)
824  : node.banman->IsBanned(netAddr)) {
826  "Error: IP/Subnet already banned");
827  }
828 
829  // Use standard bantime if not specified.
830  int64_t banTime = 0;
831  if (!request.params[2].isNull()) {
832  banTime = request.params[2].get_int64();
833  }
834 
835  bool absolute = false;
836  if (request.params[3].isTrue()) {
837  absolute = true;
838  }
839 
840  if (isSubnet) {
841  node.banman->Ban(subNet, banTime, absolute);
842  if (node.connman) {
843  node.connman->DisconnectNode(subNet);
844  }
845  } else {
846  node.banman->Ban(netAddr, banTime, absolute);
847  if (node.connman) {
848  node.connman->DisconnectNode(netAddr);
849  }
850  }
851  } else if (strCommand == "remove") {
852  if (!(isSubnet ? node.banman->Unban(subNet)
853  : node.banman->Unban(netAddr))) {
854  throw JSONRPCError(
856  "Error: Unban failed. Requested address/subnet "
857  "was not previously manually banned.");
858  }
859  }
860  return NullUniValue;
861  },
862  };
863 }
864 
866  return RPCHelpMan{
867  "listbanned",
868  "List all manually banned IPs/Subnets.\n",
869  {},
871  "",
872  "",
873  {
875  "",
876  "",
877  {
878  {RPCResult::Type::STR, "address", ""},
879  {RPCResult::Type::NUM_TIME, "banned_until", ""},
880  {RPCResult::Type::NUM_TIME, "ban_created", ""},
881  {RPCResult::Type::STR, "ban_reason", ""},
882  }},
883  }},
884  RPCExamples{HelpExampleCli("listbanned", "") +
885  HelpExampleRpc("listbanned", "")},
886  [&](const RPCHelpMan &self, const Config &config,
887  const JSONRPCRequest &request) -> UniValue {
888  NodeContext &node = EnsureNodeContext(request.context);
889  if (!node.banman) {
891  "Error: Ban database not loaded");
892  }
893 
894  banmap_t banMap;
895  node.banman->GetBanned(banMap);
896 
897  UniValue bannedAddresses(UniValue::VARR);
898  for (const auto &entry : banMap) {
899  const CBanEntry &banEntry = entry.second;
901  rec.pushKV("address", entry.first.ToString());
902  rec.pushKV("banned_until", banEntry.nBanUntil);
903  rec.pushKV("ban_created", banEntry.nCreateTime);
904 
905  bannedAddresses.push_back(rec);
906  }
907 
908  return bannedAddresses;
909  },
910  };
911 }
912 
914  return RPCHelpMan{
915  "clearbanned",
916  "Clear all banned IPs.\n",
917  {},
919  RPCExamples{HelpExampleCli("clearbanned", "") +
920  HelpExampleRpc("clearbanned", "")},
921  [&](const RPCHelpMan &self, const Config &config,
922  const JSONRPCRequest &request) -> UniValue {
923  NodeContext &node = EnsureNodeContext(request.context);
924  if (!node.banman) {
925  throw JSONRPCError(
927  "Error: Peer-to-peer functionality missing or disabled");
928  }
929 
930  node.banman->ClearBanned();
931 
932  return NullUniValue;
933  },
934  };
935 }
936 
938  return RPCHelpMan{
939  "setnetworkactive",
940  "Disable/enable all p2p network activity.\n",
941  {
943  "true to enable networking, false to disable"},
944  },
945  RPCResult{RPCResult::Type::BOOL, "", "The value that was passed in"},
946  RPCExamples{""},
947  [&](const RPCHelpMan &self, const Config &config,
948  const JSONRPCRequest &request) -> UniValue {
949  NodeContext &node = EnsureNodeContext(request.context);
950  if (!node.banman) {
951  throw JSONRPCError(
953  "Error: Peer-to-peer functionality missing or disabled");
954  }
955 
956  node.connman->SetNetworkActive(request.params[0].get_bool());
957 
958  return node.connman->GetNetworkActive();
959  },
960  };
961 }
962 
964  return RPCHelpMan{
965  "getnodeaddresses",
966  "Return known addresses which can potentially be used to find new "
967  "nodes in the network\n",
968  {
969  {"count", RPCArg::Type::NUM, /* default */ "1",
970  "The maximum number of addresses to return. Specify 0 to return "
971  "all known addresses."},
972  },
973  RPCResult{
975  "",
976  "",
977  {
979  "",
980  "",
981  {
982  {RPCResult::Type::NUM_TIME, "time",
983  "The " + UNIX_EPOCH_TIME +
984  " of when the node was last seen"},
985  {RPCResult::Type::NUM, "services", "The services offered"},
986  {RPCResult::Type::STR, "address",
987  "The address of the node"},
988  {RPCResult::Type::NUM, "port", "The port of the node"},
989  }},
990  }},
991  RPCExamples{HelpExampleCli("getnodeaddresses", "8") +
992  HelpExampleRpc("getnodeaddresses", "8")},
993  [&](const RPCHelpMan &self, const Config &config,
994  const JSONRPCRequest &request) -> UniValue {
995  NodeContext &node = EnsureNodeContext(request.context);
996  if (!node.banman) {
997  throw JSONRPCError(
999  "Error: Peer-to-peer functionality missing or disabled");
1000  }
1001 
1002  int count = 1;
1003  if (!request.params[0].isNull()) {
1004  count = request.params[0].get_int();
1005  if (count < 0) {
1007  "Address count out of range");
1008  }
1009  }
1010  // returns a shuffled list of CAddress
1011  std::vector<CAddress> vAddr =
1012  node.connman->GetAddresses(count, /* max_pct */ 0);
1013  UniValue ret(UniValue::VARR);
1014 
1015  for (const CAddress &addr : vAddr) {
1016  UniValue obj(UniValue::VOBJ);
1017  obj.pushKV("time", int(addr.nTime));
1018  obj.pushKV("services", uint64_t(addr.nServices));
1019  obj.pushKV("address", addr.ToStringIP());
1020  obj.pushKV("port", addr.GetPort());
1021  ret.push_back(obj);
1022  }
1023  return ret;
1024  },
1025  };
1026 }
1027 
1029  return RPCHelpMan{
1030  "addpeeraddress",
1031  "Add the address of a potential peer to the address manager. This "
1032  "RPC is for testing only.\n",
1033  {
1035  "The IP address of the peer"},
1037  "The port of the peer"},
1038  },
1039  RPCResult{
1041  "",
1042  "",
1043  {
1044  {RPCResult::Type::BOOL, "success",
1045  "whether the peer address was successfully added to the "
1046  "address manager"},
1047  },
1048  },
1049  RPCExamples{HelpExampleCli("addpeeraddress", "\"1.2.3.4\" 8333") +
1050  HelpExampleRpc("addpeeraddress", "\"1.2.3.4\", 8333")},
1051  [&](const RPCHelpMan &self, const Config &config,
1052  const JSONRPCRequest &request) -> UniValue {
1053  NodeContext &node = EnsureNodeContext(request.context);
1054  if (!node.connman) {
1055  throw JSONRPCError(
1057  "Error: Peer-to-peer functionality missing or disabled");
1058  }
1059 
1060  UniValue obj(UniValue::VOBJ);
1061 
1062  std::string addr_string = request.params[0].get_str();
1063  uint16_t port = request.params[1].get_int();
1064 
1065  CNetAddr net_addr;
1066  if (!LookupHost(addr_string, net_addr, false)) {
1067  obj.pushKV("success", false);
1068  return obj;
1069  }
1070  CAddress address =
1071  CAddress({net_addr, port}, ServiceFlags(NODE_NETWORK));
1072  address.nTime = GetAdjustedTime();
1073  // The source address is set equal to the address. This is
1074  // equivalent to the peer announcing itself.
1075  if (!node.connman->AddNewAddresses({address}, address)) {
1076  obj.pushKV("success", false);
1077  return obj;
1078  }
1079 
1080  obj.pushKV("success", true);
1081  return obj;
1082  },
1083  };
1084 }
1085 
1087  // clang-format off
1088  static const CRPCCommand commands[] = {
1089  // category name actor (function) argNames
1090  // ------------------- ------------------------ ---------------------- ----------
1091  { "network", "getconnectioncount", getconnectioncount, {} },
1092  { "network", "ping", ping, {} },
1093  { "network", "getpeerinfo", getpeerinfo, {} },
1094  { "network", "addnode", addnode, {"node","command"} },
1095  { "network", "disconnectnode", disconnectnode, {"address", "nodeid"} },
1096  { "network", "getaddednodeinfo", getaddednodeinfo, {"node"} },
1097  { "network", "getnettotals", getnettotals, {} },
1098  { "network", "getnetworkinfo", getnetworkinfo, {} },
1099  { "network", "setban", setban, {"subnet", "command", "bantime", "absolute"} },
1100  { "network", "listbanned", listbanned, {} },
1101  { "network", "clearbanned", clearbanned, {} },
1102  { "network", "setnetworkactive", setnetworkactive, {"state"} },
1103  { "network", "getnodeaddresses", getnodeaddresses, {"count"} },
1104  { "hidden", "addpeeraddress", addpeeraddress, {"address", "port"} },
1105  };
1106  // clang-format on
1107  for (const auto &c : commands) {
1108  t.appendCommand(c.name, &c);
1109  }
1110 }
getnettotals
static RPCHelpMan getnettotals()
Definition: net.cpp:544
CNodeStateStats::vHeightInFlight
std::vector< int > vHeightInFlight
Definition: net_processing.h:242
HelpExampleCli
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
Definition: util.cpp:157
CNodeStateStats::nCommonHeight
int nCommonHeight
Definition: net_processing.h:241
ToString
std::string ToString(const T &t)
Locale-independent version of std::to_string.
Definition: string.h:69
proxyType::IsValid
bool IsValid() const
Definition: netbase.h:35
NET_UNROUTABLE
@ NET_UNROUTABLE
Addresses from these networks are not publicly routable on the global Internet.
Definition: netaddress.h:46
UniValue::VOBJ
@ VOBJ
Definition: univalue.h:27
count
static int count
Definition: tests.c:41
getaddednodeinfo
static RPCHelpMan getaddednodeinfo()
Definition: net.cpp:454
CONNECTION_TYPE_DOC
const std::vector< std::string > CONNECTION_TYPE_DOC
Definition: net.h:141
NetPermissions::ToStrings
static std::vector< std::string > ToStrings(NetPermissionFlags flags)
Definition: net_permissions.cpp:97
settings.h
RPC_CLIENT_P2P_DISABLED
@ RPC_CLIENT_P2P_DISABLED
No valid connection manager instance found.
Definition: protocol.h:81
EnsureNodeContext
NodeContext & EnsureNodeContext(const util::Ref &context)
Definition: blockchain.cpp:56
avalanche.h
CNodeStateStats::m_misbehavior_score
int m_misbehavior_score
Definition: net_processing.h:239
NET_INTERNAL
@ NET_INTERNAL
A set of addresses that represent the hash of a string or FQDN.
Definition: netaddress.h:65
help
static RPCHelpMan help()
Definition: server.cpp:177
GetWarnings
bilingual_str GetWarnings(bool verbose)
Format a string that describes several potential problems detected by the core.
Definition: warnings.cpp:41
RPCHelpMan
Definition: util.h:334
sync.h
NET_MESSAGE_COMMAND_OTHER
const std::string NET_MESSAGE_COMMAND_OTHER
Definition: net.cpp:118
timedata.h
setnetworkactive
static RPCHelpMan setnetworkactive()
Definition: net.cpp:937
NullUniValue
const UniValue NullUniValue
Definition: univalue.cpp:13
string.h
CNetAddr
Network address.
Definition: netaddress.h:117
g_relay_txes
bool g_relay_txes
Definition: net.cpp:133
RPC_INVALID_PARAMETER
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
Definition: protocol.h:46
getconnectioncount
static RPCHelpMan getconnectioncount()
Definition: net.cpp:35
NET_MAX
@ NET_MAX
Dummy value to indicate the number of NET_* constants.
Definition: netaddress.h:68
GetServicesNames
UniValue GetServicesNames(ServiceFlags services)
Returns, given services flags, a list of humanly readable (known) network services.
Definition: util.cpp:940
CNode
Information about a peer.
Definition: net.h:926
RPCArg::Optional::NO
@ NO
Required arg.
CNode::fPingQueued
std::atomic< bool > fPingQueued
Definition: net.h:1232
RPCArg::Type::STR
@ STR
minRelayTxFee
CFeeRate minRelayTxFee
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation)
Definition: validation.cpp:122
protocol.h
CNodeStateStats::nSyncHeight
int nSyncHeight
Definition: net_processing.h:240
setban
static RPCHelpMan setban()
Definition: net.cpp:759
RPCResult::Type::NUM
@ NUM
clearbanned
static RPCHelpMan clearbanned()
Definition: net.cpp:913
clientversion.h
ServiceFlags
ServiceFlags
nServices flags.
Definition: protocol.h:314
UniValue::isNull
bool isNull() const
Definition: univalue.h:89
NODE_NETWORK
@ NODE_NETWORK
Definition: protocol.h:321
Network
Network
A network type.
Definition: netaddress.h:43
CAddress::nTime
uint32_t nTime
Definition: protocol.h:462
GetNetworksInfo
static UniValue GetNetworksInfo()
Definition: net.cpp:613
context.h
version.h
core_io.h
proxyType
Definition: netbase.h:28
UniValue::pushKV
bool pushKV(const std::string &key, const UniValue &val)
Definition: univalue.cpp:133
CService::ToStringIPPort
std::string ToStringIPPort() const
Definition: netaddress.cpp:1012
g_avalanche
std::unique_ptr< avalanche::Processor > g_avalanche
Global avalanche instance.
Definition: processor.cpp:31
UniValue
Definition: univalue.h:23
ConnectionType::MANUAL
@ MANUAL
We open manual connections to addresses that users explicitly inputted via the addnode RPC,...
RPCArg::Type::NUM
@ NUM
UniValue::get_str
const std::string & get_str() const
Definition: univalue_get.cpp:98
strencodings.h
Config
Definition: config.h:17
CFeeRate::GetFeePerK
Amount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
Definition: feerate.h:54
UniValue::isStr
bool isStr() const
Definition: univalue.h:93
net_types.h
banman.h
RPCHelpMan::ToString
std::string ToString() const
Definition: util.cpp:527
UniValue::get_int64
int64_t get_int64() const
Definition: univalue_get.cpp:115
RPCHelpMan::IsValidNumArgs
bool IsValidNumArgs(size_t num_args) const
If the supplied number of args is neither too small nor too high.
Definition: util.cpp:508
cs_main
RecursiveMutex cs_main
Global state.
Definition: validation.cpp:103
RPCResult::Type::OBJ
@ OBJ
CRPCCommand
Definition: server.h:149
RPCResult::Type::NONE
@ NONE
IsReachable
bool IsReachable(enum Network net)
Definition: net.cpp:297
CConnman::CONNECTIONS_ALL
@ CONNECTIONS_ALL
Definition: net.h:227
cs_mapLocalHost
RecursiveMutex cs_mapLocalHost
Definition: net.cpp:134
univalue.h
RPC_DATABASE_ERROR
@ RPC_DATABASE_ERROR
Database error.
Definition: protocol.h:48
Currency::get
static const Currency & get()
Definition: amount.cpp:19
RPCResult::Type::STR_HEX
@ STR_HEX
Special string with only hex chars.
AddedNodeInfo
Definition: net.h:119
RPCExamples
Definition: util.h:326
CNetAddr::IsValid
bool IsValid() const
Definition: netaddress.cpp:438
CSubNet
Definition: netaddress.h:465
CConnman::CONNECTIONS_IN
@ CONNECTIONS_IN
Definition: net.h:225
CBanEntry::nCreateTime
int64_t nCreateTime
Definition: addrdb.h:25
RPCResult::Type::STR
@ STR
RPCResult::Type::NUM_TIME
@ NUM_TIME
Special numeric to denote unix epoch time.
RPCResult::Type::ARR
@ ARR
HelpExampleRpc
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
Definition: util.cpp:162
net_processing.h
ping
static RPCHelpMan ping()
Definition: net.cpp:57
CRPCTable
RPC command dispatcher.
Definition: server.h:202
RegisterNetRPCCommands
void RegisterNetRPCCommands(CRPCTable &t)
Register P2P networking RPC commands.
Definition: net.cpp:1086
system.h
Currency::ticker
std::string ticker
Definition: amount.h:160
CLIENT_VERSION
static constexpr int CLIENT_VERSION
bitcoind-res.rc includes this file, but it cannot cope with real c++ code.
Definition: clientversion.h:44
addpeeraddress
static RPCHelpMan addpeeraddress()
Definition: net.cpp:1028
strprintf
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1201
Join
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
Definition: string.h:36
CRPCTable::appendCommand
void appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
Definition: server.cpp:318
disconnectnode
static RPCHelpMan disconnectnode()
Definition: net.cpp:395
CConnman::CONNECTIONS_OUT
@ CONNECTIONS_OUT
Definition: net.h:226
GetAdjustedTime
int64_t GetAdjustedTime()
Definition: timedata.cpp:34
CAddress
A CService with information about it as peer.
Definition: protocol.h:421
LookupHost
bool LookupHost(const std::string &name, std::vector< CNetAddr > &vIP, unsigned int nMaxSolutions, bool fAllowLookup)
Resolve a host string to its corresponding network addresses.
Definition: netbase.cpp:165
NodeContext::banman
std::unique_ptr< BanMan > banman
Definition: context.h:42
RPCResult::Type::BOOL
@ BOOL
translation.h
JSONRPCError
UniValue JSONRPCError(int code, const std::string &message)
Definition: request.cpp:52
proxyType::randomize_credentials
bool randomize_credentials
Definition: netbase.h:38
LOCK
#define LOCK(cs)
Definition: sync.h:241
gArgs
ArgsManager gArgs
Definition: system.cpp:75
RPC_CLIENT_NODE_ALREADY_ADDED
@ RPC_CLIENT_NODE_ALREADY_ADDED
Node is already added.
Definition: protocol.h:73
RPCArg::Type::BOOL
@ BOOL
GetNodeStateStats
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats)
Get statistics from node state.
Definition: net_processing.cpp:1230
CBanEntry
Definition: addrdb.h:21
UniValue::push_back
bool push_back(const UniValue &val)
Definition: univalue.cpp:108
CNodeStats
POD that contains various stats about a node.
Definition: net.h:757
CBanEntry::nBanUntil
int64_t nBanUntil
Definition: addrdb.h:26
network.h
RPC_CLIENT_NODE_NOT_ADDED
@ RPC_CLIENT_NODE_NOT_ADDED
Node has not been added before.
Definition: protocol.h:75
CSubNet::IsValid
bool IsValid() const
Definition: netaddress.cpp:1155
GetProxy
bool GetProxy(enum Network net, proxyType &proxyInfoOut)
Definition: netbase.cpp:783
listbanned
static RPCHelpMan listbanned()
Definition: net.cpp:865
config.h
getpeerinfo
static RPCHelpMan getpeerinfo()
Definition: net.cpp:87
RPCResult::Type::OBJ_DYN
@ OBJ_DYN
Special dictionary with keys that are not literals.
NodeId
int64_t NodeId
Definition: nodeid.h:10
RPC_CLIENT_NODE_NOT_CONNECTED
@ RPC_CLIENT_NODE_NOT_CONNECTED
Node to disconnect not found in connected nodes.
Definition: protocol.h:77
JSONRPCRequest
Definition: request.h:33
banmap_t
std::map< CSubNet, CBanEntry > banmap_t
Definition: net_types.h:13
util.h
netbase.h
RPCResult
Definition: util.h:247
GetNetworkName
std::string GetNetworkName(enum Network net)
Definition: netbase.cpp:60
IsDeprecatedRPCEnabled
bool IsDeprecatedRPCEnabled(const ArgsManager &args, const std::string &method)
Definition: server.cpp:398
blockchain.h
RPC_INVALID_PARAMS
@ RPC_INVALID_PARAMS
Definition: protocol.h:30
GetTimeOffset
int64_t GetTimeOffset()
"Never go to sea with two chronometers; take one or three." Our three time sources are:
Definition: timedata.cpp:29
NodeContext::connman
std::unique_ptr< CConnman > connman
Definition: context.h:37
UniValue::VARR
@ VARR
Definition: univalue.h:27
NodeContext
NodeContext struct containing references to chain state and connection state.
Definition: context.h:36
server.h
CNodeStateStats
Definition: net_processing.h:238
net.h
userAgent
std::string userAgent(const Config &config)
Definition: net.cpp:3444
warnings.h
getnetworkinfo
static RPCHelpMan getnetworkinfo()
Definition: net.cpp:634
GetTimeMillis
int64_t GetTimeMillis()
Returns the system time (not mockable)
Definition: time.cpp:59
UNIX_EPOCH_TIME
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency.
Definition: util.cpp:21
getnodeaddresses
static RPCHelpMan getnodeaddresses()
Definition: net.cpp:963
proxyType::proxy
CService proxy
Definition: netbase.h:37
RPC_CLIENT_INVALID_IP_OR_SUBNET
@ RPC_CLIENT_INVALID_IP_OR_SUBNET
Invalid IP/Subnet.
Definition: protocol.h:79
LookupSubNet
bool LookupSubNet(const std::string &strSubnet, CSubNet &ret)
Parse and resolve a specified subnet string into the appropriate internal representation.
Definition: netbase.cpp:891
addnode
static RPCHelpMan addnode()
Definition: net.cpp:328
net_permissions.h
PROTOCOL_VERSION
static const int PROTOCOL_VERSION
network protocol versioning
Definition: version.h:11