16 #include "validation.h"
22 if (!
Params().IsTestChain()) {
26 throw std::runtime_error(
27 "signsession llmqType \"id\" \"msgHash\"\n"
29 "1. llmqType (int, required) LLMQ type.\n"
30 "2. \"id\" (string, required) Request id.\n"
31 "3. \"msgHash\" (string, required) Message hash.\n"
34 "n (bool) True if the sign was successful, false otherwise\n"
51 if (!
Params().IsTestChain()) {
55 throw std::runtime_error(
56 "hasrecoverysignature llmqType \"id\" \"msgHash\"\n"
58 "1. llmqType (int, required) LLMQ type.\n"
59 "2. \"id\" (string, required) Request id.\n"
60 "3. \"msgHash\" (string, required) Message hash.\n"
63 "n (bool) True if you have already received a recovery signature for the given signing session\n"
80 if (!
Params().IsTestChain()) {
84 throw std::runtime_error(
85 "issessionconflicting llmqType \"id\" \"msgHash\"\n"
87 "1. llmqType (int, required) LLMQ type.\n"
88 "2. \"id\" (string, required) Request id.\n"
89 "3. \"msgHash\" (string, required) Message hash.\n"
92 "n (bool) True if you have the recovery signature of an another signing session with same id but different msgHash\n"
110 throw std::runtime_error(
111 "listquorums ( count )\n"
113 "1. count (numeric, optional, default=10) Number of quorums to list\n"
117 " \"llmqType\": [ (array of string) A json array of quorum hashes for a given llmqType\n"
118 " \"quorumhash\", (string) Block hash of the quorum\n"
133 throw std::runtime_error(
134 "count cannot be 0 or negative!\n");
139 for (
auto& p :
Params().GetConsensus().llmqs) {
143 for (
auto& q : quorums) {
144 v.
push_back(q->qc.quorumHash.ToString());
147 ret.
pushKV(p.second.name, v);
157 throw std::runtime_error(
158 "getquoruminfo llmqType \"quorumHash\" ( includeSkShare )\n"
160 "1. llmqType (numeric, required) LLMQ type.\n"
161 "2. \"quorumHash\" (string, required) Block hash of quorum.\n"
162 "3. includeSkShare (boolean, optional) Include secret key share in output.\n"
166 " \"height\": n, (numeric) The starting block height of the quorum\n"
167 " \"quorumHash\": \"quorumHash\", (string) Block hash of the quorum\n"
168 " \"members\": [ (array of json objects)\n"
170 " \"proTxHash\": \"proTxHash\" (string) ProTxHash of the quorum member\n"
171 " \"valid\": true/false (boolean) True/false if the member is valid/invalid\n"
172 " \"pubKeyShare\": pubKeyShare (string) Quorum public key share of the member, will be outputted only if the command is performed by another quorum member or watcher\n"
176 " \"quorumPublicKey\": quorumPublicKey, (string) Public key of the quorum\n"
177 " \"secretKeyShare\": secretKeyShare (string) This is outputted only if includeSkShare=true and the command is performed by a valid member of the quorum. It corresponds to the secret key share of that member\n"
191 bool includeSkShare =
false;
203 ret.
pushKV(
"height", quorum->pindexQuorum->nHeight);
204 ret.
pushKV(
"quorumHash", quorum->qc.quorumHash.ToString());
207 for (
size_t i = 0; i < quorum->members.size(); i++) {
208 auto& dmn = quorum->members[i];
210 mo.
pushKV(
"proTxHash", dmn->proTxHash.ToString());
211 mo.
pushKV(
"valid", quorum->qc.validMembers[i]);
212 if (quorum->qc.validMembers[i]) {
221 ret.
pushKV(
"members", membersArr);
222 ret.
pushKV(
"quorumPublicKey", quorum->qc.quorumPublicKey.ToString());
224 if (includeSkShare && skShare.
IsValid()) {
234 throw std::runtime_error(
235 "getminedcommitment llmq_type quorum_hash\n"
236 "Return information about the commitment for given quorum.\n"
238 "1. llmq_type (number, required) LLMQ type.\n"
239 "2. quorum_hash (hex string, required) LLMQ hash.\n"
270 throw std::runtime_error(
271 "getquorummembers llmq_type quorum_hash\n"
272 "Return the list of proTx hashes for given quorum.\n"
274 "1. llmq_type (number, required) LLMQ type.\n"
275 "2. quorum_hash (hex string, required) LLMQ hash.\n"
289 if (pindexQuorum ==
nullptr) {
295 for (
const auto& dmn : mns) {
296 ret.
push_back(dmn->proTxHash.ToString());
304 throw std::runtime_error(
305 "quorumdkgstatus ( detail_level )\n"
306 "Return the status of the current DKG process of the active masternode.\n"
308 "1. detail_level (number, optional, default=0) Detail level of output.\n"
309 " 0=Only show counts. 1=Show member indexes. 2=Show member's ProTxHashes.\n"
317 if (detailLevel < 0 || detailLevel > 2) {
328 auto ret = status.
ToJson(detailLevel);
333 for (
const auto& p :
Params().GetConsensus().llmqs) {
334 auto& params = p.second;
339 minableCommitments.
pushKV(params.name, obj);
342 ret.pushKV(
"minableCommitments", minableCommitments);
350 throw std::runtime_error(
351 "quorum selectquorum llmqType \"id\"\n"
352 "Returns the quorum that would/should sign a request\n"
354 "1. llmqType (int, required) LLMQ type.\n"
355 "2. \"id\" (string, required) Request id.\n");
371 ret.
pushKV(
"quorumHash", quorum->qc.quorumHash.ToString());
374 for (
int i = 0; i < quorum->params.recoveryMembers; i++) {
376 recoveryMembers.
push_back(dmn->proTxHash.ToString());
378 ret.
pushKV(
"recoveryMembers", recoveryMembers);
386 throw std::runtime_error(
387 "quorumdkgsimerror \"error_type\" rate\n"
388 "This enables simulation of errors and malicious behaviour in the DKG.\n"
389 "Only available on testnet/regtest for LLMQ_TEST llmq type.\n"
391 "1. \"error_type\" (string, required) Error type.\n"
392 "2. rate (number, required) Rate at which to simulate this error type.\n"
399 if (!
Params().IsTestChain()) {
405 if (rate < 0 || rate > 1) {
420 {
"evo",
"getminedcommitment", &
getminedcommitment,
true, {
"llmq_type",
"quorum_hash"} },
421 {
"evo",
"getquorummembers", &
getquorummembers,
true, {
"llmq_type",
"quorum_hash"} },
423 {
"evo",
"quorumdkgsimerror", &
quorumdkgsimerror,
true, {
"error_type",
"rate"} },
424 {
"evo",
"quorumdkgstatus", &
quorumdkgstatus,
true, {
"detail_level"} },
425 {
"evo",
"listquorums", &
listquorums,
true, {
"count"} },
426 {
"evo",
"getquoruminfo", &
getquoruminfo,
true, {
"llmqType",
"quorumHash",
"includeSkShare"} },
429 {
"hidden",
"signsession", &
signsession,
true, {
"llmqType",
"id",
"msgHash"} },
430 {
"hidden",
"hasrecoverysignature", &
hasrecoverysignature,
true, {
"llmqType",
"id",
"msgHash"} },
431 {
"hidden",
"issessionconflicting", &
issessionconflicting,
true, {
"llmqType",
"id",
"msgHash"} },
437 for (
unsigned int vcidx = 0; vcidx <
ARRAYLEN(commands); vcidx++)
CActiveDeterministicMasternodeManager * activeMasternodeManager
const CChainParams & Params()
Return the currently selected parameters.
std::string ToString() const
The block chain is a tree shaped structure starting with the genesis block at the root,...
CBlockIndex * Tip(bool fProofOfStake=false) const
Returns the index entry for the tip of this chain, or nullptr if none.
int Height() const
Return the maximal height in the chain.
const Consensus::Params & GetConsensus() const
PIVX RPC command dispatcher.
bool appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
const std::string & get_str() const
bool push_back(const UniValue &val)
bool pushKV(const std::string &key, const UniValue &val)
std::string ToString() const
UniValue ToJson(int detailLevel) const
void ToJson(UniValue &obj) const
std::unique_ptr< CDeterministicMNManager > deterministicMNManager
std::unique_ptr< CQuorumBlockProcessor > quorumBlockProcessor
std::unique_ptr< CQuorumManager > quorumManager
std::unique_ptr< CDKGDebugManager > quorumDKGDebugManager
bool SetSimulatedDKGErrorRate(const std::string &error_type, double rate)
std::unique_ptr< CSigningManager > quorumSigningManager
std::unique_ptr< CSigSharesManager > quorumSigSharesManager
RecursiveMutex cs_main
Global state.
UniValue JSONRPCError(int code, const std::string &message)
@ RPC_MISC_ERROR
General application defined errors.
@ RPC_INVALID_PARAMETER
Ran out of memory during operation.
UniValue quorumdkgsimerror(const JSONRPCRequest &request)
UniValue getquorummembers(const JSONRPCRequest &request)
UniValue issessionconflicting(const JSONRPCRequest &request)
UniValue getminedcommitment(const JSONRPCRequest &request)
UniValue quorumselectquorum(const JSONRPCRequest &request)
UniValue quorumdkgstatus(const JSONRPCRequest &request)
UniValue getquoruminfo(const JSONRPCRequest &request)
void RegisterQuorumsRPCCommands(CRPCTable &tableRPC)
Register Quorums RPC commands.
UniValue hasrecoverysignature(const JSONRPCRequest &request)
UniValue signsession(const JSONRPCRequest &request)
UniValue listquorums(const JSONRPCRequest &request)
std::string HelpExampleCli(std::string methodname, std::string args)
double ParseDoubleV(const UniValue &v, const std::string &strName)
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded Values (throws error if not hex).
std::string HelpExampleRpc(std::string methodname, std::string args)
std::map< LLMQType, LLMQParams > llmqs
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
std::atomic< bool > fMasterNode
const UniValue NullUniValue
CChain chainActive
The currently-connected chain of blocks (protected by cs_main).
CBlockIndex * LookupBlockIndex(const uint256 &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)