BSHA3  0.17.99
P2P Blockchain, based on Bitcoin
misc.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2018 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 <chain.h>
7 #include <clientversion.h>
8 #include <core_io.h>
9 #include <crypto/ripemd160.h>
10 #include <key_io.h>
11 #include <validation.h>
12 #include <httpserver.h>
13 #include <net.h>
14 #include <netbase.h>
15 #include <outputtype.h>
16 #include <rpc/blockchain.h>
17 #include <rpc/server.h>
18 #include <rpc/util.h>
19 #include <timedata.h>
20 #include <util.h>
21 #include <utilstrencodings.h>
22 #include <warnings.h>
23 
24 #include <stdint.h>
25 #ifdef HAVE_MALLOC_INFO
26 #include <malloc.h>
27 #endif
28 
29 #include <univalue.h>
30 
31 static UniValue validateaddress(const JSONRPCRequest& request)
32 {
33  if (request.fHelp || request.params.size() != 1)
34  throw std::runtime_error(
35  "validateaddress \"address\"\n"
36  "\nReturn information about the given bitcoin address.\n"
37  "DEPRECATION WARNING: Parts of this command have been deprecated and moved to getaddressinfo. Clients must\n"
38  "transition to using getaddressinfo to access this information before upgrading to v0.18. The following deprecated\n"
39  "fields have moved to getaddressinfo and will only be shown here with -deprecatedrpc=validateaddress: ismine, iswatchonly,\n"
40  "script, hex, pubkeys, sigsrequired, pubkey, addresses, embedded, iscompressed, account, timestamp, hdkeypath, kdmasterkeyid.\n"
41  "\nArguments:\n"
42  "1. \"address\" (string, required) The bitcoin address to validate\n"
43  "\nResult:\n"
44  "{\n"
45  " \"isvalid\" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.\n"
46  " \"address\" : \"address\", (string) The bitcoin address validated\n"
47  " \"scriptPubKey\" : \"hex\", (string) The hex-encoded scriptPubKey generated by the address\n"
48  " \"isscript\" : true|false, (boolean) If the key is a script\n"
49  " \"iswitness\" : true|false, (boolean) If the address is a witness address\n"
50  " \"witness_version\" : version (numeric, optional) The version number of the witness program\n"
51  " \"witness_program\" : \"hex\" (string, optional) The hex value of the witness program\n"
52  "}\n"
53  "\nExamples:\n"
54  + HelpExampleCli("validateaddress", "\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"")
55  + HelpExampleRpc("validateaddress", "\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"")
56  );
57 
58  CTxDestination dest = DecodeDestination(request.params[0].get_str());
59  bool isValid = IsValidDestination(dest);
60 
62  ret.pushKV("isvalid", isValid);
63  if (isValid)
64  {
65  std::string currentAddress = EncodeDestination(dest);
66  ret.pushKV("address", currentAddress);
67 
68  CScript scriptPubKey = GetScriptForDestination(dest);
69  ret.pushKV("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end()));
70 
71  UniValue detail = DescribeAddress(dest);
72  ret.pushKVs(detail);
73  }
74  return ret;
75 }
76 
77 static UniValue createmultisig(const JSONRPCRequest& request)
78 {
79  if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
80  {
81  std::string msg = "createmultisig nrequired [\"key\",...] ( \"address_type\" )\n"
82  "\nCreates a multi-signature address with n signature of m keys required.\n"
83  "It returns a json object with the address and redeemScript.\n"
84  "\nArguments:\n"
85  "1. nrequired (numeric, required) The number of required signatures out of the n keys.\n"
86  "2. \"keys\" (string, required) A json array of hex-encoded public keys\n"
87  " [\n"
88  " \"key\" (string) The hex-encoded public key\n"
89  " ,...\n"
90  " ]\n"
91  "3. \"address_type\" (string, optional) The address type to use. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\". Default is legacy.\n"
92 
93  "\nResult:\n"
94  "{\n"
95  " \"address\":\"multisigaddress\", (string) The value of the new multisig address.\n"
96  " \"redeemScript\":\"script\" (string) The string value of the hex-encoded redemption script.\n"
97  "}\n"
98 
99  "\nExamples:\n"
100  "\nCreate a multisig address from 2 public keys\n"
101  + HelpExampleCli("createmultisig", "2 \"[\\\"03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd\\\",\\\"03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626\\\"]\"") +
102  "\nAs a JSON-RPC call\n"
103  + HelpExampleRpc("createmultisig", "2, \"[\\\"03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd\\\",\\\"03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626\\\"]\"")
104  ;
105  throw std::runtime_error(msg);
106  }
107 
108  int required = request.params[0].get_int();
109 
110  // Get the public keys
111  const UniValue& keys = request.params[1].get_array();
112  std::vector<CPubKey> pubkeys;
113  for (unsigned int i = 0; i < keys.size(); ++i) {
114  if (IsHex(keys[i].get_str()) && (keys[i].get_str().length() == 66 || keys[i].get_str().length() == 130)) {
115  pubkeys.push_back(HexToPubKey(keys[i].get_str()));
116  } else {
117  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Invalid public key: %s\n.", keys[i].get_str()));
118  }
119  }
120 
121  // Get the output type
122  OutputType output_type = OutputType::LEGACY;
123  if (!request.params[2].isNull()) {
124  if (!ParseOutputType(request.params[2].get_str(), output_type)) {
125  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address type '%s'", request.params[2].get_str()));
126  }
127  }
128 
129  // Construct using pay-to-script-hash:
130  const CScript inner = CreateMultisigRedeemscript(required, pubkeys);
131  CBasicKeyStore keystore;
132  const CTxDestination dest = AddAndGetDestinationForScript(keystore, inner, output_type);
133 
134  UniValue result(UniValue::VOBJ);
135  result.pushKV("address", EncodeDestination(dest));
136  result.pushKV("redeemScript", HexStr(inner.begin(), inner.end()));
137 
138  return result;
139 }
140 
141 static UniValue verifymessage(const JSONRPCRequest& request)
142 {
143  if (request.fHelp || request.params.size() != 3)
144  throw std::runtime_error(
145  "verifymessage \"address\" \"signature\" \"message\"\n"
146  "\nVerify a signed message\n"
147  "\nArguments:\n"
148  "1. \"address\" (string, required) The bitcoin address to use for the signature.\n"
149  "2. \"signature\" (string, required) The signature provided by the signer in base 64 encoding (see signmessage).\n"
150  "3. \"message\" (string, required) The message that was signed.\n"
151  "\nResult:\n"
152  "true|false (boolean) If the signature is verified or not.\n"
153  "\nExamples:\n"
154  "\nUnlock the wallet for 30 seconds\n"
155  + HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") +
156  "\nCreate the signature\n"
157  + HelpExampleCli("signmessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"my message\"") +
158  "\nVerify the signature\n"
159  + HelpExampleCli("verifymessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"signature\" \"my message\"") +
160  "\nAs a JSON-RPC call\n"
161  + HelpExampleRpc("verifymessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"signature\", \"my message\"")
162  );
163 
164  LOCK(cs_main);
165 
166  std::string strAddress = request.params[0].get_str();
167  std::string strSign = request.params[1].get_str();
168  std::string strMessage = request.params[2].get_str();
169 
170  CTxDestination destination = DecodeDestination(strAddress);
171  if (!IsValidDestination(destination)) {
172  throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address");
173  }
174 
175  const CKeyID *keyID = boost::get<CKeyID>(&destination);
176  if (!keyID) {
177  throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key");
178  }
179 
180  bool fInvalid = false;
181  std::vector<unsigned char> vchSig = DecodeBase64(strSign.c_str(), &fInvalid);
182 
183  if (fInvalid)
184  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Malformed base64 encoding");
185 
186  CHashWriter ss(SER_GETHASH, 0);
187  ss << strMessageMagic;
188  ss << strMessage;
189 
190  CPubKey pubkey;
191  if (!pubkey.RecoverCompact(ss.GetHash(), vchSig))
192  return false;
193 
194  return (pubkey.GetID() == *keyID);
195 }
196 
197 static UniValue signmessagewithprivkey(const JSONRPCRequest& request)
198 {
199  if (request.fHelp || request.params.size() != 2)
200  throw std::runtime_error(
201  "signmessagewithprivkey \"privkey\" \"message\"\n"
202  "\nSign a message with the private key of an address\n"
203  "\nArguments:\n"
204  "1. \"privkey\" (string, required) The private key to sign the message with.\n"
205  "2. \"message\" (string, required) The message to create a signature of.\n"
206  "\nResult:\n"
207  "\"signature\" (string) The signature of the message encoded in base 64\n"
208  "\nExamples:\n"
209  "\nCreate the signature\n"
210  + HelpExampleCli("signmessagewithprivkey", "\"privkey\" \"my message\"") +
211  "\nVerify the signature\n"
212  + HelpExampleCli("verifymessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"signature\" \"my message\"") +
213  "\nAs a JSON-RPC call\n"
214  + HelpExampleRpc("signmessagewithprivkey", "\"privkey\", \"my message\"")
215  );
216 
217  std::string strPrivkey = request.params[0].get_str();
218  std::string strMessage = request.params[1].get_str();
219 
220  CKey key = DecodeSecret(strPrivkey);
221  if (!key.IsValid()) {
222  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key");
223  }
224 
225  CHashWriter ss(SER_GETHASH, 0);
226  ss << strMessageMagic;
227  ss << strMessage;
228 
229  std::vector<unsigned char> vchSig;
230  if (!key.SignCompact(ss.GetHash(), vchSig))
231  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Sign failed");
232 
233  return EncodeBase64(vchSig.data(), vchSig.size());
234 }
235 
236 static UniValue setmocktime(const JSONRPCRequest& request)
237 {
238  if (request.fHelp || request.params.size() != 1)
239  throw std::runtime_error(
240  "setmocktime timestamp\n"
241  "\nSet the local time to given timestamp (-regtest only)\n"
242  "\nArguments:\n"
243  "1. timestamp (integer, required) Unix seconds-since-epoch timestamp\n"
244  " Pass 0 to go back to using the system time."
245  );
246 
247  if (!Params().MineBlocksOnDemand())
248  throw std::runtime_error("setmocktime for regression testing (-regtest mode) only");
249 
250  // For now, don't change mocktime if we're in the middle of validation, as
251  // this could have an effect on mempool time-based eviction, as well as
252  // IsCurrentForFeeEstimation() and IsInitialBlockDownload().
253  // TODO: figure out the right way to synchronize around mocktime, and
254  // ensure all call sites of GetTime() are accessing this safely.
255  LOCK(cs_main);
256 
257  RPCTypeCheck(request.params, {UniValue::VNUM});
258  SetMockTime(request.params[0].get_int64());
259 
260  return NullUniValue;
261 }
262 
263 static UniValue RPCLockedMemoryInfo()
264 {
267  obj.pushKV("used", uint64_t(stats.used));
268  obj.pushKV("free", uint64_t(stats.free));
269  obj.pushKV("total", uint64_t(stats.total));
270  obj.pushKV("locked", uint64_t(stats.locked));
271  obj.pushKV("chunks_used", uint64_t(stats.chunks_used));
272  obj.pushKV("chunks_free", uint64_t(stats.chunks_free));
273  return obj;
274 }
275 
276 #ifdef HAVE_MALLOC_INFO
277 static std::string RPCMallocInfo()
278 {
279  char *ptr = nullptr;
280  size_t size = 0;
281  FILE *f = open_memstream(&ptr, &size);
282  if (f) {
283  malloc_info(0, f);
284  fclose(f);
285  if (ptr) {
286  std::string rv(ptr, size);
287  free(ptr);
288  return rv;
289  }
290  }
291  return "";
292 }
293 #endif
294 
295 static UniValue getmemoryinfo(const JSONRPCRequest& request)
296 {
297  /* Please, avoid using the word "pool" here in the RPC interface or help,
298  * as users will undoubtedly confuse it with the other "memory pool"
299  */
300  if (request.fHelp || request.params.size() > 1)
301  throw std::runtime_error(
302  "getmemoryinfo (\"mode\")\n"
303  "Returns an object containing information about memory usage.\n"
304  "Arguments:\n"
305  "1. \"mode\" determines what kind of information is returned. This argument is optional, the default mode is \"stats\".\n"
306  " - \"stats\" returns general statistics about memory usage in the daemon.\n"
307  " - \"mallocinfo\" returns an XML string describing low-level heap state (only available if compiled with glibc 2.10+).\n"
308  "\nResult (mode \"stats\"):\n"
309  "{\n"
310  " \"locked\": { (json object) Information about locked memory manager\n"
311  " \"used\": xxxxx, (numeric) Number of bytes used\n"
312  " \"free\": xxxxx, (numeric) Number of bytes available in current arenas\n"
313  " \"total\": xxxxxxx, (numeric) Total number of bytes managed\n"
314  " \"locked\": xxxxxx, (numeric) 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.\n"
315  " \"chunks_used\": xxxxx, (numeric) Number allocated chunks\n"
316  " \"chunks_free\": xxxxx, (numeric) Number unused chunks\n"
317  " }\n"
318  "}\n"
319  "\nResult (mode \"mallocinfo\"):\n"
320  "\"<malloc version=\"1\">...\"\n"
321  "\nExamples:\n"
322  + HelpExampleCli("getmemoryinfo", "")
323  + HelpExampleRpc("getmemoryinfo", "")
324  );
325 
326  std::string mode = request.params[0].isNull() ? "stats" : request.params[0].get_str();
327  if (mode == "stats") {
329  obj.pushKV("locked", RPCLockedMemoryInfo());
330  return obj;
331  } else if (mode == "mallocinfo") {
332 #ifdef HAVE_MALLOC_INFO
333  return RPCMallocInfo();
334 #else
335  throw JSONRPCError(RPC_INVALID_PARAMETER, "mallocinfo is only available when compiled with glibc 2.10+");
336 #endif
337  } else {
338  throw JSONRPCError(RPC_INVALID_PARAMETER, "unknown mode " + mode);
339  }
340 }
341 
342 static void EnableOrDisableLogCategories(UniValue cats, bool enable) {
343  cats = cats.get_array();
344  for (unsigned int i = 0; i < cats.size(); ++i) {
345  std::string cat = cats[i].get_str();
346 
347  bool success;
348  if (enable) {
349  success = g_logger->EnableCategory(cat);
350  } else {
351  success = g_logger->DisableCategory(cat);
352  }
353 
354  if (!success) {
355  throw JSONRPCError(RPC_INVALID_PARAMETER, "unknown logging category " + cat);
356  }
357  }
358 }
359 
361 {
362  if (request.fHelp || request.params.size() > 2) {
363  throw std::runtime_error(
364  "logging ( <include> <exclude> )\n"
365  "Gets and sets the logging configuration.\n"
366  "When called without an argument, returns the list of categories with status that are currently being debug logged or not.\n"
367  "When called with arguments, adds or removes categories from debug logging and return the lists above.\n"
368  "The arguments are evaluated in order \"include\", \"exclude\".\n"
369  "If an item is both included and excluded, it will thus end up being excluded.\n"
370  "The valid logging categories are: " + ListLogCategories() + "\n"
371  "In addition, the following are available as category names with special meanings:\n"
372  " - \"all\", \"1\" : represent all logging categories.\n"
373  " - \"none\", \"0\" : even if other logging categories are specified, ignore all of them.\n"
374  "\nArguments:\n"
375  "1. \"include\" (array of strings, optional) A json array of categories to add debug logging\n"
376  " [\n"
377  " \"category\" (string) the valid logging category\n"
378  " ,...\n"
379  " ]\n"
380  "2. \"exclude\" (array of strings, optional) A json array of categories to remove debug logging\n"
381  " [\n"
382  " \"category\" (string) the valid logging category\n"
383  " ,...\n"
384  " ]\n"
385  "\nResult:\n"
386  "{ (json object where keys are the logging categories, and values indicates its status\n"
387  " \"category\": 0|1, (numeric) if being debug logged or not. 0:inactive, 1:active\n"
388  " ...\n"
389  "}\n"
390  "\nExamples:\n"
391  + HelpExampleCli("logging", "\"[\\\"all\\\"]\" \"[\\\"http\\\"]\"")
392  + HelpExampleRpc("logging", "[\"all\"], \"[libevent]\"")
393  );
394  }
395 
396  uint32_t original_log_categories = g_logger->GetCategoryMask();
397  if (request.params[0].isArray()) {
398  EnableOrDisableLogCategories(request.params[0], true);
399  }
400  if (request.params[1].isArray()) {
401  EnableOrDisableLogCategories(request.params[1], false);
402  }
403  uint32_t updated_log_categories = g_logger->GetCategoryMask();
404  uint32_t changed_log_categories = original_log_categories ^ updated_log_categories;
405 
406  // Update libevent logging if BCLog::LIBEVENT has changed.
407  // If the library version doesn't allow it, UpdateHTTPServerLogging() returns false,
408  // in which case we should clear the BCLog::LIBEVENT flag.
409  // Throw an error if the user has explicitly asked to change only the libevent
410  // flag and it failed.
411  if (changed_log_categories & BCLog::LIBEVENT) {
414  if (changed_log_categories == BCLog::LIBEVENT) {
415  throw JSONRPCError(RPC_INVALID_PARAMETER, "libevent logging cannot be updated when using libevent before v2.1.1.");
416  }
417  }
418  }
419 
420  UniValue result(UniValue::VOBJ);
421  std::vector<CLogCategoryActive> vLogCatActive = ListActiveLogCategories();
422  for (const auto& logCatActive : vLogCatActive) {
423  result.pushKV(logCatActive.category, logCatActive.active);
424  }
425 
426  return result;
427 }
428 
429 static UniValue echo(const JSONRPCRequest& request)
430 {
431  if (request.fHelp)
432  throw std::runtime_error(
433  "echo|echojson \"message\" ...\n"
434  "\nSimply echo back the input arguments. This command is for testing.\n"
435  "\nThe difference between echo and echojson is that echojson has argument conversion enabled in the client-side table in"
436  "bsha3-cli and the GUI. There is no server-side difference."
437  );
438 
439  return request.params;
440 }
441 
442 // clang-format off
443 static const CRPCCommand commands[] =
444 { // category name actor (function) argNames
445  // --------------------- ------------------------ ----------------------- ----------
446  { "control", "getmemoryinfo", &getmemoryinfo, {"mode"} },
447  { "control", "logging", &logging, {"include", "exclude"}},
448  { "util", "validateaddress", &validateaddress, {"address"} },
449  { "util", "createmultisig", &createmultisig, {"nrequired","keys","address_type"} },
450  { "util", "verifymessage", &verifymessage, {"address","signature","message"} },
451  { "util", "signmessagewithprivkey", &signmessagewithprivkey, {"privkey","message"} },
452 
453  /* Not shown in help */
454  { "hidden", "setmocktime", &setmocktime, {"timestamp"}},
455  { "hidden", "echo", &echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}},
456  { "hidden", "echojson", &echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}},
457 };
458 // clang-format on
459 
461 {
462  for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
463  t.appendCommand(commands[vcidx].name, &commands[vcidx]);
464 }
void EnableCategory(LogFlags flag)
Definition: logging.cpp:55
CScript CreateMultisigRedeemscript(const int required, const std::vector< CPubKey > &pubkeys)
Definition: util.cpp:47
std::vector< unsigned char > DecodeBase64(const char *p, bool *pfInvalid)
Bitcoin RPC command dispatcher.
Definition: server.h:143
static LockedPoolManager & Instance()
Return the current instance, or create it once.
Definition: lockedpool.h:222
#define strprintf
Definition: tinyformat.h:1066
std::string ListLogCategories()
Returns a string with the log categories.
Definition: logging.cpp:141
UniValue ret(UniValue::VARR)
Definition: rpcwallet.cpp:1140
void SetMockTime(int64_t nMockTimeIn)
Definition: utiltime.cpp:30
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
Definition: standard.cpp:324
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
CPubKey HexToPubKey(const std::string &hex_in)
Definition: util.cpp:13
UniValue DescribeAddress(const CTxDestination &dest)
Definition: util.cpp:125
const std::string & get_str() const
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
Definition: server.cpp:516
const UniValue & get_array() const
int64_t get_int64() const
bool pushKVs(const UniValue &obj)
Definition: univalue.cpp:146
bool appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
Definition: server.cpp:285
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
Definition: pubkey.h:155
const std::string strMessageMagic
Definition: validation.cpp:251
OutputType
Definition: outputtype.h:15
Invalid, missing or duplicate parameter.
Definition: protocol.h:52
bool SignCompact(const uint256 &hash, std::vector< unsigned char > &vchSig) const
Create a compact signature (65 bytes), which allows reconstructing the used public key...
Definition: key.cpp:241
iterator end()
Definition: prevector.h:303
std::string name
Definition: server.h:135
bool push_back(const UniValue &val)
Definition: univalue.cpp:108
CCriticalSection cs_main
Definition: validation.cpp:216
bool MineBlocksOnDemand() const
Make miner stop after a block is found.
Definition: chainparams.h:72
UniValue params
Definition: server.h:44
boost::variant< CNoDestination, CKeyID, CScriptID, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:123
#define LOCK(cs)
Definition: sync.h:181
CTxDestination AddAndGetDestinationForScript(CKeyStore &keystore, const CScript &script, OutputType type)
Get a destination of the requested type (if possible) to the specified script.
Definition: outputtype.cpp:76
bool RecoverCompact(const uint256 &hash, const std::vector< unsigned char > &vchSig)
Recover a public key from a compact signature.
Definition: pubkey.cpp:186
An encapsulated public key.
Definition: pubkey.h:30
bool IsHex(const std::string &str)
Unexpected type was passed as parameter.
Definition: protocol.h:49
uint32_t GetCategoryMask() const
Definition: logging.h:97
void DisableCategory(LogFlags flag)
Definition: logging.cpp:68
bool pushKV(const std::string &key, const UniValue &val)
Definition: univalue.cpp:133
void RPCTypeCheck(const UniValue &params, const std::list< UniValueType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
Definition: server.cpp:51
int get_int() const
Invalid address or key.
Definition: protocol.h:50
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
Definition: standard.cpp:288
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
Definition: server.cpp:511
bool WillLogCategory(LogFlags category) const
Definition: logging.cpp:81
bool isNull() const
Definition: univalue.h:78
bool fHelp
Definition: server.h:45
CTxDestination DecodeDestination(const std::string &str)
Definition: key_io.cpp:214
#define ARRAYLEN(array)
const CChainParams & Params()
Return the currently selected parameters.
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:384
void RegisterMiscRPCCommands(CRPCTable &t)
Register miscellaneous RPC commands.
Definition: misc.cpp:460
A reference to a CKey: the Hash360 of its serialized public key.
Definition: pubkey.h:20
UniValue logging(const JSONRPCRequest &request)
Definition: misc.cpp:360
const UniValue NullUniValue
Definition: univalue.cpp:13
iterator begin()
Definition: prevector.h:301
std::string EncodeDestination(const CTxDestination &dest)
Definition: key_io.cpp:209
A writer stream (for serialization) that computes a 256-bit SHA-3-256 hash.
Definition: hash.h:165
UniValue JSONRPCError(int code, const std::string &message)
Definition: protocol.cpp:51
size_t size() const
Definition: univalue.h:69
An encapsulated private key.
Definition: key.h:27
Stats stats() const
Get pool usage statistics.
Definition: lockedpool.cpp:324
CKey DecodeSecret(const std::string &str)
Definition: key_io.cpp:133
bool ParseOutputType(const std::string &type, OutputType &output_type)
Definition: outputtype.cpp:20
std::vector< CLogCategoryActive > ListActiveLogCategories()
Returns a vector of the active log categories.
Definition: logging.cpp:156
bool isArray() const
Definition: univalue.h:84
Basic key store, that keeps keys in an address->secret map.
Definition: keystore.h:42
BCLog::Logger *const g_logger
NOTE: the logger instances is leaked on exit.
Definition: logging.cpp:24
std::string EncodeBase64(const unsigned char *pch, size_t len)
bool UpdateHTTPServerLogging(bool enable)
Change logging level for libevent.
Definition: httpserver.cpp:401
Memory statistics.
Definition: lockedpool.h:145
bool IsValid() const
Check whether this private key is valid.
Definition: key.h:93