Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
governance.cpp
Go to the documentation of this file.
31 "1. \"mode\" (string, optional, default: \"json\") Output format: json (\"json\") or string in free form (\"all\")\n"
107 throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid proposal data, error messages:" + validator.GetErrorMessages());
110 throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid object type, only proposals can be validated");
141 if (request.fHelp || (request.params.size() != 5 && request.params.size() != 6 && request.params.size() != 8))
182 throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid proposal data, error messages:" + validator.GetErrorMessages());
187 throw JSONRPCError(RPC_INVALID_PARAMETER, "Trigger objects need not be prepared (however only masternodes can create them)");
195 throw JSONRPCError(RPC_INTERNAL_ERROR, "Governance object is not valid - " + govobj.GetHash().ToString() + " - " + strError);
204 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("invalid hash or index: %s-%d", collateralHash.ToString(), collateralIndex));
210 if (!pwallet->GetBudgetSystemCollateralTX(wtx, govobj.GetHash(), govobj.GetMinCollateralFee(), outpoint)) {
211 std::string err = "Error making collateral transaction for governance object. Please check your wallet balance and make sure your wallet is unlocked.";
213 err += "Please verify your specified output is valid and is enough for the combined proposal fee and transaction fee.";
223 throw JSONRPCError(RPC_INTERNAL_ERROR, "CommitTransaction failed! Reason given: " + state.GetRejectReason());
226 LogPrint(BCLog::GOBJECT, "gobject_prepare -- GetDataAsPlainString = %s, hash = %s, txid = %s\n",
253 throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Must wait for client to sync with masternode network. Try again in a minute or so.");
259 LogPrint(BCLog::GOBJECT, "gobject_submit -- pubKeyOperator = %s, outpoint = %s, params.size() = %lld, fMnFound = %d\n",
260 (activeMasternodeInfo.blsPubKeyOperator ? activeMasternodeInfo.blsPubKeyOperator->ToString() : "N/A"),
271 if (request.params[1].get_str() == "0") { // attach to root node (root node doesn't really exist, but has a hash of zero)
293 throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid proposal data, error messages:" + validator.GetErrorMessages());
304 throw JSONRPCError(RPC_INVALID_PARAMETER, "Only valid masternodes can submit this type of object");
308 throw JSONRPCError(RPC_INVALID_PARAMETER, "The fee-txid parameter must be included to submit this type of object");
318 LogPrintf("gobject(submit) -- Object submission rejected because object is not valid - hash = %s, strError = %s\n", strHash, strError);
319 throw JSONRPCError(RPC_INTERNAL_ERROR, "Governance object is not valid - " + strHash + " - " + strError);
326 LogPrintf("gobject(submit) -- Object submission rejected because of rate check failure - hash = %s\n", strHash);
374 throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid vote outcome. Please use one of the following: 'yes', 'no' or 'abstain'");
395 auto dmn = deterministicMNManager->GetListAtChainTip().GetValidMNByCollateral(activeMasternodeInfo.outpoint);
402 returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed)));
422 returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed)));
439 returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed)));
504 returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed)));
515 "Vote on a governance object by all masternodes for which the voting key is present in the local wallet\n"
546 throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid vote outcome. Please use one of the following: 'yes', 'no' or 'abstain'");
600 throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid vote outcome. Please use one of the following: 'yes', 'no' or 'abstain'");
613 throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Private key for voting address %s not known by wallet", EncodeDestination(dmn->pdmnState->keyIDVoting)));
623 UniValue ListObjects(const std::string& strCachedSignal, const std::string& strType, int nStartTime)
684 "1. signal (string, optional, default=valid) cached signal, possible values: [valid|funding|delete|endorsed|all]\n"
685 "2. type (string, optional, default=all) object type, possible values: [proposals|triggers|all]\n"
698 if (strCachedSignal != "valid" && strCachedSignal != "funding" && strCachedSignal != "delete" && strCachedSignal != "endorsed" && strCachedSignal != "all")
717 "1. signal (string, optional, default=valid) cached signal, possible values: [valid|funding|delete|endorsed|all]\n"
718 "2. type (string, optional, default=all) object type, possible values: [proposals|triggers|all]\n"
731 if (strCachedSignal != "valid" && strCachedSignal != "funding" && strCachedSignal != "delete" && strCachedSignal != "endorsed" && strCachedSignal != "all")
789 objFundingResult.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_FUNDING)));
792 objFundingResult.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_FUNDING)));
805 objDelete.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_DELETE)));
813 objEndorsed.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_ENDORSED)));
894 " count - Count governance objects and votes (additional param: 'json' or 'all', default: 'json')\n"
896 " getcurrentvotes - Get only current (tallying) votes for a governance object hash (does not include old votes)\n"
904 " vote-many - Vote on a governance object by all masternodes for which the voting key is in the wallet\n"
933 // AFTER COLLATERAL TRANSACTION HAS MATURED USER CAN SUBMIT GOVERNANCE OBJECT TO PROPAGATE NETWORK
937 gobject submit 6e622bb41bad1fb18e7f23ae96770aeb33129e18bd9efe790522488e580a0a03 0 1 1464292854 "beer-reimbursement" 5b5b22636f6e7472616374222c207b2270726f6a6563745f6e616d65223a20225c22626565722d7265696d62757273656d656e745c22222c20227061796d656e745f61646472657373223a20225c225879324c4b4a4a64655178657948726e34744744514238626a6876464564615576375c22222c2022656e645f64617465223a202231343936333030343030222c20226465736372697074696f6e5f75726c223a20225c227777772e646173687768616c652e6f72672f702f626565722d7265696d62757273656d656e745c22222c2022636f6e74726163745f75726c223a20225c22626565722d7265696d62757273656d656e742e636f6d2f3030312e7064665c22222c20227061796d656e745f616d6f756e74223a20223233342e323334323232222c2022676f7665726e616e63655f6f626a6563745f6964223a2037342c202273746172745f64617465223a202231343833323534303030227d5d5d1
968 "voteraw <mn-collateral-tx-hash> <mn-collateral-tx-index> <governance-hash> <vote-signal> [yes|no|abstain] <time> <vote-sig>\n"
969 "Compile and relay a governance vote with provided external signature instead of signing vote internally\n"
989 throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid vote outcome. Please use one of the following: 'yes', 'no' or 'abstain'");
1014 throw JSONRPCError(RPC_INTERNAL_ERROR, "Failure to find masternode in list : " + outpoint.ToStringShort());
1021 bool onlyVotingKeyAllowed = govObjType == GOVERNANCE_OBJECT_PROPOSAL && vote.GetSignal() == VOTE_SIGNAL_FUNDING;
1043 " \"governanceminquorum\": xxxxx, (numeric) the absolute minimum number of votes needed to trigger a governance action\n"
1044 " \"proposalfee\": xxx.xx, (numeric) the collateral transaction fee which must be paid to create a proposal in " + CURRENCY_UNIT + "\n"
1081 "n (numeric) The absolute maximum sum of superblock payments allowed, in " + CURRENCY_UNIT + "\n"
1103 { "dash", "voteraw", &voteraw, {"tx_hash","tx_index","gov_hash","signal","outcome","time","sig"} },
UniValue ListObjects(const std::string &strCachedSignal, const std::string &strType, int nStartTime)
Definition: governance.cpp:623
CTxMemPool mempool
std::vector< unsigned char > DecodeBase64(const char *p, bool *pfInvalid)
Definition: utilstrencodings.cpp:177
Definition: governance-vote.h:27
bool MasternodeRateCheck(const CGovernanceObject &govobj, bool fUpdateFailStatus=false)
Definition: governance.cpp:733
int GetAbstainCount(vote_signal_enum_t eVoteSignalIn) const
Definition: governance-object.cpp:633
int32_t ParseInt32V(const UniValue &v, const std::string &strName)
Definition: server.cpp:152
Definition: governance-vote.h:28
bool EnsureWalletIsAvailable(CWallet *const pwallet, bool avoidException)
Definition: rpcwallet.cpp:66
Definition: protocol.h:44
Definition: governance-vote.h:54
static void GetNearestSuperblocksHeights(int nBlockHeight, int &nLastSuperblockRet, int &nNextSuperblockRet)
Definition: governance-classes.cpp:444
const COutPoint & GetMasternodeOutpoint() const
Definition: governance-object.h:209
static const CAmount GOVERNANCE_PROPOSAL_FEE_TX
Definition: governance-object.h:36
Definition: governance-validators.h:12
Definition: univalue.h:20
void SetMasternodeOutpoint(const COutPoint &outpoint)
Definition: governance-object.cpp:301
const uint256 & GetCollateralHash() const
Definition: governance-object.h:204
static const int GOVERNANCE_OBJECT_PROPOSAL
Definition: governance-object.h:33
bool ProcessVoteAndRelay(const CGovernanceVote &vote, CGovernanceException &exception, CConnman &connman)
Definition: governance.h:381
UniValue getsuperblockbudget(const JSONRPCRequest &request)
Definition: governance.cpp:1072
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
Definition: server.cpp:583
bool IsSetCachedFunding() const
Definition: governance-object.h:214
std::shared_ptr< const CDeterministicMN > CDeterministicMNCPtr
Definition: deterministicmns.h:249
static vote_signal_enum_t ConvertVoteSignal(const std::string &strVoteSignal)
Definition: governance-vote.cpp:64
std::unique_ptr< CDeterministicMNManager > deterministicMNManager
Definition: deterministicmns.cpp:24
bool appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
Definition: server.cpp:353
bool IsSetCachedEndorsed() const
Definition: governance-object.h:229
void AddPostponedObject(const CGovernanceObject &govobj)
Definition: governance.h:369
std::string HelpRequiringPassphrase(CWallet *const pwallet)
Definition: rpcwallet.cpp:59
CGovernanceObject * FindGovernanceObject(const uint256 &nHash)
Definition: governance.cpp:463
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded Values (throws error if not hex).
Definition: server.cpp:121
const std::string & GetErrorMessages()
Definition: governance-validators.h:25
Definition: univalue.h:22
int GetNoCount(vote_signal_enum_t eVoteSignalIn) const
Definition: governance-object.cpp:628
void AddGovernanceObject(CGovernanceObject &govobj, CConnman &connman, CNode *pfrom=nullptr)
Definition: governance.cpp:291
UniValue gobject_deserialize(const JSONRPCRequest &request)
Definition: governance.cpp:62
bool GetKey(const CKeyID &address, CKey &keyOut) const override
GetKey implementation that can derive a HD private key on the fly.
Definition: wallet.cpp:300
bool Validate(bool fCheckExpiration=true)
Definition: governance-validators.cpp:38
Definition: util.h:134
UniValue gobject_vote_conf(const JSONRPCRequest &request)
Definition: governance.cpp:354
bool IsSetCachedDelete() const
Definition: governance-object.h:224
static const int GOVERNANCE_OBJECT_TRIGGER
Definition: governance-object.h:34
A class which encapsulates information about a governance exception condition.
Definition: governance-exceptions.h:55
std::vector< const CGovernanceObject * > GetAllNewerThan(int64_t nMoreThanTime) const
Definition: governance.cpp:516
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
Definition: server.cpp:578
static std::pair< std::string, UniValue > Pair(const char *cKey, const char *cVal)
Definition: univalue.h:185
UniValue gobject_getcurrentvotes(const JSONRPCRequest &request)
Definition: governance.cpp:842
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:26
void RegisterGovernanceRPCCommands(CRPCTable &t)
Register governance RPC commands.
Definition: governance.cpp:1107
std::vector< CGovernanceVote > GetCurrentVotes(const uint256 &nParentHash, const COutPoint &mnCollateralOutpointFilter) const
Definition: governance.cpp:472
int64_t GetCreationTime() const
Definition: governance-object.h:189
A transaction with a bunch of additional info that only the owner cares about.
Definition: wallet.h:280
Definition: governance-vote.h:29
bool IsValidLocally(std::string &strError, bool fCheckCollateral) const
Definition: governance-object.cpp:430
void SetSignature(const std::vector< unsigned char > &vchSigIn)
Definition: governance-vote.h:96
std::string GetDataAsPlainString() const
Definition: governance-object.cpp:417
static CAmount GetPaymentsLimit(int nBlockHeight)
Definition: governance-classes.cpp:463
std::string EncodeDestination(const CTxDestination &dest)
Definition: base58.cpp:329
Definition: governance-vote.h:26
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:947
int GetAbsoluteYesCount(vote_signal_enum_t eVoteSignalIn) const
Get specific vote counts for each outcome (funding, validity, etc)
Definition: governance-object.cpp:613
int GetYesCount(vote_signal_enum_t eVoteSignalIn) const
Definition: governance-object.cpp:623
Definition: server.h:37
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Definition: wallet.h:715
const std::string & GetMessage() const
Definition: governance-exceptions.h:84
CWallet * GetWalletForJSONRPCRequest(const JSONRPCRequest &request)
Figures out what wallet, if any, to use for a JSONRPCRequest.
Definition: rpcwallet.cpp:45
UniValue getgovernanceinfo(const JSONRPCRequest &request)
Definition: governance.cpp:1035
std::unique_ptr< CBLSPublicKey > blsPubKeyOperator
Definition: activemasternode.h:25
bool Sign(const CKey &key, const CKeyID &keyID)
Definition: governance-vote.cpp:163
UniValue VoteWithMasternodes(const std::map< uint256, CKey > &keys, const uint256 &hash, vote_signal_enum_t eVoteSignal, vote_outcome_enum_t eVoteOutcome)
Definition: governance.cpp:445
CChain & chainActive
The currently-connected chain of blocks (protected by cs_main).
Definition: validation.cpp:217
std::unique_ptr< CBLSSecretKey > blsKeyOperator
Definition: activemasternode.h:26
Definition: governance-vote.h:17
static vote_outcome_enum_t ConvertVoteOutcome(const std::string &strVoteOutcome)
Definition: governance-vote.cpp:47
void UpdateLastDiffTime(int64_t nTimeIn)
Definition: governance.h:354
Definition: governance-vote.h:30
bool GetBudgetSystemCollateralTX(CWalletTx &tx, uint256 hash, CAmount amount, const COutPoint &outpoint=COutPoint())
Definition: wallet.cpp:3631
void EnsureWalletIsUnlocked(CWallet *const pwallet)
Definition: rpcwallet.cpp:83
bool CommitTransaction(CWalletTx &wtxNew, CReserveKey &reservekey, CConnman *connman, CValidationState &state)
Call after CreateTransaction unless you want to abort.
Definition: wallet.cpp:4089
Definition: server.h:128