Bitcoin Core  22.99.0
P2P Digital Currency
misc.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2021 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #include <httpserver.h>
8 #include <index/coinstatsindex.h>
9 #include <index/txindex.h>
10 #include <interfaces/chain.h>
11 #include <interfaces/echo.h>
12 #include <interfaces/init.h>
13 #include <interfaces/ipc.h>
14 #include <key_io.h>
15 #include <node/context.h>
16 #include <outputtype.h>
17 #include <rpc/blockchain.h>
18 #include <rpc/server.h>
19 #include <rpc/server_util.h>
20 #include <rpc/util.h>
21 #include <scheduler.h>
22 #include <script/descriptor.h>
23 #include <util/check.h>
24 #include <util/message.h> // For MessageSign(), MessageVerify()
25 #include <util/strencodings.h>
26 #include <util/syscall_sandbox.h>
27 #include <util/system.h>
28 
29 #include <optional>
30 #include <stdint.h>
31 #include <tuple>
32 #ifdef HAVE_MALLOC_INFO
33 #include <malloc.h>
34 #endif
35 
36 #include <univalue.h>
37 
38 using node::NodeContext;
39 
41 {
42  return RPCHelpMan{
43  "validateaddress",
44  "\nReturn information about the given bitcoin address.\n",
45  {
46  {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The bitcoin address to validate"},
47  },
48  RPCResult{
49  RPCResult::Type::OBJ, "", "",
50  {
51  {RPCResult::Type::BOOL, "isvalid", "If the address is valid or not"},
52  {RPCResult::Type::STR, "address", /*optional=*/true, "The bitcoin address validated"},
53  {RPCResult::Type::STR_HEX, "scriptPubKey", /*optional=*/true, "The hex-encoded scriptPubKey generated by the address"},
54  {RPCResult::Type::BOOL, "isscript", /*optional=*/true, "If the key is a script"},
55  {RPCResult::Type::BOOL, "iswitness", /*optional=*/true, "If the address is a witness address"},
56  {RPCResult::Type::NUM, "witness_version", /*optional=*/true, "The version number of the witness program"},
57  {RPCResult::Type::STR_HEX, "witness_program", /*optional=*/true, "The hex value of the witness program"},
58  {RPCResult::Type::STR, "error", /*optional=*/true, "Error message, if any"},
59  {RPCResult::Type::ARR, "error_locations", /*optional=*/true, "Indices of likely error locations in address, if known (e.g. Bech32 errors)",
60  {
61  {RPCResult::Type::NUM, "index", "index of a potential error"},
62  }},
63  }
64  },
66  HelpExampleCli("validateaddress", "\"" + EXAMPLE_ADDRESS[0] + "\"") +
67  HelpExampleRpc("validateaddress", "\"" + EXAMPLE_ADDRESS[0] + "\"")
68  },
69  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
70 {
71  std::string error_msg;
72  std::vector<int> error_locations;
73  CTxDestination dest = DecodeDestination(request.params[0].get_str(), error_msg, &error_locations);
74  const bool isValid = IsValidDestination(dest);
75  CHECK_NONFATAL(isValid == error_msg.empty());
76 
78  ret.pushKV("isvalid", isValid);
79  if (isValid) {
80  std::string currentAddress = EncodeDestination(dest);
81  ret.pushKV("address", currentAddress);
82 
83  CScript scriptPubKey = GetScriptForDestination(dest);
84  ret.pushKV("scriptPubKey", HexStr(scriptPubKey));
85 
86  UniValue detail = DescribeAddress(dest);
87  ret.pushKVs(detail);
88  } else {
89  UniValue error_indices(UniValue::VARR);
90  for (int i : error_locations) error_indices.push_back(i);
91  ret.pushKV("error_locations", error_indices);
92  ret.pushKV("error", error_msg);
93  }
94 
95  return ret;
96 },
97  };
98 }
99 
101 {
102  return RPCHelpMan{"createmultisig",
103  "\nCreates a multi-signature address with n signature of m keys required.\n"
104  "It returns a json object with the address and redeemScript.\n",
105  {
106  {"nrequired", RPCArg::Type::NUM, RPCArg::Optional::NO, "The number of required signatures out of the n keys."},
107  {"keys", RPCArg::Type::ARR, RPCArg::Optional::NO, "The hex-encoded public keys.",
108  {
109  {"key", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, "The hex-encoded public key"},
110  }},
111  {"address_type", RPCArg::Type::STR, RPCArg::Default{"legacy"}, "The address type to use. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\"."},
112  },
113  RPCResult{
114  RPCResult::Type::OBJ, "", "",
115  {
116  {RPCResult::Type::STR, "address", "The value of the new multisig address."},
117  {RPCResult::Type::STR_HEX, "redeemScript", "The string value of the hex-encoded redemption script."},
118  {RPCResult::Type::STR, "descriptor", "The descriptor for this multisig"},
119  {RPCResult::Type::ARR, "warnings", /* optional */ true, "Any warnings resulting from the creation of this multisig",
120  {
121  {RPCResult::Type::STR, "", ""},
122  }},
123  }
124  },
125  RPCExamples{
126  "\nCreate a multisig address from 2 public keys\n"
127  + HelpExampleCli("createmultisig", "2 \"[\\\"03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd\\\",\\\"03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626\\\"]\"") +
128  "\nAs a JSON-RPC call\n"
129  + HelpExampleRpc("createmultisig", "2, [\"03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd\",\"03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626\"]")
130  },
131  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
132 {
133  int required = request.params[0].get_int();
134 
135  // Get the public keys
136  const UniValue& keys = request.params[1].get_array();
137  std::vector<CPubKey> pubkeys;
138  for (unsigned int i = 0; i < keys.size(); ++i) {
139  if (IsHex(keys[i].get_str()) && (keys[i].get_str().length() == 66 || keys[i].get_str().length() == 130)) {
140  pubkeys.push_back(HexToPubKey(keys[i].get_str()));
141  } else {
142  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Invalid public key: %s\n.", keys[i].get_str()));
143  }
144  }
145 
146  // Get the output type
147  OutputType output_type = OutputType::LEGACY;
148  if (!request.params[2].isNull()) {
149  std::optional<OutputType> parsed = ParseOutputType(request.params[2].get_str());
150  if (!parsed) {
151  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address type '%s'", request.params[2].get_str()));
152  } else if (parsed.value() == OutputType::BECH32M) {
153  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "createmultisig cannot create bech32m multisig addresses");
154  }
155  output_type = parsed.value();
156  }
157 
158  // Construct using pay-to-script-hash:
159  FillableSigningProvider keystore;
160  CScript inner;
161  const CTxDestination dest = AddAndGetMultisigDestination(required, pubkeys, output_type, keystore, inner);
162 
163  // Make the descriptor
164  std::unique_ptr<Descriptor> descriptor = InferDescriptor(GetScriptForDestination(dest), keystore);
165 
166  UniValue result(UniValue::VOBJ);
167  result.pushKV("address", EncodeDestination(dest));
168  result.pushKV("redeemScript", HexStr(inner));
169  result.pushKV("descriptor", descriptor->ToString());
170 
171  UniValue warnings(UniValue::VARR);
172  if (!request.params[2].isNull() && OutputTypeFromDestination(dest) != output_type) {
173  // Only warns if the user has explicitly chosen an address type we cannot generate
174  warnings.push_back("Unable to make chosen address type, please ensure no uncompressed public keys are present.");
175  }
176  if (warnings.size()) result.pushKV("warnings", warnings);
177 
178  return result;
179 },
180  };
181 }
182 
184 {
185  const std::string EXAMPLE_DESCRIPTOR = "wpkh([d34db33f/84h/0h/0h]0279be667ef9dcbbac55a06295Ce870b07029Bfcdb2dce28d959f2815b16f81798)";
186 
187  return RPCHelpMan{"getdescriptorinfo",
188  {"\nAnalyses a descriptor.\n"},
189  {
190  {"descriptor", RPCArg::Type::STR, RPCArg::Optional::NO, "The descriptor."},
191  },
192  RPCResult{
193  RPCResult::Type::OBJ, "", "",
194  {
195  {RPCResult::Type::STR, "descriptor", "The descriptor in canonical form, without private keys"},
196  {RPCResult::Type::STR, "checksum", "The checksum for the input descriptor"},
197  {RPCResult::Type::BOOL, "isrange", "Whether the descriptor is ranged"},
198  {RPCResult::Type::BOOL, "issolvable", "Whether the descriptor is solvable"},
199  {RPCResult::Type::BOOL, "hasprivatekeys", "Whether the input descriptor contained at least one private key"},
200  }
201  },
202  RPCExamples{
203  "Analyse a descriptor\n" +
204  HelpExampleCli("getdescriptorinfo", "\"" + EXAMPLE_DESCRIPTOR + "\"") +
205  HelpExampleRpc("getdescriptorinfo", "\"" + EXAMPLE_DESCRIPTOR + "\"")
206  },
207  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
208 {
209  RPCTypeCheck(request.params, {UniValue::VSTR});
210 
211  FlatSigningProvider provider;
212  std::string error;
213  auto desc = Parse(request.params[0].get_str(), provider, error);
214  if (!desc) {
216  }
217 
218  UniValue result(UniValue::VOBJ);
219  result.pushKV("descriptor", desc->ToString());
220  result.pushKV("checksum", GetDescriptorChecksum(request.params[0].get_str()));
221  result.pushKV("isrange", desc->IsRange());
222  result.pushKV("issolvable", desc->IsSolvable());
223  result.pushKV("hasprivatekeys", provider.keys.size() > 0);
224  return result;
225 },
226  };
227 }
228 
230 {
231  const std::string EXAMPLE_DESCRIPTOR = "wpkh([d34db33f/84h/0h/0h]xpub6DJ2dNUysrn5Vt36jH2KLBT2i1auw1tTSSomg8PhqNiUtx8QX2SvC9nrHu81fT41fvDUnhMjEzQgXnQjKEu3oaqMSzhSrHMxyyoEAmUHQbY/0/*)#cjjspncu";
232 
233  return RPCHelpMan{"deriveaddresses",
234  {"\nDerives one or more addresses corresponding to an output descriptor.\n"
235  "Examples of output descriptors are:\n"
236  " pkh(<pubkey>) P2PKH outputs for the given pubkey\n"
237  " wpkh(<pubkey>) Native segwit P2PKH outputs for the given pubkey\n"
238  " sh(multi(<n>,<pubkey>,<pubkey>,...)) P2SH-multisig outputs for the given threshold and pubkeys\n"
239  " raw(<hex script>) Outputs whose scriptPubKey equals the specified hex scripts\n"
240  "\nIn the above, <pubkey> either refers to a fixed public key in hexadecimal notation, or to an xpub/xprv optionally followed by one\n"
241  "or more path elements separated by \"/\", where \"h\" represents a hardened child key.\n"
242  "For more information on output descriptors, see the documentation in the doc/descriptors.md file.\n"},
243  {
244  {"descriptor", RPCArg::Type::STR, RPCArg::Optional::NO, "The descriptor."},
245  {"range", RPCArg::Type::RANGE, RPCArg::Optional::OMITTED_NAMED_ARG, "If a ranged descriptor is used, this specifies the end or the range (in [begin,end] notation) to derive."},
246  },
247  RPCResult{
248  RPCResult::Type::ARR, "", "",
249  {
250  {RPCResult::Type::STR, "address", "the derived addresses"},
251  }
252  },
253  RPCExamples{
254  "First three native segwit receive addresses\n" +
255  HelpExampleCli("deriveaddresses", "\"" + EXAMPLE_DESCRIPTOR + "\" \"[0,2]\"") +
256  HelpExampleRpc("deriveaddresses", "\"" + EXAMPLE_DESCRIPTOR + "\", \"[0,2]\"")
257  },
258  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
259 {
260  RPCTypeCheck(request.params, {UniValue::VSTR, UniValueType()}); // Range argument is checked later
261  const std::string desc_str = request.params[0].get_str();
262 
263  int64_t range_begin = 0;
264  int64_t range_end = 0;
265 
266  if (request.params.size() >= 2 && !request.params[1].isNull()) {
267  std::tie(range_begin, range_end) = ParseDescriptorRange(request.params[1]);
268  }
269 
270  FlatSigningProvider key_provider;
271  std::string error;
272  auto desc = Parse(desc_str, key_provider, error, /* require_checksum = */ true);
273  if (!desc) {
275  }
276 
277  if (!desc->IsRange() && request.params.size() > 1) {
278  throw JSONRPCError(RPC_INVALID_PARAMETER, "Range should not be specified for an un-ranged descriptor");
279  }
280 
281  if (desc->IsRange() && request.params.size() == 1) {
282  throw JSONRPCError(RPC_INVALID_PARAMETER, "Range must be specified for a ranged descriptor");
283  }
284 
285  UniValue addresses(UniValue::VARR);
286 
287  for (int i = range_begin; i <= range_end; ++i) {
288  FlatSigningProvider provider;
289  std::vector<CScript> scripts;
290  if (!desc->Expand(i, key_provider, scripts, provider)) {
291  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Cannot derive script without private keys");
292  }
293 
294  for (const CScript &script : scripts) {
295  CTxDestination dest;
296  if (!ExtractDestination(script, dest)) {
297  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Descriptor does not have a corresponding address");
298  }
299 
300  addresses.push_back(EncodeDestination(dest));
301  }
302  }
303 
304  // This should not be possible, but an assert seems overkill:
305  if (addresses.empty()) {
306  throw JSONRPCError(RPC_MISC_ERROR, "Unexpected empty result");
307  }
308 
309  return addresses;
310 },
311  };
312 }
313 
315 {
316  return RPCHelpMan{"verifymessage",
317  "Verify a signed message.",
318  {
319  {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The bitcoin address to use for the signature."},
320  {"signature", RPCArg::Type::STR, RPCArg::Optional::NO, "The signature provided by the signer in base 64 encoding (see signmessage)."},
321  {"message", RPCArg::Type::STR, RPCArg::Optional::NO, "The message that was signed."},
322  },
323  RPCResult{
324  RPCResult::Type::BOOL, "", "If the signature is verified or not."
325  },
326  RPCExamples{
327  "\nUnlock the wallet for 30 seconds\n"
328  + HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") +
329  "\nCreate the signature\n"
330  + HelpExampleCli("signmessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"my message\"") +
331  "\nVerify the signature\n"
332  + HelpExampleCli("verifymessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"signature\" \"my message\"") +
333  "\nAs a JSON-RPC call\n"
334  + HelpExampleRpc("verifymessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"signature\", \"my message\"")
335  },
336  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
337 {
338  LOCK(cs_main);
339 
340  std::string strAddress = request.params[0].get_str();
341  std::string strSign = request.params[1].get_str();
342  std::string strMessage = request.params[2].get_str();
343 
344  switch (MessageVerify(strAddress, strSign, strMessage)) {
346  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
348  throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key");
350  throw JSONRPCError(RPC_TYPE_ERROR, "Malformed base64 encoding");
353  return false;
355  return true;
356  }
357 
358  return false;
359 },
360  };
361 }
362 
364 {
365  return RPCHelpMan{"signmessagewithprivkey",
366  "\nSign a message with the private key of an address\n",
367  {
368  {"privkey", RPCArg::Type::STR, RPCArg::Optional::NO, "The private key to sign the message with."},
369  {"message", RPCArg::Type::STR, RPCArg::Optional::NO, "The message to create a signature of."},
370  },
371  RPCResult{
372  RPCResult::Type::STR, "signature", "The signature of the message encoded in base 64"
373  },
374  RPCExamples{
375  "\nCreate the signature\n"
376  + HelpExampleCli("signmessagewithprivkey", "\"privkey\" \"my message\"") +
377  "\nVerify the signature\n"
378  + HelpExampleCli("verifymessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"signature\" \"my message\"") +
379  "\nAs a JSON-RPC call\n"
380  + HelpExampleRpc("signmessagewithprivkey", "\"privkey\", \"my message\"")
381  },
382  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
383 {
384  std::string strPrivkey = request.params[0].get_str();
385  std::string strMessage = request.params[1].get_str();
386 
387  CKey key = DecodeSecret(strPrivkey);
388  if (!key.IsValid()) {
389  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key");
390  }
391 
392  std::string signature;
393 
394  if (!MessageSign(key, strMessage, signature)) {
395  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Sign failed");
396  }
397 
398  return signature;
399 },
400  };
401 }
402 
404 {
405  return RPCHelpMan{"setmocktime",
406  "\nSet the local time to given timestamp (-regtest only)\n",
407  {
409  "Pass 0 to go back to using the system time."},
410  },
412  RPCExamples{""},
413  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
414 {
415  if (!Params().IsMockableChain()) {
416  throw std::runtime_error("setmocktime is for regression testing (-regtest mode) only");
417  }
418 
419  // For now, don't change mocktime if we're in the middle of validation, as
420  // this could have an effect on mempool time-based eviction, as well as
421  // IsCurrentForFeeEstimation() and IsInitialBlockDownload().
422  // TODO: figure out the right way to synchronize around mocktime, and
423  // ensure all call sites of GetTime() are accessing this safely.
424  LOCK(cs_main);
425 
426  RPCTypeCheck(request.params, {UniValue::VNUM});
427  const int64_t time{request.params[0].get_int64()};
428  if (time < 0) {
429  throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Mocktime can not be negative: %s.", time));
430  }
431  SetMockTime(time);
432  auto node_context = util::AnyPtr<NodeContext>(request.context);
433  if (node_context) {
434  for (const auto& chain_client : node_context->chain_clients) {
435  chain_client->setMockTime(time);
436  }
437  }
438 
439  return NullUniValue;
440 },
441  };
442 }
443 
444 #if defined(USE_SYSCALL_SANDBOX)
445 static RPCHelpMan invokedisallowedsyscall()
446 {
447  return RPCHelpMan{
448  "invokedisallowedsyscall",
449  "\nInvoke a disallowed syscall to trigger a syscall sandbox violation. Used for testing purposes.\n",
450  {},
452  RPCExamples{
453  HelpExampleCli("invokedisallowedsyscall", "") + HelpExampleRpc("invokedisallowedsyscall", "")},
454  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue {
455  if (!Params().IsTestChain()) {
456  throw std::runtime_error("invokedisallowedsyscall is used for testing only.");
457  }
458  TestDisallowedSandboxCall();
459  return NullUniValue;
460  },
461  };
462 }
463 #endif // USE_SYSCALL_SANDBOX
464 
466 {
467  return RPCHelpMan{"mockscheduler",
468  "\nBump the scheduler into the future (-regtest only)\n",
469  {
470  {"delta_time", RPCArg::Type::NUM, RPCArg::Optional::NO, "Number of seconds to forward the scheduler into the future." },
471  },
473  RPCExamples{""},
474  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
475 {
476  if (!Params().IsMockableChain()) {
477  throw std::runtime_error("mockscheduler is for regression testing (-regtest mode) only");
478  }
479 
480  // check params are valid values
481  RPCTypeCheck(request.params, {UniValue::VNUM});
482  int64_t delta_seconds = request.params[0].get_int64();
483  if (delta_seconds <= 0 || delta_seconds > 3600) {
484  throw std::runtime_error("delta_time must be between 1 and 3600 seconds (1 hr)");
485  }
486 
487  auto node_context = util::AnyPtr<NodeContext>(request.context);
488  // protect against null pointer dereference
489  CHECK_NONFATAL(node_context);
490  CHECK_NONFATAL(node_context->scheduler);
491  node_context->scheduler->MockForward(std::chrono::seconds(delta_seconds));
492 
493  return NullUniValue;
494 },
495  };
496 }
497 
499 {
502  obj.pushKV("used", uint64_t(stats.used));
503  obj.pushKV("free", uint64_t(stats.free));
504  obj.pushKV("total", uint64_t(stats.total));
505  obj.pushKV("locked", uint64_t(stats.locked));
506  obj.pushKV("chunks_used", uint64_t(stats.chunks_used));
507  obj.pushKV("chunks_free", uint64_t(stats.chunks_free));
508  return obj;
509 }
510 
511 #ifdef HAVE_MALLOC_INFO
512 static std::string RPCMallocInfo()
513 {
514  char *ptr = nullptr;
515  size_t size = 0;
516  FILE *f = open_memstream(&ptr, &size);
517  if (f) {
518  malloc_info(0, f);
519  fclose(f);
520  if (ptr) {
521  std::string rv(ptr, size);
522  free(ptr);
523  return rv;
524  }
525  }
526  return "";
527 }
528 #endif
529 
531 {
532  /* Please, avoid using the word "pool" here in the RPC interface or help,
533  * as users will undoubtedly confuse it with the other "memory pool"
534  */
535  return RPCHelpMan{"getmemoryinfo",
536  "Returns an object containing information about memory usage.\n",
537  {
538  {"mode", RPCArg::Type::STR, RPCArg::Default{"stats"}, "determines what kind of information is returned.\n"
539  " - \"stats\" returns general statistics about memory usage in the daemon.\n"
540  " - \"mallocinfo\" returns an XML string describing low-level heap state (only available if compiled with glibc 2.10+)."},
541  },
542  {
543  RPCResult{"mode \"stats\"",
544  RPCResult::Type::OBJ, "", "",
545  {
546  {RPCResult::Type::OBJ, "locked", "Information about locked memory manager",
547  {
548  {RPCResult::Type::NUM, "used", "Number of bytes used"},
549  {RPCResult::Type::NUM, "free", "Number of bytes available in current arenas"},
550  {RPCResult::Type::NUM, "total", "Total number of bytes managed"},
551  {RPCResult::Type::NUM, "locked", "Amount of bytes that succeeded locking. If this number is smaller than total, locking pages failed at some point and key data could be swapped to disk."},
552  {RPCResult::Type::NUM, "chunks_used", "Number allocated chunks"},
553  {RPCResult::Type::NUM, "chunks_free", "Number unused chunks"},
554  }},
555  }
556  },
557  RPCResult{"mode \"mallocinfo\"",
558  RPCResult::Type::STR, "", "\"<malloc version=\"1\">...\""
559  },
560  },
561  RPCExamples{
562  HelpExampleCli("getmemoryinfo", "")
563  + HelpExampleRpc("getmemoryinfo", "")
564  },
565  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
566 {
567  std::string mode = request.params[0].isNull() ? "stats" : request.params[0].get_str();
568  if (mode == "stats") {
570  obj.pushKV("locked", RPCLockedMemoryInfo());
571  return obj;
572  } else if (mode == "mallocinfo") {
573 #ifdef HAVE_MALLOC_INFO
574  return RPCMallocInfo();
575 #else
576  throw JSONRPCError(RPC_INVALID_PARAMETER, "mallocinfo mode not available");
577 #endif
578  } else {
579  throw JSONRPCError(RPC_INVALID_PARAMETER, "unknown mode " + mode);
580  }
581 },
582  };
583 }
584 
585 static void EnableOrDisableLogCategories(UniValue cats, bool enable) {
586  cats = cats.get_array();
587  for (unsigned int i = 0; i < cats.size(); ++i) {
588  std::string cat = cats[i].get_str();
589 
590  bool success;
591  if (enable) {
592  success = LogInstance().EnableCategory(cat);
593  } else {
594  success = LogInstance().DisableCategory(cat);
595  }
596 
597  if (!success) {
598  throw JSONRPCError(RPC_INVALID_PARAMETER, "unknown logging category " + cat);
599  }
600  }
601 }
602 
604 {
605  return RPCHelpMan{"logging",
606  "Gets and sets the logging configuration.\n"
607  "When called without an argument, returns the list of categories with status that are currently being debug logged or not.\n"
608  "When called with arguments, adds or removes categories from debug logging and return the lists above.\n"
609  "The arguments are evaluated in order \"include\", \"exclude\".\n"
610  "If an item is both included and excluded, it will thus end up being excluded.\n"
611  "The valid logging categories are: " + LogInstance().LogCategoriesString() + "\n"
612  "In addition, the following are available as category names with special meanings:\n"
613  " - \"all\", \"1\" : represent all logging categories.\n"
614  " - \"none\", \"0\" : even if other logging categories are specified, ignore all of them.\n"
615  ,
616  {
617  {"include", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, "The categories to add to debug logging",
618  {
619  {"include_category", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "the valid logging category"},
620  }},
621  {"exclude", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, "The categories to remove from debug logging",
622  {
623  {"exclude_category", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "the valid logging category"},
624  }},
625  },
626  RPCResult{
627  RPCResult::Type::OBJ_DYN, "", "keys are the logging categories, and values indicates its status",
628  {
629  {RPCResult::Type::BOOL, "category", "if being debug logged or not. false:inactive, true:active"},
630  }
631  },
632  RPCExamples{
633  HelpExampleCli("logging", "\"[\\\"all\\\"]\" \"[\\\"http\\\"]\"")
634  + HelpExampleRpc("logging", "[\"all\"], [\"libevent\"]")
635  },
636  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
637 {
638  uint32_t original_log_categories = LogInstance().GetCategoryMask();
639  if (request.params[0].isArray()) {
640  EnableOrDisableLogCategories(request.params[0], true);
641  }
642  if (request.params[1].isArray()) {
643  EnableOrDisableLogCategories(request.params[1], false);
644  }
645  uint32_t updated_log_categories = LogInstance().GetCategoryMask();
646  uint32_t changed_log_categories = original_log_categories ^ updated_log_categories;
647 
648  // Update libevent logging if BCLog::LIBEVENT has changed.
649  // If the library version doesn't allow it, UpdateHTTPServerLogging() returns false,
650  // in which case we should clear the BCLog::LIBEVENT flag.
651  // Throw an error if the user has explicitly asked to change only the libevent
652  // flag and it failed.
653  if (changed_log_categories & BCLog::LIBEVENT) {
654  if (!UpdateHTTPServerLogging(LogInstance().WillLogCategory(BCLog::LIBEVENT))) {
656  if (changed_log_categories == BCLog::LIBEVENT) {
657  throw JSONRPCError(RPC_INVALID_PARAMETER, "libevent logging cannot be updated when using libevent before v2.1.1.");
658  }
659  }
660  }
661 
662  UniValue result(UniValue::VOBJ);
663  for (const auto& logCatActive : LogInstance().LogCategoriesList()) {
664  result.pushKV(logCatActive.category, logCatActive.active);
665  }
666 
667  return result;
668 },
669  };
670 }
671 
672 static RPCHelpMan echo(const std::string& name)
673 {
674  return RPCHelpMan{name,
675  "\nSimply echo back the input arguments. This command is for testing.\n"
676  "\nIt will return an internal bug report when arg9='trigger_internal_bug' is passed.\n"
677  "\nThe difference between echo and echojson is that echojson has argument conversion enabled in the client-side table in "
678  "bitcoin-cli and the GUI. There is no server-side difference.",
679  {
690  },
691  RPCResult{RPCResult::Type::ANY, "", "Returns whatever was passed in"},
692  RPCExamples{""},
693  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
694 {
695  if (request.params[9].isStr()) {
696  CHECK_NONFATAL(request.params[9].get_str() != "trigger_internal_bug");
697  }
698 
699  return request.params;
700 },
701  };
702 }
703 
704 static RPCHelpMan echo() { return echo("echo"); }
705 static RPCHelpMan echojson() { return echo("echojson"); }
706 
708 {
709  return RPCHelpMan{
710  "echoipc",
711  "\nEcho back the input argument, passing it through a spawned process in a multiprocess build.\n"
712  "This command is for testing.\n",
713  {{"arg", RPCArg::Type::STR, RPCArg::Optional::NO, "The string to echo",}},
714  RPCResult{RPCResult::Type::STR, "echo", "The echoed string."},
715  RPCExamples{HelpExampleCli("echo", "\"Hello world\"") +
716  HelpExampleRpc("echo", "\"Hello world\"")},
717  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue {
718  interfaces::Init& local_init = *EnsureAnyNodeContext(request.context).init;
719  std::unique_ptr<interfaces::Echo> echo;
720  if (interfaces::Ipc* ipc = local_init.ipc()) {
721  // Spawn a new bitcoin-node process and call makeEcho to get a
722  // client pointer to a interfaces::Echo instance running in
723  // that process. This is just for testing. A slightly more
724  // realistic test spawning a different executable instead of
725  // the same executable would add a new bitcoin-echo executable,
726  // and spawn bitcoin-echo below instead of bitcoin-node. But
727  // using bitcoin-node avoids the need to build and install a
728  // new executable just for this one test.
729  auto init = ipc->spawnProcess("bitcoin-node");
730  echo = init->makeEcho();
731  ipc->addCleanup(*echo, [init = init.release()] { delete init; });
732  } else {
733  // IPC support is not available because this is a bitcoind
734  // process not a bitcoind-node process, so just create a local
735  // interfaces::Echo object and return it so the `echoipc` RPC
736  // method will work, and the python test calling `echoipc`
737  // can expect the same result.
738  echo = local_init.makeEcho();
739  }
740  return echo->echo(request.params[0].get_str());
741  },
742  };
743 }
744 
745 static UniValue SummaryToJSON(const IndexSummary&& summary, std::string index_name)
746 {
747  UniValue ret_summary(UniValue::VOBJ);
748  if (!index_name.empty() && index_name != summary.name) return ret_summary;
749 
750  UniValue entry(UniValue::VOBJ);
751  entry.pushKV("synced", summary.synced);
752  entry.pushKV("best_block_height", summary.best_block_height);
753  ret_summary.pushKV(summary.name, entry);
754  return ret_summary;
755 }
756 
758 {
759  return RPCHelpMan{"getindexinfo",
760  "\nReturns the status of one or all available indices currently running in the node.\n",
761  {
762  {"index_name", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, "Filter results for an index with a specific name."},
763  },
764  RPCResult{
765  RPCResult::Type::OBJ_DYN, "", "", {
766  {
767  RPCResult::Type::OBJ, "name", "The name of the index",
768  {
769  {RPCResult::Type::BOOL, "synced", "Whether the index is synced or not"},
770  {RPCResult::Type::NUM, "best_block_height", "The block height to which the index is synced"},
771  }
772  },
773  },
774  },
775  RPCExamples{
776  HelpExampleCli("getindexinfo", "")
777  + HelpExampleRpc("getindexinfo", "")
778  + HelpExampleCli("getindexinfo", "txindex")
779  + HelpExampleRpc("getindexinfo", "txindex")
780  },
781  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
782 {
783  UniValue result(UniValue::VOBJ);
784  const std::string index_name = request.params[0].isNull() ? "" : request.params[0].get_str();
785 
786  if (g_txindex) {
787  result.pushKVs(SummaryToJSON(g_txindex->GetSummary(), index_name));
788  }
789 
790  if (g_coin_stats_index) {
791  result.pushKVs(SummaryToJSON(g_coin_stats_index->GetSummary(), index_name));
792  }
793 
794  ForEachBlockFilterIndex([&result, &index_name](const BlockFilterIndex& index) {
795  result.pushKVs(SummaryToJSON(index.GetSummary(), index_name));
796  });
797 
798  return result;
799 },
800  };
801 }
802 
804 {
805 // clang-format off
806 static const CRPCCommand commands[] =
807 { // category actor (function)
808  // --------------------- ------------------------
809  { "control", &getmemoryinfo, },
810  { "control", &logging, },
811  { "util", &validateaddress, },
812  { "util", &createmultisig, },
813  { "util", &deriveaddresses, },
814  { "util", &getdescriptorinfo, },
815  { "util", &verifymessage, },
816  { "util", &signmessagewithprivkey, },
817  { "util", &getindexinfo, },
818 
819  /* Not shown in help */
820  { "hidden", &setmocktime, },
821  { "hidden", &mockscheduler, },
822  { "hidden", &echo, },
823  { "hidden", &echojson, },
824  { "hidden", &echoipc, },
825 #if defined(USE_SYSCALL_SANDBOX)
826  { "hidden", &invokedisallowedsyscall, },
827 #endif // USE_SYSCALL_SANDBOX
828 };
829 // clang-format on
830  for (const auto& c : commands) {
831  t.appendCommand(c.name, &c);
832  }
833 }
RPC_MISC_ERROR
@ RPC_MISC_ERROR
General application defined errors.
Definition: protocol.h:39
MessageSign
bool MessageSign(const CKey &privkey, const std::string &message, std::string &signature)
Sign a message.
Definition: message.cpp:56
Parse
std::unique_ptr< Descriptor > Parse(const std::string &descriptor, FlatSigningProvider &out, std::string &error, bool require_checksum)
Parse a descriptor string.
Definition: descriptor.cpp:1394
CChainParams::IsMockableChain
bool IsMockableChain() const
If this chain allows time to be mocked.
Definition: chainparams.h:103
HelpExampleCli
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
Definition: util.cpp:156
MessageVerificationResult::ERR_MALFORMED_SIGNATURE
@ ERR_MALFORMED_SIGNATURE
The provided signature couldn't be parsed (maybe invalid base64).
getdescriptorinfo
static RPCHelpMan getdescriptorinfo()
Definition: misc.cpp:183
OutputType
OutputType
Definition: outputtype.h:18
echo
static RPCHelpMan echo(const std::string &name)
Definition: misc.cpp:672
LockedPool::Stats::free
size_t free
Definition: lockedpool.h:148
UniValue::VOBJ
@ VOBJ
Definition: univalue.h:19
check.h
g_txindex
std::unique_ptr< TxIndex > g_txindex
The global transaction index, used in GetTransaction. May be null.
Definition: txindex.cpp:16
CHECK_NONFATAL
#define CHECK_NONFATAL(condition)
Throw a NonFatalCheckError when the condition evaluates to false.
Definition: check.h:32
createmultisig
static RPCHelpMan createmultisig()
Definition: misc.cpp:100
key_io.h
ipc
Definition: ipc.h:12
OutputType::LEGACY
@ LEGACY
RPCHelpMan
Definition: util.h:346
blockfilterindex.h
interfaces::Init::makeEcho
virtual std::unique_ptr< Echo > makeEcho()
Definition: init.cpp:15
signmessagewithprivkey
static RPCHelpMan signmessagewithprivkey()
Definition: misc.cpp:363
FillableSigningProvider
Fillable signing provider that keeps keys in an address->secret map.
Definition: signingprovider.h:90
NullUniValue
const UniValue NullUniValue
Definition: univalue.cpp:13
GetScriptForDestination
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
Definition: standard.cpp:310
CChainParams::IsTestChain
bool IsTestChain() const
If this chain is exclusively used for testing.
Definition: chainparams.h:101
BaseIndex::GetSummary
IndexSummary GetSummary() const
Get a summary of the index and its state.
Definition: base.cpp:376
RPC_INVALID_PARAMETER
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
Definition: protocol.h:43
outputtype.h
IsHex
bool IsHex(const std::string &str)
Definition: strencodings.cpp:61
deriveaddresses
static RPCHelpMan deriveaddresses()
Definition: misc.cpp:229
node::NodeContext
NodeContext struct containing references to chain state and connection state.
Definition: context.h:40
RPCArg::Optional::NO
@ NO
Required arg.
interfaces::Init
Initial interface created when a process is first started, and used to give and get access to other i...
Definition: init.h:28
RPCArg::Type::STR
@ STR
FlatSigningProvider::keys
std::map< CKeyID, CKey > keys
Definition: signingprovider.h:77
BlockFilterIndex
BlockFilterIndex is used to store and retrieve block filters, hashes, and headers for a range of bloc...
Definition: blockfilterindex.h:24
RPCArg::Type::ARR
@ ARR
MessageVerify
MessageVerificationResult MessageVerify(const std::string &address, const std::string &signature, const std::string &message)
Verify a signed message.
Definition: message.cpp:24
MessageVerificationResult::ERR_NOT_SIGNED
@ ERR_NOT_SIGNED
The message was not signed with the private key of the provided address.
BCLog::Logger::GetCategoryMask
uint32_t GetCategoryMask() const
Definition: logging.h:137
RPCResult::Type::NUM
@ NUM
LockedPoolManager::Instance
static LockedPoolManager & Instance()
Return the current instance, or create it once.
Definition: lockedpool.h:222
HexToPubKey
CPubKey HexToPubKey(const std::string &hex_in)
Definition: util.cpp:192
server_util.h
UniValue::isNull
bool isNull() const
Definition: univalue.h:75
LockedPool::Stats::chunks_free
size_t chunks_free
Definition: lockedpool.h:152
SummaryToJSON
static UniValue SummaryToJSON(const IndexSummary &&summary, std::string index_name)
Definition: misc.cpp:745
coinstatsindex.h
chain.h
context.h
UniValue::pushKV
bool pushKV(const std::string &key, const UniValue &val)
Definition: univalue.cpp:133
validateaddress
static RPCHelpMan validateaddress()
Definition: misc.cpp:40
scheduler.h
UniValue
Definition: univalue.h:17
g_coin_stats_index
std::unique_ptr< CoinStatsIndex > g_coin_stats_index
The global UTXO set hash object.
Definition: coinstatsindex.cpp:100
LockedPool::Stats::total
size_t total
Definition: lockedpool.h:149
txindex.h
GetDescriptorChecksum
std::string GetDescriptorChecksum(const std::string &descriptor)
Get the checksum for a descriptor.
Definition: descriptor.cpp:1404
RPCArg::Type::NUM
@ NUM
EnsureAnyNodeContext
NodeContext & EnsureAnyNodeContext(const std::any &context)
Definition: server_util.cpp:20
OutputType::BECH32M
@ BECH32M
LockedPool::Stats::locked
size_t locked
Definition: lockedpool.h:150
UniValue::get_str
const std::string & get_str() const
Definition: univalue_get.cpp:98
strencodings.h
syscall_sandbox.h
UniValue::pushKVs
bool pushKVs(const UniValue &obj)
Definition: univalue.cpp:146
CTxDestination
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:157
echoipc
static RPCHelpMan echoipc()
Definition: misc.cpp:707
IsValidDestination
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
Definition: standard.cpp:332
RPCArg::Optional::OMITTED_NAMED_ARG
@ OMITTED_NAMED_ARG
Optional arg that is a named argument and has a default value of null.
interfaces::Init::ipc
virtual Ipc * ipc()
Definition: init.cpp:16
RPCArg::Type::STR_HEX
@ STR_HEX
Special type that is a STR with only hex chars.
RPCResult::Type::OBJ
@ OBJ
OutputTypeFromDestination
std::optional< OutputType > OutputTypeFromDestination(const CTxDestination &dest)
Get the OutputType for a CTxDestination.
Definition: outputtype.cpp:109
CRPCCommand
Definition: server.h:89
RPCResult::Type::NONE
@ NONE
echo.h
UpdateHTTPServerLogging
bool UpdateHTTPServerLogging(bool enable)
Change logging level for libevent.
Definition: httpserver.cpp:405
message.h
SetMockTime
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
Definition: time.cpp:101
BCLog::Logger::LogCategoriesString
std::string LogCategoriesString() const
Returns a string with the log categories in alphabetical order.
Definition: logging.h:148
RPCLockedMemoryInfo
static UniValue RPCLockedMemoryInfo()
Definition: misc.cpp:498
BCLog::LIBEVENT
@ LIBEVENT
Definition: logging.h:56
univalue.h
RPCResult::Type::STR_HEX
@ STR_HEX
Special string with only hex chars.
AddAndGetMultisigDestination
CTxDestination AddAndGetMultisigDestination(const int required, const std::vector< CPubKey > &pubkeys, OutputType type, FillableSigningProvider &keystore, CScript &script_out)
Definition: util.cpp:226
LockedPool::Stats::chunks_used
size_t chunks_used
Definition: lockedpool.h:151
CKey::IsValid
bool IsValid() const
Check whether this private key is valid.
Definition: key.h:93
LockedPool::Stats::used
size_t used
Definition: lockedpool.h:147
DescribeAddress
UniValue DescribeAddress(const CTxDestination &dest)
Definition: util.cpp:325
MessageVerificationResult::ERR_INVALID_ADDRESS
@ ERR_INVALID_ADDRESS
The provided address is invalid.
RPCExamples
Definition: util.h:336
init.h
setmocktime
static RPCHelpMan setmocktime()
Definition: misc.cpp:403
BCLog::Logger::EnableCategory
void EnableCategory(LogFlags flag)
Definition: logging.cpp:94
getindexinfo
static RPCHelpMan getindexinfo()
Definition: misc.cpp:757
echojson
static RPCHelpMan echojson()
Definition: misc.cpp:705
RPCResult::Type::STR
@ STR
DecodeSecret
CKey DecodeSecret(const std::string &str)
Definition: key_io.cpp:198
RPCResult::Type::ARR
@ ARR
logging
static RPCHelpMan logging()
Definition: misc.cpp:603
node::NodeContext::init
interfaces::Init * init
Init interface for initializing current process and connecting to other processes.
Definition: context.h:42
MessageVerificationResult::ERR_PUBKEY_NOT_RECOVERED
@ ERR_PUBKEY_NOT_RECOVERED
A public key could not be recovered from the provided signature and message.
RPCResult::Type::ANY
@ ANY
Special type to disable type checks (for testing only)
EnableOrDisableLogCategories
static void EnableOrDisableLogCategories(UniValue cats, bool enable)
Definition: misc.cpp:585
LockedPool::Stats
Memory statistics.
Definition: lockedpool.h:145
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:405
HelpExampleRpc
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
Definition: util.cpp:174
ExtractDestination
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
Definition: standard.cpp:213
RPCArg::Type::RANGE
@ RANGE
Special type that is a NUM or [NUM,NUM].
MessageVerificationResult::ERR_ADDRESS_NO_KEY
@ ERR_ADDRESS_NO_KEY
The provided address is valid but does not refer to a public key.
ipc.h
CRPCTable
RPC command dispatcher.
Definition: server.h:125
RPC_INVALID_ADDRESS_OR_KEY
@ RPC_INVALID_ADDRESS_OR_KEY
Invalid address or key.
Definition: protocol.h:41
name
const char * name
Definition: rest.cpp:52
system.h
strprintf
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1164
ParseDescriptorRange
std::pair< int64_t, int64_t > ParseDescriptorRange(const UniValue &value)
Parse a JSON range specified as int64, or [int64, int64].
Definition: util.cpp:989
RegisterMiscRPCCommands
void RegisterMiscRPCCommands(CRPCTable &t)
Register miscellaneous RPC commands.
Definition: misc.cpp:803
verifymessage
static RPCHelpMan verifymessage()
Definition: misc.cpp:314
getmemoryinfo
static RPCHelpMan getmemoryinfo()
Definition: misc.cpp:530
RPCResult::Type::BOOL
@ BOOL
CKey
An encapsulated private key.
Definition: key.h:26
UniValue::get_int
int get_int() const
Definition: univalue_get.cpp:105
RPCTypeCheck
void RPCTypeCheck(const UniValue &params, const std::list< UniValueType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
Definition: util.cpp:24
JSONRPCError
UniValue JSONRPCError(int code, const std::string &message)
Definition: request.cpp:56
ForEachBlockFilterIndex
void ForEachBlockFilterIndex(std::function< void(BlockFilterIndex &)> fn)
Iterate over all running block filter indexes, invoking fn on each.
Definition: blockfilterindex.cpp:460
LOCK
#define LOCK(cs)
Definition: sync.h:226
RPCArg::Optional::OMITTED
@ OMITTED
Optional argument with default value omitted because they are implicitly clear.
init
Definition: bitcoin-gui.cpp:16
DecodeDestination
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg, std::vector< int > *error_locations)
Definition: key_io.cpp:281
UniValue::push_back
bool push_back(const UniValue &val)
Definition: univalue.cpp:108
LogInstance
BCLog::Logger & LogInstance()
Definition: logging.cpp:18
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:561
MessageVerificationResult::OK
@ OK
The message verification was successful.
EXAMPLE_ADDRESS
const std::string EXAMPLE_ADDRESS[2]
Example bech32 addresses for the RPCExamples help documentation.
Definition: util.cpp:22
UniValue::empty
bool empty() const
Definition: univalue.h:64
RPCResult::Type::OBJ_DYN
@ OBJ_DYN
Special dictionary with keys that are not literals.
IndexSummary
Definition: base.h:16
UniValue::size
size_t size() const
Definition: univalue.h:66
JSONRPCRequest
Definition: request.h:28
RPCResult
Definition: util.h:231
blockchain.h
httpserver.h
RPC_TYPE_ERROR
@ RPC_TYPE_ERROR
Unexpected type was passed as parameter.
Definition: protocol.h:40
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:49
BCLog::Logger::DisableCategory
void DisableCategory(LogFlags flag)
Definition: logging.cpp:107
UniValue::get_array
const UniValue & get_array() const
Definition: univalue_get.cpp:142
UniValue::VARR
@ VARR
Definition: univalue.h:19
server.h
InferDescriptor
std::unique_ptr< Descriptor > InferDescriptor(const CScript &script, const SigningProvider &provider)
Find a descriptor for the specified script, using information from provider where possible.
Definition: descriptor.cpp:1413
cs_main
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: validation.cpp:138
HexStr
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
Definition: strencodings.cpp:511
LockedPool::stats
Stats stats() const
Get pool usage statistics.
Definition: lockedpool.cpp:330
mockscheduler
static RPCHelpMan mockscheduler()
Definition: misc.cpp:465
ParseOutputType
std::optional< OutputType > ParseOutputType(const std::string &type)
Definition: outputtype.cpp:24
EncodeDestination
std::string EncodeDestination(const CTxDestination &dest)
Definition: key_io.cpp:276
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
FlatSigningProvider
Definition: signingprovider.h:72
descriptor.h
ByteUnit::t
@ t
interfaces::Ipc
Interface providing access to interprocess-communication (IPC) functionality.
Definition: ipc.h:44