12 #include "validation.h" 30 #ifdef HAVE_MALLOC_INFO 52 throw std::runtime_error(
54 "\nDEPRECATED. Returns an object containing various state info.\n" 57 " \"deprecation-warning\": \"...\" (string) warning that the getinfo command is deprecated and will be removed in 0.16\n" 58 " \"version\": xxxxx, (numeric) the server version\n" 59 " \"protocolversion\": xxxxx, (numeric) the protocol version\n" 60 " \"walletversion\": xxxxx, (numeric) the wallet version\n" 61 " \"balance\": xxxxxxx, (numeric) the total Ravencoin balance of the wallet\n" 62 " \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n" 63 " \"timeoffset\": xxxxx, (numeric) the time offset\n" 64 " \"connections\": xxxxx, (numeric) the number of connections\n" 65 " \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n" 66 " \"difficulty\": xxxxxx, (numeric) the current difficulty\n" 67 " \"testnet\": true|false, (boolean) if the server is using testnet or not\n" 68 " \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since Unix epoch) of the oldest pre-generated key in the key pool\n" 69 " \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n" 70 " \"unlocked_until\": ttt, (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n" 71 " \"paytxfee\": x.xxxx, (numeric) the transaction fee set in " +
CURRENCY_UNIT +
"/kB\n" 72 " \"relayfee\": x.xxxx, (numeric) minimum relay fee for transactions in " +
CURRENCY_UNIT +
"/kB\n" 73 " \"errors\": \"...\" (string) any error messages\n" 92 obj.
push_back(Pair(
"deprecation-warning",
"WARNING: getinfo is deprecated and will be fully removed in 0.16." 93 " Projects should transition to using getblockchaininfo, getnetworkinfo, and getwalletinfo before upgrading to 0.16"));
94 obj.
push_back(Pair(
"version", CLIENT_VERSION));
95 obj.
push_back(Pair(
"protocolversion", PROTOCOL_VERSION));
126 class DescribeAddressVisitor :
public boost::static_visitor<UniValue>
131 explicit DescribeAddressVisitor(
CWallet *_pwallet) : pwallet(_pwallet) {}
139 if (pwallet && pwallet->
GetPubKey(keyID, vchPubKey)) {
150 if (pwallet && pwallet->
GetCScript(scriptID, subscript)) {
151 std::vector<CTxDestination> addresses;
163 obj.
push_back(Pair(
"sigsrequired", nRequired));
173 throw std::runtime_error(
174 "validateaddress \"address\"\n" 175 "\nReturn information about the given raven address.\n" 177 "1. \"address\" (string, required) The raven address to validate\n" 180 " \"isvalid\" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.\n" 181 " \"address\" : \"address\", (string) The raven address validated\n" 182 " \"scriptPubKey\" : \"hex\", (string) The hex encoded scriptPubKey generated by the address\n" 183 " \"ismine\" : true|false, (boolean) If the address is yours or not\n" 184 " \"iswatchonly\" : true|false, (boolean) If the address is watchonly\n" 185 " \"isscript\" : true|false, (boolean) If the key is a script\n" 186 " \"script\" : \"type\" (string, optional) The output script type. Possible types: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_keyhash, witness_v0_scripthash\n" 187 " \"hex\" : \"hex\", (string, optional) The redeemscript for the p2sh address\n" 188 " \"addresses\" (string, optional) Array of addresses associated with the known redeemscript\n" 193 " \"sigsrequired\" : xxxxx (numeric, optional) Number of signatures required to spend multisig output\n" 194 " \"pubkey\" : \"publickeyhex\", (string) The hex value of the raw public key\n" 195 " \"iscompressed\" : true|false, (boolean) If the address is compressed\n" 196 " \"account\" : \"account\" (string) DEPRECATED. The account associated with the address, \"\" is the default account\n" 197 " \"timestamp\" : timestamp, (number, optional) The creation time of the key if available in seconds since epoch (Jan 1 1970 GMT)\n" 198 " \"hdkeypath\" : \"keypath\" (string, optional) The HD keypath if the key is HD and available\n" 199 " \"hdmasterkeyid\" : \"<hash160>\" (string, optional) The Hash160 of the HD master pubkey\n" 202 +
HelpExampleCli(
"validateaddress",
"\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"")
203 +
HelpExampleRpc(
"validateaddress",
"\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"")
222 ret.
push_back(Pair(
"address", currentAddress));
231 UniValue detail = boost::apply_visitor(DescribeAddressVisitor(pwallet), dest);
238 const CKeyID *keyID = boost::get<CKeyID>(&dest);
239 auto it = keyID ? meta.find(*keyID) : meta.
end();
240 if (it == meta.end()) {
243 if (it != meta.end()) {
244 ret.
push_back(Pair(
"timestamp", it->second.nCreateTime));
245 if (!it->second.hdKeypath.empty()) {
246 ret.
push_back(Pair(
"hdkeypath", it->second.hdKeypath));
247 ret.
push_back(Pair(
"hdseedid", it->second.hd_seed_id.GetHex()));
264 int nRequired = params[0].
get_int();
269 throw std::runtime_error(
"a multisignature address must require at least one key to redeem");
270 if ((
int)keys.
size() < nRequired)
271 throw std::runtime_error(
273 "(got %u keys, but need at least %d to redeem)", keys.
size(), nRequired));
274 if (keys.
size() > 16)
275 throw std::runtime_error(
"Number of addresses involved in the multisignature address creation > 16\nReduce the number");
276 std::vector<CPubKey> pubkeys;
277 pubkeys.resize(keys.
size());
278 for (
unsigned int i = 0; i < keys.
size(); i++)
280 const std::string& ks = keys[i].
get_str();
285 const CKeyID *keyID = boost::get<CKeyID>(&dest);
287 throw std::runtime_error(
strprintf(
"%s does not refer to a key", ks));
290 if (!pwallet->
GetPubKey(*keyID, vchPubKey)) {
291 throw std::runtime_error(
strprintf(
"no full public key for address %s", ks));
294 throw std::runtime_error(
" Invalid public key: "+ks);
295 pubkeys[i] = vchPubKey;
305 throw std::runtime_error(
" Invalid public key: "+ks);
306 pubkeys[i] = vchPubKey;
310 throw std::runtime_error(
" Invalid public key: "+ks);
315 if (result.
size() > MAX_SCRIPT_ELEMENT_SIZE)
316 throw std::runtime_error(
317 strprintf(
"redeemScript exceeds size limit: %d > %d", result.
size(), MAX_SCRIPT_ELEMENT_SIZE));
327 CWallet *
const pwallet =
nullptr;
332 std::string msg =
"createmultisig nrequired [\"key\",...]\n" 333 "\nCreates a multi-signature address with n signature of m keys required.\n" 334 "It returns a json object with the address and redeemScript.\n" 337 "1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n" 338 "2. \"keys\" (string, required) A json array of keys which are raven addresses or hex-encoded public keys\n" 340 " \"key\" (string) raven address or hex-encoded public key\n" 346 " \"address\":\"multisigaddress\", (string) The value of the new multisig address.\n" 347 " \"redeemScript\":\"script\" (string) The string value of the hex-encoded redemption script.\n" 351 "\nCreate a multisig address from 2 addresses\n" 352 +
HelpExampleCli(
"createmultisig",
"2 \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") +
353 "\nAs a json rpc call\n" 354 +
HelpExampleRpc(
"createmultisig",
"2, \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"")
356 throw std::runtime_error(msg);
373 throw std::runtime_error(
374 "verifymessage \"address\" \"signature\" \"message\"\n" 375 "\nVerify a signed message\n" 377 "1. \"address\" (string, required) The raven address to use for the signature.\n" 378 "2. \"signature\" (string, required) The signature provided by the signer in base 64 encoding (see signmessage).\n" 379 "3. \"message\" (string, required) The message that was signed.\n" 381 "true|false (boolean) If the signature is verified or not.\n" 383 "\nUnlock the wallet for 30 seconds\n" 385 "\nCreate the signature\n" 386 +
HelpExampleCli(
"signmessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"my message\"") +
387 "\nVerify the signature\n" 388 +
HelpExampleCli(
"verifymessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"signature\" \"my message\"") +
390 +
HelpExampleRpc(
"verifymessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"signature\", \"my message\"")
404 const CKeyID *keyID = boost::get<CKeyID>(&destination);
409 bool fInvalid =
false;
410 std::vector<unsigned char> vchSig =
DecodeBase64(strSign.c_str(), &fInvalid);
423 return (pubkey.
GetID() == *keyID);
429 throw std::runtime_error(
430 "signmessagewithprivkey \"privkey\" \"message\"\n" 431 "\nSign a message with the private key of an address\n" 433 "1. \"privkey\" (string, required) The private key to sign the message with.\n" 434 "2. \"message\" (string, required) The message to create a signature of.\n" 436 "\"signature\" (string) The signature of the message encoded in base 64\n" 438 "\nCreate the signature\n" 439 +
HelpExampleCli(
"signmessagewithprivkey",
"\"privkey\" \"my message\"") +
440 "\nVerify the signature\n" 441 +
HelpExampleCli(
"verifymessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"signature\" \"my message\"") +
443 +
HelpExampleRpc(
"signmessagewithprivkey",
"\"privkey\", \"my message\"")
450 bool fGood = vchSecret.
SetString(strPrivkey);
461 std::vector<unsigned char> vchSig;
471 throw std::runtime_error(
472 "setmocktime timestamp\n" 473 "\nSet the local time to given timestamp (-regtest only)\n" 475 "1. timestamp (integer, required) Unix seconds-since-epoch timestamp\n" 476 " Pass 0 to go back to using the system time." 480 throw std::runtime_error(
"setmocktime for regression testing (-regtest mode) only");
495 static UniValue RPCLockedMemoryInfo()
508 #ifdef HAVE_MALLOC_INFO 509 static std::string RPCMallocInfo()
513 FILE *f = open_memstream(&ptr, &size);
518 std::string rv(ptr, size);
533 throw std::runtime_error(
534 "getmemoryinfo (\"mode\")\n" 535 "Returns an object containing information about memory usage.\n" 537 "1. \"mode\" determines what kind of information is returned. This argument is optional, the default mode is \"stats\".\n" 538 " - \"stats\" returns general statistics about memory usage in the daemon.\n" 539 " - \"mallocinfo\" returns an XML string describing low-level heap state (only available if compiled with glibc 2.10+).\n" 540 "\nResult (mode \"stats\"):\n" 542 " \"locked\": { (json object) Information about locked memory manager\n" 543 " \"used\": xxxxx, (numeric) Number of bytes used\n" 544 " \"free\": xxxxx, (numeric) Number of bytes available in current arenas\n" 545 " \"total\": xxxxxxx, (numeric) Total number of bytes managed\n" 546 " \"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" 547 " \"chunks_used\": xxxxx, (numeric) Number allocated chunks\n" 548 " \"chunks_free\": xxxxx, (numeric) Number unused chunks\n" 551 "\nResult (mode \"mallocinfo\"):\n" 552 "\"<malloc version=\"1\">...\"\n" 559 if (mode ==
"stats") {
561 obj.
push_back(Pair(
"locked", RPCLockedMemoryInfo()));
563 }
else if (mode ==
"mallocinfo") {
564 #ifdef HAVE_MALLOC_INFO 565 return RPCMallocInfo();
577 for (
unsigned int i = 0; i < cats.
size(); ++i) {
579 std::string cat = cats[i].
get_str();
591 throw std::runtime_error(
592 "logging [include,...] <exclude>\n" 593 "Gets and sets the logging configuration.\n" 594 "When called without an argument, returns the list of categories that are currently being debug logged.\n" 595 "When called with arguments, adds or removes categories from debug logging.\n" 597 "libevent logging is configured on startup and cannot be modified by this RPC during runtime." 599 "1. \"include\" (array of strings) add debug logging for these categories.\n" 600 "2. \"exclude\" (array of strings) remove debug logging for these categories.\n" 601 "\nResult: <categories> (string): a list of the logging categories that are active.\n" 603 +
HelpExampleCli(
"logging",
"\"[\\\"all\\\"]\" \"[\\\"http\\\"]\"")
622 uint32_t changedLogCategories = originalLogCategories ^
logCategories;
626 if (changedLogCategories == BCLog::LIBEVENT) {
634 for (
const auto& logCatActive : vLogCatActive) {
635 result.
pushKV(logCatActive.category, logCatActive.active);
644 throw std::runtime_error(
645 "echo|echojson \"message\" ...\n" 646 "\nSimply echo back the input arguments. This command is for testing.\n" 647 "\nThe difference between echo and echojson is that echojson has argument conversion enabled in the client-side table in" 648 "raven-cli and the GUI. There is no server-side difference." 658 }
else if (type == 1) {
668 if (params[0].isStr()) {
675 addresses.push_back(std::make_pair(hashBytes, type));
676 }
else if (params[0].isObject()) {
679 if (!addressValues.
isArray()) {
683 std::vector<UniValue> values = addressValues.
getValues();
685 for (std::vector<UniValue>::iterator it = values.begin(); it != values.end(); ++it) {
690 if (!address.GetIndexKey(hashBytes, type)) {
693 addresses.push_back(std::make_pair(hashBytes, type));
702 bool heightSort(std::pair<CAddressUnspentKey, CAddressUnspentValue> a,
703 std::pair<CAddressUnspentKey, CAddressUnspentValue> b) {
704 return a.second.blockHeight < b.second.blockHeight;
707 bool timestampSort(std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta> a,
708 std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta> b) {
709 return a.second.time < b.second.time;
715 throw std::runtime_error(
716 "getaddressmempool\n" 717 "\nReturns all mempool deltas for an address (requires addressindex to be enabled).\n" 722 " \"address\" (string) The base58check encoded address\n" 726 "\"includeAssets\" (boolean, optional, default false) If true this will return an expanded result which includes asset deltas\n" 730 " \"address\" (string) The base58check encoded address\n" 731 " \"assetName\" (string) The name of the associated asset (RVN for Ravencoin)\n" 732 " \"txid\" (string) The related txid\n" 733 " \"index\" (number) The related input or output index\n" 734 " \"satoshis\" (number) The difference of satoshis\n" 735 " \"timestamp\" (number) The time the transaction entered the mempool (seconds)\n" 736 " \"prevtxid\" (string) The previous txid (if spending)\n" 737 " \"prevout\" (string) The previous transaction output index (if spending)\n" 741 +
HelpExampleCli(
"getaddressmempool",
"'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
742 +
HelpExampleRpc(
"getaddressmempool",
"{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}")
743 +
HelpExampleCli(
"getaddressmempool",
"'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}', true")
744 +
HelpExampleRpc(
"getaddressmempool",
"{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}, true")
747 std::vector<std::pair<uint160, int> > addresses;
753 bool includeAssets =
false;
762 std::vector<std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta> > indexes;
778 for (std::vector<std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta> >::iterator it = indexes.begin();
779 it != indexes.end(); it++) {
787 delta.
push_back(Pair(
"address", address));
788 delta.
push_back(Pair(
"assetName", it->first.asset));
789 delta.
push_back(Pair(
"txid", it->first.txhash.GetHex()));
790 delta.
push_back(Pair(
"index", (
int)it->first.index));
791 delta.
push_back(Pair(
"satoshis", it->second.amount));
792 delta.
push_back(Pair(
"timestamp", it->second.time));
793 if (it->second.amount < 0) {
794 delta.
push_back(Pair(
"prevtxid", it->second.prevhash.GetHex()));
795 delta.
push_back(Pair(
"prevout", (
int)it->second.prevout));
797 result.push_back(delta);
806 throw std::runtime_error(
808 "\nReturns all unspent outputs for an address (requires addressindex to be enabled).\n" 813 " \"address\" (string) The base58check encoded address\n" 816 " \"chainInfo\", (boolean, optional, default false) Include chain info with results\n" 817 " \"assetName\" (string, optional) Get UTXOs for a particular asset instead of RVN ('*' for all assets).\n" 822 " \"address\" (string) The address base58check encoded\n" 823 " \"assetName\" (string) The asset associated with the UTXOs (RVN for Ravencoin)\n" 824 " \"txid\" (string) The output txid\n" 825 " \"height\" (number) The block height\n" 826 " \"outputIndex\" (number) The output index\n" 827 " \"script\" (strin) The script hex encoded\n" 828 " \"satoshis\" (number) The number of satoshis of the output\n" 832 +
HelpExampleCli(
"getaddressutxos",
"'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
833 +
HelpExampleRpc(
"getaddressutxos",
"{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}")
834 +
HelpExampleCli(
"getaddressutxos",
"'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"],\"assetName\":\"MY_ASSET\"}'")
835 +
HelpExampleRpc(
"getaddressutxos",
"{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"],\"assetName\":\"MY_ASSET\"}")
838 bool includeChainInfo =
false;
839 std::string assetName = RVN;
843 includeChainInfo = chainInfo.
get_bool();
846 if (assetNameParam.
isStr()) {
849 assetName = assetNameParam.
get_str();
853 std::vector<std::pair<uint160, int> > addresses;
859 std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
861 for (std::vector<std::pair<uint160, int> >::iterator it = addresses.begin(); it != addresses.end(); it++) {
862 if (assetName ==
"*") {
873 std::sort(unspentOutputs.begin(), unspentOutputs.end(),
heightSort);
877 for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) {
884 std::string assetNameOut =
"RVN";
885 if (assetName !=
"RVN") {
892 output.
push_back(Pair(
"address", address));
893 output.
push_back(Pair(
"assetName", assetNameOut));
894 output.
push_back(Pair(
"txid", it->first.txhash.GetHex()));
895 output.
push_back(Pair(
"outputIndex", (
int)it->first.index));
896 output.
push_back(Pair(
"script",
HexStr(it->second.script.begin(), it->second.script.end())));
897 output.
push_back(Pair(
"satoshis", it->second.satoshis));
898 output.
push_back(Pair(
"height", it->second.blockHeight));
899 utxos.push_back(output);
902 if (includeChainInfo) {
918 throw std::runtime_error(
920 "\nReturns all changes for an address (requires addressindex to be enabled).\n" 925 " \"address\" (string) The base58check encoded address\n" 928 " \"start\" (number) The start block height\n" 929 " \"end\" (number) The end block height\n" 930 " \"chainInfo\" (boolean) Include chain info in results, only applies if start and end specified\n" 931 " \"assetName\" (string, optional) Get deltas for a particular asset instead of RVN.\n" 936 " \"assetName\" (string) The asset associated with the deltas (RVN for Ravencoin)\n" 937 " \"satoshis\" (number) The difference of satoshis\n" 938 " \"txid\" (string) The related txid\n" 939 " \"index\" (number) The related input or output index\n" 940 " \"height\" (number) The block height\n" 941 " \"address\" (string) The base58check encoded address\n" 945 +
HelpExampleCli(
"getaddressdeltas",
"'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
946 +
HelpExampleRpc(
"getaddressdeltas",
"{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}")
947 +
HelpExampleCli(
"getaddressdeltas",
"'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"],\"assetName\":\"MY_ASSET\"}'")
948 +
HelpExampleRpc(
"getaddressdeltas",
"{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"],\"assetName\":\"MY_ASSET\"}")
956 bool includeChainInfo =
false;
957 if (chainInfo.isBool()) {
958 includeChainInfo = chainInfo.
get_bool();
961 std::string assetName = RVN;
963 if (assetNameParam.
isStr()) {
966 assetName = assetNameParam.
get_str();
972 if (startValue.
isNum() && endValue.isNum()) {
974 end = endValue.get_int();
975 if (start <= 0 || end <= 0) {
983 std::vector<std::pair<uint160, int> > addresses;
989 std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex;
991 for (std::vector<std::pair<uint160, int> >::iterator it = addresses.begin(); it != addresses.end(); it++) {
992 if (start > 0 && end > 0) {
993 if (!
GetAddressIndex((*it).first, (*it).second, assetName, addressIndex, start, end)) {
997 if (!
GetAddressIndex((*it).first, (*it).second, assetName, addressIndex)) {
1005 for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) {
1006 std::string address;
1012 delta.
push_back(Pair(
"assetName", it->first.asset));
1013 delta.
push_back(Pair(
"satoshis", it->second));
1014 delta.
push_back(Pair(
"txid", it->first.txhash.GetHex()));
1015 delta.
push_back(Pair(
"index", (
int)it->first.index));
1016 delta.
push_back(Pair(
"blockindex", (
int)it->first.txindex));
1017 delta.
push_back(Pair(
"height", it->first.blockHeight));
1018 delta.
push_back(Pair(
"address", address));
1024 if (includeChainInfo && start > 0 && end > 0) {
1038 startInfo.
push_back(Pair(
"height", start));
1043 result.
push_back(Pair(
"deltas", deltas));
1044 result.
push_back(Pair(
"start", startInfo));
1056 throw std::runtime_error(
1057 "getaddressbalance\n" 1058 "\nReturns the balance for an address(es) (requires addressindex to be enabled).\n" 1063 " \"address\" (string) The base58check encoded address\n" 1067 "\"includeAssets\" (boolean, optional, default false) If true this will return an expanded result which includes asset balances\n" 1071 " \"balance\" (string) The current balance in satoshis\n" 1072 " \"received\" (string) The total number of satoshis received (including change)\n" 1077 " \"assetName\" (string) The asset associated with the balance (RVN for Ravencoin)\n" 1078 " \"balance\" (string) The current balance in satoshis\n" 1079 " \"received\" (string) The total number of satoshis received (including change)\n" 1083 +
HelpExampleCli(
"getaddressbalance",
"'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
1084 +
HelpExampleCli(
"getaddressbalance",
"'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}', true")
1085 +
HelpExampleRpc(
"getaddressbalance",
"{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}")
1086 +
HelpExampleRpc(
"getaddressbalance",
"{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}, true")
1089 std::vector<std::pair<uint160, int> > addresses;
1095 bool includeAssets =
false;
1100 if (includeAssets) {
1104 std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex;
1106 for (std::vector<std::pair<uint160, int> >::iterator it = addresses.begin(); it != addresses.end(); it++) {
1113 std::map<std::string, std::pair<CAmount, CAmount>> balances;
1115 for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it = addressIndex.begin();
1116 it != addressIndex.end(); it++) {
1117 std::string assetName = it->first.asset;
1118 if (balances.count(assetName) == 0) {
1119 balances[assetName] = std::make_pair(0, 0);
1121 if (it->second > 0) {
1122 balances[assetName].first += it->second;
1124 balances[assetName].second += it->second;
1129 for (std::map<std::string, std::pair<CAmount, CAmount>>::const_iterator it = balances.begin();
1130 it != balances.end(); it++) {
1132 balance.
push_back(Pair(
"assetName", it->first));
1133 balance.
push_back(Pair(
"balance", it->second.second));
1134 balance.
push_back(Pair(
"received", it->second.first));
1141 std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex;
1143 for (std::vector<std::pair<uint160, int> >::iterator it = addresses.begin(); it != addresses.end(); it++) {
1152 for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it = addressIndex.begin();
1153 it != addressIndex.end(); it++) {
1154 if (it->second > 0) {
1155 received += it->second;
1157 balance += it->second;
1161 result.
push_back(Pair(
"balance", balance));
1162 result.
push_back(Pair(
"received", received));
1172 throw std::runtime_error(
1174 "\nReturns the txids for an address(es) (requires addressindex to be enabled).\n" 1179 " \"address\" (string) The base58check encoded address\n" 1182 " \"start\" (number, optional) The start block height\n" 1183 " \"end\" (number, optional) The end block height\n" 1185 "\"includeAssets\" (boolean, optional, default false) If true this will return an expanded result which includes asset transactions\n" 1188 " \"transactionid\" (string) The transaction id\n" 1192 +
HelpExampleCli(
"getaddresstxids",
"'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
1193 +
HelpExampleRpc(
"getaddresstxids",
"{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}")
1194 +
HelpExampleCli(
"getaddresstxids",
"'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}', true")
1195 +
HelpExampleRpc(
"getaddresstxids",
"{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}, true")
1198 std::vector<std::pair<uint160, int> > addresses;
1209 if (startValue.
isNum() && endValue.isNum()) {
1211 end = endValue.get_int();
1215 bool includeAssets =
false;
1224 std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex;
1226 for (std::vector<std::pair<uint160, int> >::iterator it = addresses.begin(); it != addresses.end(); it++) {
1227 if (includeAssets) {
1228 if (start > 0 && end > 0) {
1229 if (!
GetAddressIndex((*it).first, (*it).second, addressIndex, start, end)) {
1238 if (start > 0 && end > 0) {
1239 if (!
GetAddressIndex((*it).first, (*it).second, RVN, addressIndex, start, end)) {
1250 std::set<std::pair<int, std::string> > txids;
1253 for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) {
1254 int height = it->first.blockHeight;
1255 std::string txid = it->first.txhash.GetHex();
1257 if (addresses.size() > 1) {
1258 txids.insert(std::make_pair(height, txid));
1260 if (txids.insert(std::make_pair(height, txid)).second) {
1266 if (addresses.size() > 1) {
1267 for (std::set<std::pair<int, std::string> >::const_iterator it=txids.begin(); it!=txids.end(); it++) {
1280 throw std::runtime_error(
1282 "\nReturns the txid and index where an output is spent.\n" 1285 " \"txid\" (string) The hex string of the txid\n" 1286 " \"index\" (number) The start block height\n" 1290 " \"txid\" (string) The transaction id\n" 1291 " \"index\" (number) The spending input index\n" 1295 +
HelpExampleCli(
"getspentinfo",
"'{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}'")
1296 +
HelpExampleRpc(
"getspentinfo",
"{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}")
1302 if (!txidValue.
isStr() || !indexValue.isNum()) {
1307 int outputIndex = indexValue.get_int();
1327 {
"control",
"getinfo", &
getinfo, {} },
1330 {
"util",
"createmultisig", &
createmultisig, {
"nrequired",
"keys"} },
1331 {
"util",
"verifymessage", &
verifymessage, {
"address",
"signature",
"message"} },
1335 {
"addressindex",
"getaddressmempool", &
getaddressmempool, {
"addresses",
"includeAssets"} },
1336 {
"addressindex",
"getaddressutxos", &
getaddressutxos, {
"addresses"} },
1338 {
"addressindex",
"getaddresstxids", &
getaddresstxids, {
"addresses",
"includeAssets"} },
1339 {
"addressindex",
"getaddressbalance", &
getaddressbalance, {
"addresses",
"includeAssets"} },
1345 {
"hidden",
"setmocktime", &
setmocktime, {
"timestamp"}},
1346 {
"hidden",
"echo", &
echo, {
"arg0",
"arg1",
"arg2",
"arg3",
"arg4",
"arg5",
"arg6",
"arg7",
"arg8",
"arg9"}},
1347 {
"hidden",
"echojson", &
echo, {
"arg0",
"arg1",
"arg2",
"arg3",
"arg4",
"arg5",
"arg6",
"arg7",
"arg8",
"arg9"}},
1348 {
"hidden",
"logging", &
logging, {
"include",
"exclude"}},
1353 for (
unsigned int vcidx = 0; vcidx <
ARRAYLEN(commands); vcidx++)
std::string ListLogCategories()
Returns a string with the log categories.
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
const std::vector< UniValue > & getValues() const
int64_t GetOldestKeyPoolTime()
bool GetAddressIndex(uint160 addressHash, int type, std::string assetName, std::vector< std::pair< CAddressIndexKey, CAmount > > &addressIndex, int start, int end)
std::vector< unsigned char > DecodeBase64(const char *p, bool *pfInvalid)
Raven RPC command dispatcher.
static LockedPoolManager & Instance()
Return the current instance, or create it once.
std::map< CTxDestination, CAddressBookData > mapAddressBook
CCriticalSection cs_wallet
bool GetCScript(const CScriptID &hash, CScript &redeemScriptOut) const override
int Height() const
Return the maximal height in the chain.
void SetMockTime(int64_t nMockTimeIn)
CCriticalSection cs_main
Global state.
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
CTxDestination DecodeDestination(const std::string &str)
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
isminetype IsMine(const CKeyStore &keystore, const CScript &scriptPubKey, SigVersion sigversion)
const std::string & get_str() const
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
const UniValue & get_array() const
const std::string CURRENCY_UNIT
unsigned int GetKeyPoolSize()
UniValue verifymessage(const JSONRPCRequest &request)
double GetDifficulty(const CBlockIndex *blockindex)
Get the difficulty of the net wrt to the given block index, or the chain tip if not provided...
int64_t get_int64() const
bool getAddressIndex(std::vector< std::pair< uint160, int > > &addresses, std::string assetName, std::vector< std::pair< CMempoolAddressDeltaKey, CMempoolAddressDelta > > &results)
std::map< CTxDestination, CKeyMetadata > mapKeyMetadata
int64_t GetTimeOffset()
"Never go to sea with two chronometers; take one or three." Our three time sources are: ...
std::atomic< uint32_t > logCategories
bool pushKVs(const UniValue &obj)
std::string GetWarnings(const std::string &strFor)
Format a string that describes several potential problems detected by the core.
UniValue ValueFromAmount(const CAmount &amount, const int8_t units)
UniValue getaddressbalance(const JSONRPCRequest &request)
bool appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
const std::string strMessageMagic
bool GetAddressUnspent(uint160 addressHash, int type, std::string assetName, std::vector< std::pair< CAddressUnspentKey, CAddressUnspentValue > > &unspentOutputs)
CAmount GetBalance() const
void RPCTypeCheck(const UniValue ¶ms, const std::list< UniValue::VType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
Invalid, missing or duplicate parameter.
UniValue createmultisig(const JSONRPCRequest &request)
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded Values (throws error if not hex).
bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override
const UniValue & find_value(const UniValue &obj, const std::string &name)
bool GetIndexKey(uint160 &hashBytes, int &type) const
bool SignCompact(const uint256 &hash, std::vector< unsigned char > &vchSig) const
Create a compact signature (65 bytes), which allows reconstructing the used public key...
bool ExtractDestinations(const CScript &scriptPubKey, txnouttype &typeRet, std::vector< CTxDestination > &addressRet, int &nRequiredRet)
Parse a standard scriptPubKey with one or more destination addresses.
std::string ToString() const
int64_t CAmount
Amount in corbies (Can be negative)
uint256 GetBlockHash() const
bool push_back(const UniValue &val)
bool AreAssetsDeployed()
RVN START.
bool IsFullyValid() const
fully validate whether this is a valid public key (more expensive than IsValid()) ...
bool MineBlocksOnDemand() const
Make miner stop after a block is found.
base58-encoded Raven addresses.
CFeeRate minRelayTxFee
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) ...
isminetype
IsMine() return codes.
UniValue getinfo(const JSONRPCRequest &request)
bool RecoverCompact(const uint256 &hash, const std::vector< unsigned char > &vchSig)
Recover a public key from a compact signature.
int GetVersion()
get the current wallet format (the oldest client version guaranteed to understand this wallet) ...
An encapsulated public key.
bool SetString(const char *pszSecret)
bool IsHex(const std::string &str)
Unexpected type was passed as parameter.
const char * GetTxnOutputType(txnouttype t)
Get the name of a txnouttype as a C string, or nullptr if unknown.
bool GetAssetInfoFromScript(const CScript &scriptPubKey, std::string &strName, CAmount &nAmount)
bool pushKV(const std::string &key, const UniValue &val)
UniValue getaddressdeltas(const JSONRPCRequest &request)
CChain chainActive
The currently-connected chain of blocks (protected by cs_main).
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Raven scriptPubKey for the given CTxDestination.
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
bool GetSpentIndex(CSpentIndexKey &key, CSpentIndexValue &value)
UniValue getaddresstxids(const JSONRPCRequest &request)
UniValue setmocktime(const JSONRPCRequest &request)
UniValue validateaddress(const JSONRPCRequest &request)
UniValue getmemoryinfo(const JSONRPCRequest &request)
UniValue getaddressutxos(const JSONRPCRequest &request)
UniValue signmessagewithprivkey(const JSONRPCRequest &request)
bool heightSort(std::pair< CAddressUnspentKey, CAddressUnspentValue > a, std::pair< CAddressUnspentKey, CAddressUnspentValue > b)
CScript _createmultisig_redeemScript(CWallet *const pwallet, const UniValue ¶ms)
Used by addmultisigaddress / createmultisig:
uint32_t getCategoryMask(UniValue cats)
std::string EncodeDestination(const CTxDestination &dest)
The block chain is a tree shaped structure starting with the genesis block at the root...
const CChainParams & Params()
Return the currently selected parameters.
A base58-encoded secret key.
Serialized script, used inside transaction inputs and outputs.
void RegisterMiscRPCCommands(CRPCTable &t)
Register miscellaneous RPC commands.
const UniValue & get_obj() const
std::string ToStringIPPort() const
UniValue getaddressmempool(const JSONRPCRequest &request)
A reference to a CKey: the Hash160 of its serialized public key.
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
UniValue logging(const JSONRPCRequest &request)
std::string GetHex() const
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
std::unique_ptr< CConnman > g_connman
const UniValue NullUniValue
CWallet * GetWalletForJSONRPCRequest(const JSONRPCRequest &request)
Figures out what wallet, if any, to use for a JSONRPCRequest.
CFeeRate payTxFee(DEFAULT_TRANSACTION_FEE)
Transaction fee set by the user.
A reference to a CScript: the Hash160 of its serialization (see script.h)
static const std::string TESTNET
A writer stream (for serialization) that computes a 256-bit hash.
bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address)
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Generate a multisig script.
bool GetProxy(enum Network net, proxyType &proxyInfoOut)
UniValue JSONRPCError(int code, const std::string &message)
An encapsulated private key.
Stats stats() const
Get pool usage statistics.
UniValue getspentinfo(const JSONRPCRequest &request)
bool GetLogCategory(uint32_t *f, const std::string *str)
Return true if str parses as a log category and set the flags in f.
UniValue echo(const JSONRPCRequest &request)
bool getAddressesFromParams(const UniValue ¶ms, std::vector< std::pair< uint160, int > > &addresses)
CAmount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
std::vector< CLogCategoryActive > ListActiveLogCategories()
Returns a vector of the active log categories.
int64_t nRelockTime
Holds a timestamp at which point the wallet is scheduled (externally) to be relocked. Caller must arrange for actual relocking to occur via Lock().
bool timestampSort(std::pair< CMempoolAddressDeltaKey, CMempoolAddressDelta > a, std::pair< CMempoolAddressDeltaKey, CMempoolAddressDelta > b)
std::string EncodeBase64(const unsigned char *pch, size_t len)
bool UpdateHTTPServerLogging(bool enable)
Change logging level for libevent.
bool IsValid() const
Check whether this private key is valid.
std::vector< unsigned char > ParseHex(const char *psz)
bool IsCompressed() const
Check whether this is a compressed public key.