 |
PRCYCoin
2.0.0.7rc1
P2P Digital Currency
|
Go to the documentation of this file.
29 #include <boost/assign/list_of.hpp>
46 if (fHelp || params.
size() != 0)
47 throw std::runtime_error(
49 "Returns an object containing various state info.\n"
52 " \"version\": xxxxx, (numeric) the server version\n"
53 " \"protocolversion\": xxxxx, (numeric) the protocol version\n"
54 " \"walletversion\": xxxxx, (numeric) the wallet version\n"
55 " \"balance\": xxxxxxx, (numeric) the total prcycoin balance of the wallet\n"
56 " \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n"
57 " \"synced\": xxxxxx, (boolean) if the server is synced or not\n"
58 " \"timeoffset\": xxxxx, (numeric) the time offset\n"
59 " \"connections\": xxxxx, (numeric) the number of connections\n"
60 " \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n"
61 " \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
62 " \"testnet\": true|false, (boolean) if the server is using testnet or not\n"
63 " \"moneysupply\" : \"supply\" (numeric) The money supply when this block was added to the blockchain\n"
64 " \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n"
65 " \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n"
66 " \"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"
67 " \"paytxfee\": x.xxxx, (numeric) the transaction fee set in prcycoin/kb\n"
68 " \"relayfee\": x.xxxx, (numeric) minimum relay fee for non-free transactions in prcycoin/kb\n"
69 " \"staking mode\": enabled|disabled, (string) if staking is enabled or disabled\n"
70 " \"staking status\": active|inactive, (string) if staking is active or inactive\n"
71 " \"errors\": \"...\" (string) any error messages\n"
80 obj.
push_back(Pair(
"version", CLIENT_VERSION));
81 obj.
push_back(Pair(
"protocolversion", PROTOCOL_VERSION));
94 obj.
push_back(Pair(
"testnet",
Params().TestnetToBeDeprecatedFieldRPC()));
108 bool nStaking =
false;
114 obj.
push_back(Pair(
"staking mode", (
"disabled")));
115 obj.
push_back(Pair(
"staking status", (
"inactive (wallet locked)")));
119 obj.
push_back(Pair(
"staking status", (
"inactive (no peer connections)")));
121 obj.
push_back(Pair(
"staking status", (
"inactive (syncing masternode list)")));
123 obj.
push_back(Pair(
"staking status", (
"delayed (waiting for 100 blocks)")));
125 obj.
push_back(Pair(
"staking status", (
"inactive (no mintable coins)")));
127 obj.
push_back(Pair(
"staking status", (nStaking ?
"active (attempting to mint a block)" :
"idle (waiting for next round)")));
137 if (fHelp || params.
size() != 0)
138 throw std::runtime_error(
140 "Returns the server version.\n"
143 " \"version\": xxxxx, (numeric) the server version\n"
150 obj.
push_back(Pair(
"version", CLIENT_VERSION));
156 if (params.
size() == 1)
159 if (fHelp || params.
size() != 1 || (strMode !=
"status" && strMode !=
"reset")) {
160 throw std::runtime_error(
161 "mnsync \"status|reset\"\n"
162 "\nReturns the sync status or resets sync.\n"
165 "1. \"mode\" (string, required) either 'status' or 'reset'\n"
167 "\nResult ('status' mode):\n"
169 " \"IsBlockchainSynced\": true|false, (boolean) 'true' if blockchain is synced\n"
170 " \"lastMasternodeList\": xxxx, (numeric) Timestamp of last MN list message\n"
171 " \"lastMasternodeWinner\": xxxx, (numeric) Timestamp of last MN winner message\n"
172 " \"lastBudgetItem\": xxxx, (numeric) Timestamp of last MN budget message\n"
173 " \"lastFailure\": xxxx, (numeric) Timestamp of last failed sync\n"
174 " \"nCountFailures\": n, (numeric) Number of failed syncs (total)\n"
175 " \"sumMasternodeList\": n, (numeric) Number of MN list messages (total)\n"
176 " \"sumMasternodeWinner\": n, (numeric) Number of MN winner messages (total)\n"
177 " \"sumBudgetItemProp\": n, (numeric) Number of MN budget messages (total)\n"
178 " \"sumBudgetItemFin\": n, (numeric) Number of MN budget finalization messages (total)\n"
179 " \"countMasternodeList\": n, (numeric) Number of MN list messages (local)\n"
180 " \"countMasternodeWinner\": n, (numeric) Number of MN winner messages (local)\n"
181 " \"countBudgetItemProp\": n, (numeric) Number of MN budget messages (local)\n"
182 " \"countBudgetItemFin\": n, (numeric) Number of MN budget finalization messages (local)\n"
183 " \"RequestedMasternodeAssets\": n, (numeric) Status code of last sync phase\n"
184 " \"RequestedMasternodeAttempt\": n, (numeric) Status code of last sync attempt\n"
187 "\nResult ('reset' mode):\n"
188 "\"status\" (string) 'success'\n"
193 if (strMode ==
"status") {
216 if (strMode ==
"reset") {
224 class DescribeAddressVisitor :
public boost::static_visitor<UniValue>
230 DescribeAddressVisitor(
isminetype mineIn) : mine(mineIn) {}
238 obj.push_back(Pair(
"isscript",
false));
241 obj.push_back(Pair(
"pubkey",
HexStr(vchPubKey)));
242 obj.push_back(Pair(
"iscompressed", vchPubKey.
IsCompressed()));
250 obj.push_back(Pair(
"isscript",
true));
253 std::vector<CTxDestination> addresses;
258 obj.push_back(Pair(
"hex",
HexStr(subscript.
begin(), subscript.
end())));
262 obj.push_back(Pair(
"addresses", a));
264 obj.push_back(Pair(
"sigsrequired", nRequired));
272 if (fHelp || params.
size() != 1)
273 throw std::runtime_error(
274 "validateaddress \"prcycoinaddress\"\n"
275 "\nReturn information about the given prcycoin address.\n"
277 "1. \"prcycoinaddress\" (string, required) The prcycoin address to validate\n"
280 " \"isvalid\" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.\n"
281 " \"address\" : \"prcycoinaddress\", (string) The prcycoin address validated\n"
282 " \"scriptPubKey\" : \"hex\", (string) The hex encoded scriptPubKey generated by the address\n"
283 " \"ismine\" : true|false, (boolean) If the address is yours or not\n"
284 " \"iswatchonly\" : true|false, (boolean) If the address is watchonly\n"
285 " \"isscript\" : true|false, (boolean) If the key is a script\n"
286 " \"hex\" : \"hex\", (string, optional) The redeemscript for the P2SH address\n"
287 " \"pubkey\" : \"publickeyhex\", (string) The hex value of the raw public key\n"
288 " \"iscompressed\" : true|false, (boolean) If the address is compressed\n"
289 " \"account\" : \"account\" (string) The account associated with the address, \"\" is the default account\n"
292 HelpExampleCli(
"validateaddress",
"\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"") +
293 HelpExampleRpc(
"validateaddress",
"\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\""));
302 bool isValid = address.
IsValid();
308 std::string currentAddress = address.
ToString();
309 ret.
push_back(Pair(
"address", currentAddress));
317 UniValue detail = boost::apply_visitor(DescribeAddressVisitor(mine), dest);
328 if (fHelp || params.
size() != 1)
329 throw std::runtime_error(
330 "validatestealthaddress \"prcycoinstealthaddress\"\n"
331 "\nReturn information about the given prcycoin stealth address.\n"
333 "1. \"prcycoinstealthaddress\" (string, required) The prcycoin stealth address to validate\n"
336 " \"isvalid\" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.\n"
339 HelpExampleCli(
"validatestealthaddress",
"\"Pap5WCV4SjVMGLyYf98MEX82ErBEMVpg9ViQ1up3aBib6Fz4841SahrRXG6eSNSLBSNvEiGuQiWKXJC3RDfmotKv15oCrh6N2Ym\"") +
340 HelpExampleRpc(
"validatestealthaddress",
"\"Pap5WCV4SjVMGLyYf98MEX82ErBEMVpg9ViQ1up3aBib6Fz4841SahrRXG6eSNSLBSNvEiGuQiWKXJC3RDfmotKv15oCrh6N2Ym\""));
343 std::string addr = params[0].
get_str();
363 int nRequired = params[0].
get_int();
368 throw std::runtime_error(
"a multisignature address must require at least one key to redeem");
369 if ((
int) keys.
size() < nRequired)
370 throw std::runtime_error(
372 "(got %u keys, but need at least %d to redeem)",
373 keys.
size(), nRequired));
374 if (keys.
size() > 16)
375 throw std::runtime_error(
376 "Number of addresses involved in the multisignature address creation > 16\nReduce the number");
377 std::vector <CPubKey> pubkeys;
378 pubkeys.resize(keys.
size());
379 for (
unsigned int i = 0; i < keys.
size(); i++) {
380 const std::string &ks = keys[i].
get_str();
387 throw std::runtime_error(
388 strprintf(
"%s does not refer to a key", ks));
391 throw std::runtime_error(
392 strprintf(
"no full public key for address %s", ks));
394 throw std::runtime_error(
" Invalid public key: " + ks);
395 pubkeys[i] = vchPubKey;
404 throw std::runtime_error(
" Invalid public key: " + ks);
405 pubkeys[i] = vchPubKey;
407 throw std::runtime_error(
" Invalid public key: " + ks);
412 if (result.
size() > MAX_SCRIPT_ELEMENT_SIZE)
413 throw std::runtime_error(
414 strprintf(
"redeemScript exceeds size limit: %d > %d", result.
size(), MAX_SCRIPT_ELEMENT_SIZE));
420 if (fHelp || params.
size() < 2 || params.
size() > 2) {
421 std::string msg =
"createmultisig nrequired [\"key\",...]\n"
422 "\nCreates a multi-signature address with n signature of m keys required.\n"
423 "It returns a json object with the address and redeemScript.\n"
426 "1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n"
427 "2. \"keys\" (string, required) A json array of keys which are prcycoin addresses or hex-encoded public keys\n"
429 " \"key\" (string) prcycoin address or hex-encoded public key\n"
435 " \"address\":\"multisigaddress\", (string) The value of the new multisig address.\n"
436 " \"redeemScript\":\"script\" (string) The string value of the hex-encoded redemption script.\n"
440 "\nCreate a multisig address from 2 addresses\n" +
442 "2 \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") +
444 "2, \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"");
445 throw std::runtime_error(msg);
461 if (fHelp || params.
size() != 3)
462 throw std::runtime_error(
463 "verifymessage \"prcycoinaddress\" \"signature\" \"message\"\n"
464 "\nVerify a signed message\n"
466 "1. \"prcycoinaddress\" (string, required) The prcycoin address to use for the signature.\n"
467 "2. \"signature\" (string, required) The signature provided by the signer in base 64 encoding (see signmessage).\n"
468 "3. \"message\" (string, required) The message that was signed.\n"
470 "true|false (boolean) If the signature is verified or not.\n"
472 "\nUnlock the wallet for 30 seconds\n" +
474 "\nCreate the signature\n" +
HelpExampleCli(
"signmessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XZ\" \"my message\"") +
475 "\nVerify the signature\n" +
HelpExampleCli(
"verifymessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XZ\" \"signature\" \"my message\"") +
476 "\nAs json rpc\n" +
HelpExampleRpc(
"verifymessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XZ\", \"signature\", \"my message\""));
478 std::string strAddress = params[0].
get_str();
479 std::string strSign = params[1].
get_str();
480 std::string strMessage = params[2].
get_str();
490 bool fInvalid =
false;
491 std::vector<unsigned char> vchSig =
DecodeBase64(strSign.c_str(), &fInvalid);
504 return (pubkey.
GetID() == keyID);
508 if (fHelp || params.
size() != 1)
509 throw std::runtime_error(
510 "setmocktime timestamp\n"
511 "\nSet the local time to given timestamp (-regtest only)\n"
513 "1. timestamp (integer, required) Unix seconds-since-epoch timestamp\n"
514 " Pass 0 to go back to using the system time.");
516 if (!
Params().MineBlocksOnDemand())
517 throw std::runtime_error(
"setmocktime for regression testing (-regtest mode) only");
529 for (
unsigned int i = 0; i < cats.
size(); ++i) {
530 std::string cat = cats[i].
get_str();
546 if (fHelp || params.
size() > 2) {
547 throw std::runtime_error(
548 "logging [include,...] <exclude>\n"
549 "Gets and sets the logging configuration.\n"
550 "When called without an argument, returns the list of categories that are currently being debug logged.\n"
551 "When called with arguments, adds or removes categories from debug logging.\n"
553 "libevent logging is configured on startup and cannot be modified by this RPC during runtime."
555 "1. \"include\" (array of strings) add debug logging for these categories.\n"
556 "2. \"exclude\" (array of strings) remove debug logging for these categories.\n"
557 "\nResult: <categories> (string): a list of the logging categories that are active.\n"
559 +
HelpExampleCli(
"logging",
"\"[\\\"all\\\"]\" \"[\\\"http\\\"]\"")
574 uint32_t changed_log_categories = original_log_categories ^ updated_log_categories;
592 for (
const auto& logCatActive : vLogCatActive) {
593 result.
pushKV(logCatActive.category, logCatActive.active);
602 if (fHelp || params.
size() != 0)
603 throw std::runtime_error(
605 "Returns an object containing various staking information.\n"
608 " \"haveconnections\": true|false, (boolean) if network connections are present\n"
609 " \"walletunlocked\": true|false, (boolean) if the wallet is unlocked\n"
610 " \"mintablecoins\": true|false, (boolean) if the wallet has mintable coins\n"
611 " \"enoughcoins\": true|false, (boolean) if available coins are greater than reserve balance\n"
612 " \"masternodes-synced\": true|false, (boolean) if masternode data is synced\n"
613 " \"staking mode\": enabled|disabled, (string) if staking is enabled or disabled\n"
614 " \"staking status\": active|inactive, (string) if staking is active or inactive\n"
627 obj.push_back(Pair(
"haveconnections", !
vNodes.empty()));
631 obj.push_back(Pair(
"enoughcoins", nReserveBalance <= pwalletMain->GetBalance()));
635 bool nStaking =
false;
641 obj.push_back(Pair(
"staking mode", (
"disabled")));
642 obj.push_back(Pair(
"staking status", (
"inactive (wallet locked)")));
646 obj.push_back(Pair(
"staking status", (
"inactive (no peer connections)")));
648 obj.push_back(Pair(
"staking status", (
"inactive (syncing masternode list)")));
650 obj.push_back(Pair(
"staking status", (
"delayed (waiting for 100 blocks)")));
652 obj.push_back(Pair(
"staking status", (
"inactive (no mintable coins)")));
654 obj.push_back(Pair(
"staking status", (nStaking ?
"active (attempting to mint a block)" :
"idle (waiting for next round)")));
659 #endif // ENABLE_WALLET
UniValue verifymessage(const UniValue ¶ms, bool fHelp)
std::vector< CNode * > vNodes
isminetype IsMine(const CKeyStore &keystore, const CTxDestination &dest)
CFeeRate minRelayTxFee
Fees smaller than this (in duffs) are considered zero fee (for relaying and mining) We are ~100 times...
UniValue getversion(const UniValue ¶ms, bool fHelp)
std::vector< CLogCategoryActive > ListActiveLogCategories()
Returns a vector of the active log categories.
int RequestedMasternodeAssets
bool WillLogCategory(LogFlags category) const
int64_t GetOldestKeyPoolTime()
std::vector< unsigned char > ParseHex(const char *psz)
bool GetKeyID(CKeyID &keyID) const
UniValue ValueFromAmount(const CAmount &amount)
CChain chainActive
The currently-connected chain of blocks.
const UniValue NullUniValue
CScript GetScriptForDestination(const CTxDestination &dest)
base58-encoded PRCY addresses.
@ RPC_INVALID_PARAMETER
Ran out of memory during operation.
bool IsBlockchainSynced()
int nHeight
height of the entry in the chain. The genesis block has height 0
void SetMockTime(int64_t nMockTimeIn)
int64_t lastMasternodeWinner
int countMasternodeWinner
BCLog::Logger *const g_logger
NOTE: the logger instances is leaked on exit.
int RequestedMasternodeAttempt
uint32_t GetCategoryMask() const
isminetype
IsMine() return codes.
A reference to a CKey: the Hash160 of its serialized public key.
UniValue validateaddress(const UniValue ¶ms, bool fHelp)
void RPCTypeCheck(const UniValue ¶ms, const std::list< UniValue::VType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
std::string ToString() const
CFeeRate payTxFee(DEFAULT_TRANSACTION_FEE)
Transaction fee set by the user.
bool pushKV(const std::string &key, const UniValue &val)
std::string ToStringIPPort() const
int64_t nWalletUnlockTime
std::vector< unsigned char > DecodeBase64(const char *p, bool *pfInvalid)
CMasternodeSync masternodeSync
const std::string & get_str() const
RecursiveMutex cs_main
Global state.
const char * GetTxnOutputType(txnouttype t)
bool pushKVs(const UniValue &obj)
bool IsHex(const std::string &str)
std::string GetWarnings(std::string strFor)
Format a string that describes several potential problems detected by the core.
bool UpdateHTTPServerLogging(bool enable)
Change logging level for libevent.
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
int GetVersion()
get the current wallet format (the oldest client version guaranteed to understand this wallet)
UniValue JSONRPCError(int code, const std::string &message)
void EnableCategory(LogFlags flag)
UniValue validatestealthaddress(const UniValue ¶ms, bool fHelp)
UniValue logging(const UniValue ¶ms, bool fHelp)
std::map< unsigned int, unsigned int > mapHashedBlocks
std::string HelpExampleRpc(std::string methodname, std::string args)
CScript _createmultisig_redeemScript(const UniValue ¶ms)
Used by addmultisigaddress / createmultisig:
Serialized script, used inside transaction inputs and outputs.
virtual bool GetCScript(const CScriptID &hash, CScript &redeemScriptOut) const
@ ISMINE_WATCH_ONLY
Indicates that we dont know how to create a scriptSig that would solve this if we were given the appr...
bool RecoverCompact(const uint256 &hash, const std::vector< unsigned char > &vchSig)
Recover a public key from a compact signature.
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
UniValue createmultisig(const UniValue ¶ms, bool fHelp)
int Height() const
Return the maximal height in the chain.
UniValue getinfo(const UniValue ¶ms, bool fHelp)
int64_t lastMasternodeList
std::string HelpExampleCli(std::string methodname, std::string args)
@ RPC_INVALID_ADDRESS_OR_KEY
Unexpected type was passed as parameter.
bool IsCompressed() const
Check whether this is a compressed public key.
std::string ListLogCategories()
Returns a string with the supported log categories.
int64_t nLastCoinStakeSearchInterval
static bool DecodeStealthAddress(const std::string &stealth, CPubKey &pubViewKey, CPubKey &pubSpendKey, bool &hasPaymentID, uint64_t &paymentID)
An encapsulated public key.
bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const
GetPubKey implementation that also checks the mapHdPubKeys.
A writer stream (for serialization) that computes a 256-bit hash.
bool push_back(const UniValue &val)
const std::string strMessageMagic
const CChainParams & Params()
Return the currently selected parameters.
bool IsFullyValid() const
fully validate whether this is a valid public key (more expensive than IsValid())
bool GetProxy(enum Network net, proxyType &proxyInfoOut)
UniValue setmocktime(const UniValue ¶ms, bool fHelp)
CBlockIndex * Tip(bool fProofOfStake=false) const
Returns the index entry for the tip of this chain, or NULL if none.
@ RPC_TYPE_ERROR
Server is in safe mode, and command is not allowed in safe mode.
void DisableCategory(LogFlags flag)
void EnableOrDisableLogCategories(UniValue cats, bool enable)
UniValue mnsync(const UniValue ¶ms, bool fHelp)
int64_t GetTimeOffset()
"Never go to sea with two chronometers; take one or three." Our three time sources are:
const UniValue & get_array() const
bool ExtractDestinations(const CScript &scriptPubKey, txnouttype &typeRet, std::vector< CTxDestination > &addressRet, int &nRequiredRet)
A reference to a CScript: the Hash160 of its serialization (see script.h)
CAmount GetFeePerK() const
CTxDestination Get() const
UniValue getstakingstatus(const UniValue ¶ms, bool fHelp)
std::map< CTxDestination, CAddressBookData > mapAddressBook
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
double GetDifficulty(const CBlockIndex *blockindex=NULL)