// Copyright (c) 2014-2016 The Dash Core developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "main.h" #include "db.h" #include "init.h" #include "activemasternode.h" #include "governance.h" #include "masternode-payments.h" #include "masternode-sync.h" #include "masternodeconfig.h" #include "masternodeman.h" #include "rpcserver.h" #include "utilmoneystr.h" #include #include #include #include #include using namespace std; int ConvertVoteOutcome(std::string strVoteAction) { int nVote = -1; if(strVoteAction == "yes") nVote = VOTE_OUTCOME_YES; if(strVoteAction == "no") nVote = VOTE_OUTCOME_NO; if(strVoteAction == "abstain") nVote = VOTE_OUTCOME_ABSTAIN; if(strVoteAction == "none") nVote = VOTE_OUTCOME_NONE; return nVote; } int ConvertVoteAction(std::string strVoteOutcome) { if(strVoteOutcome == "none") return 0; if(strVoteOutcome == "funding") return 1; if(strVoteOutcome == "valid") return 2; if(strVoteOutcome == "delete") return 3; if(strVoteOutcome == "clear_registers") return 4; if(strVoteOutcome == "endorsed") return 5; if(strVoteOutcome == "release_bounty1") return 6; if(strVoteOutcome == "release_bounty2") return 7; if(strVoteOutcome == "release_bounty3") return 8; // convert custom sentinel outcomes to integer and store try { int i = boost::lexical_cast(strVoteOutcome); if(i < VOTE_ACTION_CUSTOM_START || i > VOTE_ACTION_CUSTOM_END) return -1; return i; } catch(std::exception const & e) { cout<<"error : " << e.what() <> fee transaction hash * * governance submit fee-hash nTypeIn nParentID, "name", epoch-start, epoch-end, fee-hash, register1, register2, register3 * >> governance object hash * * governance vote(-alias|many) type hash yes|no|abstain * >> success|failure * * governance list * >> flat data representation of the governance system * >> NOTE: this shouldn't be altered, we'll analyze the system outside of this project * * governance get hash * >> show one proposal * */ UniValue mngovernance(const UniValue& params, bool fHelp) { string strCommand; if (params.size() >= 1) strCommand = params[0].get_str(); if (fHelp || (strCommand != "vote-many" && strCommand != "vote-alias" && strCommand != "prepare" && strCommand != "submit" && strCommand != "vote" && strCommand != "get" && strCommand != "list" && strCommand != "diff")) throw runtime_error( "mngovernance \"command\"...\n" "Manage proposals\n" "\nAvailable commands:\n" " prepare - Prepare proposal by signing and creating tx\n" " submit - Submit proposal to network\n" " get - Get proposal hash(es) by proposal name\n" " list - List all proposals\n" " diff - List differences since last diff\n" " vote-alias - Vote on a governance object by masternode alias\n" ); if(strCommand == "prepare") { if (params.size() != 6) throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'mngovernance prepare