Converting governance system

- Generic usage of governance objects
- Added different voting types of signaling
- Removed budget commands (projection, mesc -- see sentinel https://github.com/evan82/sentinel/blob/master/docs/example4.md)
- Added various voting signaling mechanisms (origin funding, remove, valid, endorsed, milestones, outerstorage)
This commit is contained in:
Evan Duffield 2016-04-19 09:51:15 -07:00
parent 94f448d6fa
commit fe5c4dd811
19 changed files with 194 additions and 179 deletions

View File

@ -23,9 +23,9 @@ In this transaction we prepare collateral for "_cool-project_". This proposal wi
**Warning: if you change any fields within this command, the collateral transaction will become invalid.** **Warning: if you change any fields within this command, the collateral transaction will become invalid.**
Format: ```mnbudget prepare proposal-name url payment-count block-start dash-address monthly-payment-dash``` Format: ```mngovernance prepare proposal-name url payment-count block-start dash-address monthly-payment-dash```
Example: ```mnbudget prepare cool-project http://www.cool-project/one.json 12 100000 y6R9oN12KnB9zydzTLc3LikD9cCjjQzYG7 1200 true``` Example: ```mngovernance prepare cool-project http://www.cool-project/one.json 12 100000 y6R9oN12KnB9zydzTLc3LikD9cCjjQzYG7 1200 true```
Output: ```464a0eb70ea91c94295214df48c47baa72b3876cfb658744aaf863c7b5bf1ff0``` Output: ```464a0eb70ea91c94295214df48c47baa72b3876cfb658744aaf863c7b5bf1ff0```
@ -36,9 +36,9 @@ This is the collateral hash, copy this output for the next step.
Now we can submit our proposal to the network. Now we can submit our proposal to the network.
Format: ```mnbudget submit proposal-name url payment-count block-start dash-address monthly-payment-dash fee-tx``` Format: ```mngovernance submit proposal-name url payment-count block-start dash-address monthly-payment-dash fee-tx```
Example: ```mnbudget submit cool-project http://www.cool-project/one.json 12 100000 y6R9oN12KnB9zydzTLc3LikD9cCjjQzYG7 1200 464a0eb70ea91c94295214df48c47baa72b3876cfb658744aaf863c7b5bf1ff0``` Example: ```mngovernance submit cool-project http://www.cool-project/one.json 12 100000 y6R9oN12KnB9zydzTLc3LikD9cCjjQzYG7 1200 464a0eb70ea91c94295214df48c47baa72b3876cfb658744aaf863c7b5bf1ff0```
Output : ```a2b29778ae82e45a973a94309ffa6aa2e2388b8f95b39ab3739f0078835f0491``` Output : ```a2b29778ae82e45a973a94309ffa6aa2e2388b8f95b39ab3739f0078835f0491```
@ -49,9 +49,9 @@ This is your proposal hash, which other nodes will use to vote on it.
Double check your information. Double check your information.
Format: ```mnbudget getproposal proposal-hash``` Format: ```mngovernance getproposal proposal-hash```
Example: ```mnbudget getproposal a2b29778ae82e45a973a94309ffa6aa2e2388b8f95b39ab3739f0078835f0491``` Example: ```mngovernance getproposal a2b29778ae82e45a973a94309ffa6aa2e2388b8f95b39ab3739f0078835f0491```
``` ```
{ {
@ -77,16 +77,16 @@ Example: ```mnbudget getproposal a2b29778ae82e45a973a94309ffa6aa2e2388b8f95b39ab
If everything looks correct, you can ask for votes from other masternodes. To vote on a proposal, load a wallet with _masternode.conf_ file. You do not need to access your cold wallet to vote for proposals. If everything looks correct, you can ask for votes from other masternodes. To vote on a proposal, load a wallet with _masternode.conf_ file. You do not need to access your cold wallet to vote for proposals.
Format: ```mnbudget vote proposal-hash [yes|no]``` Format: ```mngovernance vote proposal-hash [yes|no]```
Example: ```mnbudget vote a2b29778ae82e45a973a94309ffa6aa2e2388b8f95b39ab3739f0078835f0491 yes``` Example: ```mngovernance vote a2b29778ae82e45a973a94309ffa6aa2e2388b8f95b39ab3739f0078835f0491 yes```
4. Make it into the budget 4. Make it into the budget
-- --
After you get enough votes, execute ```mnbudget projection``` to see if you made it into the budget. If you the budget was finalized at this moment which proposals would be in it. Note: Proposals must be active at least 1 day on the network and receive 10% of the masternode network in yes votes in order to qualify (E.g. if there is 3500 masternodes, you will need 350 yes votes.) After you get enough votes, execute ```mngovernance projection``` to see if you made it into the budget. If you the budget was finalized at this moment which proposals would be in it. Note: Proposals must be active at least 1 day on the network and receive 10% of the masternode network in yes votes in order to qualify (E.g. if there is 3500 masternodes, you will need 350 yes votes.)
```mnbudget projection```: ```mngovernance projection```:
``` ```
{ {
"cool-project" : { "cool-project" : {
@ -135,7 +135,7 @@ When block ```1000000``` is reached you'll receive a payment for ```1200``` DASH
The following RPC commands are supported: The following RPC commands are supported:
- mnbudget "command"... ( "passphrase" ) - mngovernance "command"... ( "passphrase" )
- check - Scan proposals and remove invalid from proposals list - check - Scan proposals and remove invalid from proposals list
- prepare - Prepare proposal by signing and creating tx - prepare - Prepare proposal by signing and creating tx
- submit - Submit proposal to network - submit - Submit proposal to network

View File

@ -64,18 +64,6 @@
* CValueOverride lvl, vo-type, status, status-error * CValueOverride lvl, vo-type, status, status-error
*/ */
class CDashNetwork;
class CDashNetworkVariable;
class CCategory;
class CGroup;
class CUser;
class CCompany;
class CProject;
class CProjectReport;
class CProjectMilestone;
class CProposal;
class CContract;
class CValueOverride;
/* /*
@ -87,20 +75,6 @@ class CValueOverride;
* -- Most of the values in these classes can be overriden * -- Most of the values in these classes can be overriden
* *
* CGovernanceNode (base) * CGovernanceNode (base)
* -> CGovernanceObject (unimplementable)
* -> CDashNetwork
* -> CDashNetworkVariable
* -> CValueOverride
* -> CCategory
* -> CGovernanceActor
* -> CGroup
* -> CUser
* -> CCompany
* -> DAO/DO/LLC/501c6/etc
* -> CProject
* -> CProjectReport
* -> CProjectMilestone
*
* *
* TREE STRUCTURE * TREE STRUCTURE
* =========================================== * ===========================================

54
src/governance-misc.h Normal file
View File

@ -0,0 +1,54 @@
// 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.
#ifndef GOVERANCE_MISC_H
#define GOVERANCE_MISC_H
#include "main.h"
#include "governance.h"
#include "init.h"
using namespace std;
class CBudgetVote;
/**
* Triggers and Settings - 12.2
* -----------------------------------
*
* This allows the network fine grained control of the p2p side, including but not limited to:
* - Which blocks are valid
* - What it costs to do various things on the network
*
*/
// class CGovernanceTrigger
// {
// static &T IsBlockBanned(int n)
// {
// }
// };
// /*
// */
// class CGovernanceSettings
// {
// template<typename T>
// // strName=trigger, strParamater=ban-block ... obj= tigger.ban-block(args)
// static &T GetSetting(std::string strName, &T networkDefault)
// {
// /*
// - get setting from masternode network
// */
// return networkDefault;
// }
// };
#endif

View File

@ -1,16 +0,0 @@
// Copyright (c) 2014-2016 The Dash Core developers
/*
*/
class CGovernanceSettings
{
template<typename T>
// strName=trigger, strParamater=ban-block ... obj= tigger.ban-block(args)
static &T GetSetting(std::string strName)
{
}
}

View File

@ -69,7 +69,7 @@ bool CBudgetVote::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode)
bool CBudgetVote::IsValid(bool fSignatureCheck) bool CBudgetVote::IsValid(bool fSignatureCheck)
{ {
if(nTime > GetTime() + (60*60)){ if(nTime > GetTime() + (60*60)){
LogPrint("mnbudget", "CBudgetVote::IsValid() - vote is too far ahead of current time - %s - nTime %lli - Max Time %lli\n", GetHash().ToString(), nTime, GetTime() + (60*60)); LogPrint("mngovernance", "CBudgetVote::IsValid() - vote is too far ahead of current time - %s - nTime %lli - Max Time %lli\n", GetHash().ToString(), nTime, GetTime() + (60*60));
return false; return false;
} }
@ -77,7 +77,7 @@ bool CBudgetVote::IsValid(bool fSignatureCheck)
if(pmn == NULL) if(pmn == NULL)
{ {
LogPrint("mnbudget", "CBudgetVote::IsValid() - Unknown Masternode - %s\n", vin.ToString()); LogPrint("mngovernance", "CBudgetVote::IsValid() - Unknown Masternode - %s\n", vin.ToString());
return false; return false;
} }

View File

@ -166,7 +166,7 @@ CGovernanceObject *CGovernanceManager::FindProposal(uint256 nHash)
return NULL; return NULL;
} }
std::vector<CGovernanceObject*> CGovernanceManager::GetAllProposals() std::vector<CGovernanceObject*> CGovernanceManager::GetAllProposals(int64_t nTimeIn)
{ {
LOCK(cs); LOCK(cs);
@ -175,6 +175,10 @@ std::vector<CGovernanceObject*> CGovernanceManager::GetAllProposals()
std::map<uint256, CGovernanceObject>::iterator it = mapProposals.begin(); std::map<uint256, CGovernanceObject>::iterator it = mapProposals.begin();
while(it != mapProposals.end()) while(it != mapProposals.end())
{ {
if((*it).second.nTime < nTimeIn) {
++it;
continue;
}
(*it).second.CleanAndRemove(false); (*it).second.CleanAndRemove(false);
CGovernanceObject* pbudgetProposal = &((*it).second); CGovernanceObject* pbudgetProposal = &((*it).second);
@ -291,18 +295,18 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
LOCK(cs_budget); LOCK(cs_budget);
// todo - 12.1 - change to MNGOVERNANCEVOTESYNC // todo - 12.1 - change to MNGOVERNANCEVOTESYNC
if (strCommand == NetMsgType::MNBUDGETVOTESYNC) { //Masternode vote sync if (strCommand == NetMsgType::mngovernanceVOTESYNC) { //Masternode vote sync
uint256 nProp; uint256 nProp;
vRecv >> nProp; vRecv >> nProp;
if(Params().NetworkIDString() == CBaseChainParams::MAIN){ if(Params().NetworkIDString() == CBaseChainParams::MAIN){
if(nProp == uint256()) { if(nProp == uint256()) {
if(pfrom->HasFulfilledRequest(NetMsgType::MNBUDGETVOTESYNC)) { if(pfrom->HasFulfilledRequest(NetMsgType::mngovernanceVOTESYNC)) {
LogPrintf("mnvs - peer already asked me for the list\n"); LogPrintf("mnvs - peer already asked me for the list\n");
Misbehaving(pfrom->GetId(), 20); Misbehaving(pfrom->GetId(), 20);
return; return;
} }
pfrom->FulfilledRequest(NetMsgType::MNBUDGETVOTESYNC); pfrom->FulfilledRequest(NetMsgType::mngovernanceVOTESYNC);
} }
} }
@ -312,7 +316,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
} }
// todo - 12.1 - change to MNGOVERNANCEPROPOSAL // todo - 12.1 - change to MNGOVERNANCEPROPOSAL
if (strCommand == NetMsgType::MNBUDGETPROPOSAL) { //Masternode Proposal if (strCommand == NetMsgType::mngovernancePROPOSAL) { //Masternode Proposal
CGovernanceObject budgetProposalBroadcast; CGovernanceObject budgetProposalBroadcast;
vRecv >> budgetProposalBroadcast; vRecv >> budgetProposalBroadcast;
@ -347,7 +351,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
} }
// todo - 12.1 - change to MNGOVERNANCEVOTE // todo - 12.1 - change to MNGOVERNANCEVOTE
if (strCommand == NetMsgType::MNBUDGETVOTE) { //Masternode Vote if (strCommand == NetMsgType::mngovernanceVOTE) { //Masternode Vote
CBudgetVote vote; CBudgetVote vote;
vRecv >> vote; vRecv >> vote;
vote.fValid = true; vote.fValid = true;
@ -359,7 +363,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
CMasternode* pmn = mnodeman.Find(vote.vinMasternode); CMasternode* pmn = mnodeman.Find(vote.vinMasternode);
if(pmn == NULL) { if(pmn == NULL) {
LogPrint("mnbudget", "mvote - unknown masternode - vin: %s\n", vote.vinMasternode.ToString()); LogPrint("mngovernance", "mvote - unknown masternode - vin: %s\n", vote.vinMasternode.ToString());
mnodeman.AskForMN(pfrom, vote.vinMasternode); mnodeman.AskForMN(pfrom, vote.vinMasternode);
return; return;
} }
@ -490,7 +494,7 @@ bool CGovernanceManager::UpdateProposal(CBudgetVote& vote, CNode* pfrom, std::st
mapOrphanMasternodeBudgetVotes[vote.nParentHash] = vote; mapOrphanMasternodeBudgetVotes[vote.nParentHash] = vote;
if(!askedForSourceProposalOrBudget.count(vote.nParentHash)){ if(!askedForSourceProposalOrBudget.count(vote.nParentHash)){
pfrom->PushMessage(NetMsgType::MNBUDGETVOTESYNC, vote.nParentHash); pfrom->PushMessage(NetMsgType::mngovernanceVOTESYNC, vote.nParentHash);
askedForSourceProposalOrBudget[vote.nParentHash] = GetTime(); askedForSourceProposalOrBudget[vote.nParentHash] = GetTime();
} }
} }
@ -513,12 +517,12 @@ bool CGovernanceManager::AddOrUpdateVote(CBudgetVote& vote, std::string& strErro
if(mapVotes[hash2].count(hash)){ if(mapVotes[hash2].count(hash)){
if(mapVotes[hash2][hash].nTime > vote.nTime){ if(mapVotes[hash2][hash].nTime > vote.nTime){
strError = strprintf("new vote older than existing vote - %s", vote.GetHash().ToString()); strError = strprintf("new vote older than existing vote - %s", vote.GetHash().ToString());
LogPrint("mnbudget", "CGovernanceObject::AddOrUpdateVote - %s\n", strError); LogPrint("mngovernance", "CGovernanceObject::AddOrUpdateVote - %s\n", strError);
return false; return false;
} }
if(vote.nTime - mapVotes[hash2][hash].nTime < BUDGET_VOTE_UPDATE_MIN){ if(vote.nTime - mapVotes[hash2][hash].nTime < BUDGET_VOTE_UPDATE_MIN){
strError = strprintf("time between votes is too soon - %s - %lli", vote.GetHash().ToString(), vote.nTime - mapVotes[hash2][hash].nTime); strError = strprintf("time between votes is too soon - %s - %lli", vote.GetHash().ToString(), vote.nTime - mapVotes[hash2][hash].nTime);
LogPrint("mnbudget", "CGovernanceObject::AddOrUpdateVote - %s\n", strError); LogPrint("mngovernance", "CGovernanceObject::AddOrUpdateVote - %s\n", strError);
return false; return false;
} }
} }
@ -532,29 +536,17 @@ CGovernanceObject::CGovernanceObject()
strName = "unknown"; strName = "unknown";
nStartTime = 0; nStartTime = 0;
nEndTime = 0; nEndTime = 0;
nAmount = 0;
nTime = 0; nTime = 0;
fValid = true; fValid = true;
} }
CGovernanceObject::CGovernanceObject(const CGovernanceObject& other) CGovernanceObject::CGovernanceObject(uint256 nHashParentIn, int nPriorityIn, int nRevisionIn, int nTypeVersionIn, std::string strNameIn, int64_t nStartTimeIn, int64_t nEndTimeIn, uint256 nFeeTXHashIn)
{
strName = other.strName;
strURL = other.strURL;
nStartTime = other.nStartTime;
nEndTime = other.nEndTime;
address = other.address;
nAmount = other.nAmount;
nTime = other.nTime;
nFeeTXHash = other.nFeeTXHash;
fValid = true;
}
CGovernanceObject::CGovernanceObject(std::string strNameIn, std::string strURLIn, int64_t nStartTimeIn,
int64_t nEndTimeIn, uint256 nFeeTXHashIn)
{ {
nHashParent = nHashParentIn
nPriority = nPriorityIn;
nRevision = nRevisionIn;
nTypeVersion = nTypeVersionIn;
strName = strNameIn; strName = strNameIn;
strURL = strURLIn;
nStartTime = nStartTimeIn; nStartTime = nStartTimeIn;
nEndTime = nEndTimeIn; nEndTime = nEndTimeIn;
nFeeTXHash = nFeeTXHashIn; nFeeTXHash = nFeeTXHashIn;
@ -592,16 +584,6 @@ bool CGovernanceObject::IsValid(const CBlockIndex* pindex, std::string& strError
return false; return false;
} }
if(strURL.size() > 100) {
strError = "Invalid proposal url, limit of 64 characters.";
return false;
}
if(strURL != SanitizeString(strURL)) {
strError = "Invalid proposal url, unsafe characters found.";
return false;
}
if(address == CScript()) { if(address == CScript()) {
strError = "Invalid proposal Payment Address"; strError = "Invalid proposal Payment Address";
return false; return false;
@ -741,7 +723,7 @@ std::string CGovernanceManager::ToString() const
void CGovernanceManager::UpdatedBlockTip(const CBlockIndex *pindex) void CGovernanceManager::UpdatedBlockTip(const CBlockIndex *pindex)
{ {
pCurrentBlockIndex = pindex; pCurrentBlockIndex = pindex;
LogPrint("mnbudget", "pCurrentBlockIndex->nHeight: %d\n", pCurrentBlockIndex->nHeight); LogPrint("mngovernance", "pCurrentBlockIndex->nHeight: %d\n", pCurrentBlockIndex->nHeight);
if(!fLiteMode && masternodeSync.RequestedMasternodeAssets > MASTERNODE_SYNC_LIST) if(!fLiteMode && masternodeSync.RequestedMasternodeAssets > MASTERNODE_SYNC_LIST)
NewBlock(); NewBlock();

View File

@ -60,6 +60,8 @@ private:
// Keep track of current block index // Keep track of current block index
const CBlockIndex *pCurrentBlockIndex; const CBlockIndex *pCurrentBlockIndex;
int64_t nTimeLastDiff;
public: public:
// critical section to protect the inner data structures // critical section to protect the inner data structures
mutable CCriticalSection cs; mutable CCriticalSection cs;
@ -139,6 +141,8 @@ public:
} }
void UpdatedBlockTip(const CBlockIndex *pindex); void UpdatedBlockTip(const CBlockIndex *pindex);
int64_t GetLastDiffTime() {return nTimeLastDiff;}
void UpdateLastDiffTime(int64_t nTimeIn) {nTimeLastDiff=nTimeIn;}
}; };
/** /**
@ -166,7 +170,7 @@ public:
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
//for syncing with other clients //for syncing with other clients
READWRITE(nType); READWRITE(nType);
READWRITE(LIMITED_STRING(strReg, 64)); READWRITE(LIMITED_STRING(strReg, 255));
} }
}; };
@ -184,25 +188,29 @@ private:
CAmount nAlloted; CAmount nAlloted;
public: public:
bool fValid;
uint256 nHashParent; //parent object, 0 is root
int nPriority; //budget is sorted by this integer before funding votecount
int nRevision; //object revision in the system
int64_t nTime; //time this object was created
std::string strName; //org name, username, prop name, etc. std::string strName; //org name, username, prop name, etc.
int nStartTime; int nStartTime;
int nEndTime; int nEndTime;
CAmount nAmount; // 12.1 - remove CScript ownerAddress; //todo rename to addressOwner;
int nPriority; //budget is sorted by this integer before funding votecount
CScript address; //todo rename to addressOwner;
int64_t nTime;
uint256 nFeeTXHash; uint256 nFeeTXHash;
uint256 nHashParent; // 12.1 - remove
// caching
bool fValid;
uint256 nHash;
// Registers, these can be used for anything // Registers, these can be used for anything
// -- check governance wiki for correct usage // -- check governance wiki for correct usage
std::map<int, CGovernanceObjectRegister> mapRegister; std::map<int, CGovernanceObjectRegister> mapRegister;
CGovernanceObject(); CGovernanceObject();
CGovernanceObject(const CGovernanceObject& other); CGovernanceObject(uint256 nHashParentIn, int nPriorityIn, int nRevisionIn, int nTypeVersionIn, std::string strNameIn, int64_t nStartTimeIn, int64_t nEndTimeIn, uint256 nFeeTXHashIn);
CGovernanceObject(std::string strNameIn, int64_t nStartTimeIn, int64_t nEndTimeIn, uint256 nFeeTXHashIn);
bool HasMinimumRequiredSupport(); bool HasMinimumRequiredSupport();
bool IsValid(const CBlockIndex* pindex, std::string& strError, bool fCheckCollateral=true); bool IsValid(const CBlockIndex* pindex, std::string& strError, bool fCheckCollateral=true);
@ -210,7 +218,6 @@ public:
bool NetworkWillPay(); bool NetworkWillPay();
std::string GetName() {return strName; } std::string GetName() {return strName; }
std::string GetURL() {return strURL; }
int GetStartTime() {return nStartTime;} int GetStartTime() {return nStartTime;}
int GetEndTime() {return nEndTime;} int GetEndTime() {return nEndTime;}
int IsActive(int64_t nTime) {return nTime > nStartTime && nTime < nEndTime;} int IsActive(int64_t nTime) {return nTime > nStartTime && nTime < nEndTime;}
@ -276,6 +283,19 @@ public:
template <typename Stream, typename Operation> template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
{ {
/*
uint256 nHashParent; //parent object, 0 is root
int nPriority; //budget is sorted by this integer before funding votecount
int nRevision; //object revision in the system
int64_t nTime; //time this object was created
std::string strName; //org name, username, prop name, etc.
int nStartTime;
int nEndTime;
CScript ownerAddress; //todo rename to addressOwner;
uint256 nFeeTXHash;
*/
READWRITE(LIMITED_STRING(strName, 20)); READWRITE(LIMITED_STRING(strName, 20));
READWRITE(nTime); READWRITE(nTime);
READWRITE(nStartTime); READWRITE(nStartTime);

View File

@ -511,7 +511,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-limitdescendantsize=<n>", strprintf("Do not accept transactions if any ancestor would have more than <n> kilobytes of in-mempool descendants (default: %u).", DEFAULT_DESCENDANT_SIZE_LIMIT)); strUsage += HelpMessageOpt("-limitdescendantsize=<n>", strprintf("Do not accept transactions if any ancestor would have more than <n> kilobytes of in-mempool descendants (default: %u).", DEFAULT_DESCENDANT_SIZE_LIMIT));
} }
string debugCategories = "addrman, alert, bench, coindb, db, lock, rand, rpc, selectcoins, mempool, mempoolrej, net, proxy, prune, http, libevent, tor, zmq, " string debugCategories = "addrman, alert, bench, coindb, db, lock, rand, rpc, selectcoins, mempool, mempoolrej, net, proxy, prune, http, libevent, tor, zmq, "
"dash (or specifically: darksend, instantx, masternode, keepass, mnpayments, mnbudget)"; // Don't translate these and qt below "dash (or specifically: darksend, instantx, masternode, keepass, mnpayments, mngovernance)"; // Don't translate these and qt below
if (mode == HMM_BITCOIN_QT) if (mode == HMM_BITCOIN_QT)
debugCategories += ", qt"; debugCategories += ", qt";
strUsage += HelpMessageOpt("-debug=<category>", strprintf(_("Output debugging information (default: %u, supplying <category> is optional)"), 0) + ". " + strUsage += HelpMessageOpt("-debug=<category>", strprintf(_("Output debugging information (default: %u, supplying <category> is optional)"), 0) + ". " +

View File

@ -4580,7 +4580,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss.reserve(1000); ss.reserve(1000);
ss << governance.mapSeenMasternodeBudgetVotes[inv.hash]; ss << governance.mapSeenMasternodeBudgetVotes[inv.hash];
pfrom->PushMessage(NetMsgType::MNBUDGETVOTE, ss); pfrom->PushMessage(NetMsgType::mngovernanceVOTE, ss);
pushed = true; pushed = true;
} }
} }
@ -4590,7 +4590,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss.reserve(1000); ss.reserve(1000);
ss << governance.mapSeenMasternodeBudgetProposals[inv.hash]; ss << governance.mapSeenMasternodeBudgetProposals[inv.hash];
pfrom->PushMessage(NetMsgType::MNBUDGETPROPOSAL, ss); pfrom->PushMessage(NetMsgType::mngovernancePROPOSAL, ss);
pushed = true; pushed = true;
} }
} }

View File

@ -146,18 +146,18 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
// todo : 12.1 - split out into two messages // todo : 12.1 - split out into two messages
// --- one for finalized budgets and one for gov objs // --- one for finalized budgets and one for gov objs
if (strCommand == NetMsgType::MNBUDGETVOTESYNC) { //Masternode vote sync if (strCommand == NetMsgType::mngovernanceVOTESYNC) { //Masternode vote sync
uint256 nProp; uint256 nProp;
vRecv >> nProp; vRecv >> nProp;
if(Params().NetworkIDString() == CBaseChainParams::MAIN){ if(Params().NetworkIDString() == CBaseChainParams::MAIN){
if(nProp == uint256()) { if(nProp == uint256()) {
if(pfrom->HasFulfilledRequest(NetMsgType::MNBUDGETVOTESYNC)) { if(pfrom->HasFulfilledRequest(NetMsgType::mngovernanceVOTESYNC)) {
LogPrintf("mnvs - peer already asked me for the list\n"); LogPrintf("mnvs - peer already asked me for the list\n");
Misbehaving(pfrom->GetId(), 20); Misbehaving(pfrom->GetId(), 20);
return; return;
} }
pfrom->FulfilledRequest(NetMsgType::MNBUDGETVOTESYNC); pfrom->FulfilledRequest(NetMsgType::mngovernanceVOTESYNC);
} }
} }
@ -165,7 +165,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
LogPrintf("mnvs - Sent Masternode votes to %s\n", pfrom->addr.ToString()); LogPrintf("mnvs - Sent Masternode votes to %s\n", pfrom->addr.ToString());
} }
if (strCommand == NetMsgType::MNBUDGETFINAL) { //Finalized Budget Suggestion if (strCommand == NetMsgType::mngovernanceFINAL) { //Finalized Budget Suggestion
CFinalizedBudget finalizedBudgetBroadcast; CFinalizedBudget finalizedBudgetBroadcast;
vRecv >> finalizedBudgetBroadcast; vRecv >> finalizedBudgetBroadcast;
@ -200,7 +200,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
CheckOrphanVotes(); CheckOrphanVotes();
} }
if (strCommand == NetMsgType::MNBUDGETFINALVOTE) { //Finalized Budget Vote if (strCommand == NetMsgType::mngovernanceFINALVOTE) { //Finalized Budget Vote
CBudgetVote vote; CBudgetVote vote;
vRecv >> vote; vRecv >> vote;
vote.fValid = true; vote.fValid = true;
@ -212,7 +212,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
CMasternode* pmn = mnodeman.Find(vote.vin); CMasternode* pmn = mnodeman.Find(vote.vin);
if(pmn == NULL) { if(pmn == NULL) {
LogPrint("mnbudget", "fbvote - unknown masternode - vin: %s\n", vote.vin.ToString()); LogPrint("mngovernance", "fbvote - unknown masternode - vin: %s\n", vote.vin.ToString());
mnodeman.AskForMN(pfrom, vote.vin); mnodeman.AskForMN(pfrom, vote.vin);
return; return;
} }
@ -416,7 +416,7 @@ bool CBudgetManager::UpdateFinalizedBudget(CBudgetVote& vote, CNode* pfrom, std:
mapOrphanFinalizedBudgetVotes[vote.nBudgetHash] = vote; mapOrphanFinalizedBudgetVotes[vote.nBudgetHash] = vote;
if(!askedForSourceProposalOrBudget.count(vote.nBudgetHash)){ if(!askedForSourceProposalOrBudget.count(vote.nBudgetHash)){
pfrom->PushMessage(NetMsgType::MNBUDGETVOTESYNC, vote.nBudgetHash); pfrom->PushMessage(NetMsgType::mngovernanceVOTESYNC, vote.nBudgetHash);
askedForSourceProposalOrBudget[vote.nBudgetHash] = GetTime(); askedForSourceProposalOrBudget[vote.nBudgetHash] = GetTime();
} }
@ -616,7 +616,7 @@ std::string CBudgetManager::ToString() const
void CBudgetManager::UpdatedBlockTip(const CBlockIndex *pindex) void CBudgetManager::UpdatedBlockTip(const CBlockIndex *pindex)
{ {
pCurrentBlockIndex = pindex; pCurrentBlockIndex = pindex;
LogPrint("mnbudget", "pCurrentBlockIndex->nHeight: %d\n", pCurrentBlockIndex->nHeight); LogPrint("mngovernance", "pCurrentBlockIndex->nHeight: %d\n", pCurrentBlockIndex->nHeight);
if(!fLiteMode && masternodeSync.RequestedMasternodeAssets > MASTERNODE_SYNC_LIST) if(!fLiteMode && masternodeSync.RequestedMasternodeAssets > MASTERNODE_SYNC_LIST)
NewBlock(); NewBlock();
@ -662,12 +662,12 @@ bool CFinalizedBudget::AddOrUpdateVote(CBudgetVote& vote, std::string& strError)
if(mapVotes.count(hash)){ if(mapVotes.count(hash)){
if(mapVotes[hash].nTime > vote.nTime){ if(mapVotes[hash].nTime > vote.nTime){
strError = strprintf("new vote older than existing vote - %s", vote.GetHash().ToString()); strError = strprintf("new vote older than existing vote - %s", vote.GetHash().ToString());
LogPrint("mnbudget", "CFinalizedBudget::AddOrUpdateVote - %s\n", strError); LogPrint("mngovernance", "CFinalizedBudget::AddOrUpdateVote - %s\n", strError);
return false; return false;
} }
if(vote.nTime - mapVotes[hash].nTime < BUDGET_VOTE_UPDATE_MIN){ if(vote.nTime - mapVotes[hash].nTime < BUDGET_VOTE_UPDATE_MIN){
strError = strprintf("time between votes is too soon - %s - %lli", vote.GetHash().ToString(), vote.nTime - mapVotes[hash].nTime); strError = strprintf("time between votes is too soon - %s - %lli", vote.GetHash().ToString(), vote.nTime - mapVotes[hash].nTime);
LogPrint("mnbudget", "CFinalizedBudget::AddOrUpdateVote - %s\n", strError); LogPrint("mngovernance", "CFinalizedBudget::AddOrUpdateVote - %s\n", strError);
return false; return false;
} }
} }
@ -1008,7 +1008,7 @@ bool CBudgetVote::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode)
bool CBudgetVote::IsValid(bool fSignatureCheck) bool CBudgetVote::IsValid(bool fSignatureCheck)
{ {
if(nTime > GetTime() + (60*60)){ if(nTime > GetTime() + (60*60)){
LogPrint("mnbudget", "CBudgetVote::IsValid() - vote is too far ahead of current time - %s - nTime %lli - Max Time %lli\n", GetHash().ToString(), nTime, GetTime() + (60*60)); LogPrint("mngovernance", "CBudgetVote::IsValid() - vote is too far ahead of current time - %s - nTime %lli - Max Time %lli\n", GetHash().ToString(), nTime, GetTime() + (60*60));
return false; return false;
} }
@ -1016,7 +1016,7 @@ bool CBudgetVote::IsValid(bool fSignatureCheck)
if(pmn == NULL) if(pmn == NULL)
{ {
LogPrint("mnbudget", "CBudgetVote::IsValid() - Unknown Masternode\n"); LogPrint("mngovernance", "CBudgetVote::IsValid() - Unknown Masternode\n");
return false; return false;
} }

View File

@ -259,7 +259,7 @@ void CMasternodeSync::Process()
int nMnCount = mnodeman.CountEnabled(); int nMnCount = mnodeman.CountEnabled();
pnode->PushMessage(NetMsgType::MNWINNERSSYNC, nMnCount); //sync payees pnode->PushMessage(NetMsgType::MNWINNERSSYNC, nMnCount); //sync payees
uint256 n = uint256(); uint256 n = uint256();
pnode->PushMessage(NetMsgType::MNBUDGETVOTESYNC, n); //sync masternode votes pnode->PushMessage(NetMsgType::mngovernanceVOTESYNC, n); //sync masternode votes
} else { } else {
RequestedMasternodeAssets = MASTERNODE_SYNC_FINISHED; RequestedMasternodeAssets = MASTERNODE_SYNC_FINISHED;
} }

View File

@ -43,11 +43,11 @@ const char *GETSPORKS="getsporks";
const char *MNWINNER="mnw"; const char *MNWINNER="mnw";
const char *MNWINNERSSYNC="mnget"; const char *MNWINNERSSYNC="mnget";
const char *MNSCANERROR="mn scan error"; // TODO ??? const char *MNSCANERROR="mn scan error"; // TODO ???
const char *MNBUDGETVOTESYNC="mnvs"; const char *mngovernanceVOTESYNC="mnvs";
const char *MNBUDGETVOTE="mvote"; const char *mngovernanceVOTE="mvote";
const char *MNBUDGETPROPOSAL="mprop"; const char *mngovernancePROPOSAL="mprop";
const char *MNBUDGETFINAL="fbs"; const char *mngovernanceFINAL="fbs";
const char *MNBUDGETFINALVOTE="fbvote"; const char *mngovernanceFINALVOTE="fbvote";
const char *MNQUORUM="mn quorum"; // TODO ??? const char *MNQUORUM="mn quorum"; // TODO ???
const char *MNANNOUNCE="mnb"; const char *MNANNOUNCE="mnb";
const char *MNPING="mnp"; const char *MNPING="mnp";
@ -75,10 +75,10 @@ static const char* ppszTypeName[] =
NetMsgType::SPORK, NetMsgType::SPORK,
NetMsgType::MNWINNER, NetMsgType::MNWINNER,
NetMsgType::MNSCANERROR, NetMsgType::MNSCANERROR,
NetMsgType::MNBUDGETVOTE, NetMsgType::mngovernanceVOTE,
NetMsgType::MNBUDGETPROPOSAL, NetMsgType::mngovernancePROPOSAL,
NetMsgType::MNBUDGETFINAL, NetMsgType::mngovernanceFINAL,
NetMsgType::MNBUDGETFINALVOTE, NetMsgType::mngovernanceFINALVOTE,
NetMsgType::MNQUORUM, NetMsgType::MNQUORUM,
NetMsgType::MNANNOUNCE, NetMsgType::MNANNOUNCE,
NetMsgType::MNPING, NetMsgType::MNPING,
@ -119,11 +119,11 @@ const static std::string allNetMessageTypes[] = {
NetMsgType::MNWINNER, NetMsgType::MNWINNER,
NetMsgType::MNWINNERSSYNC, NetMsgType::MNWINNERSSYNC,
NetMsgType::MNSCANERROR, NetMsgType::MNSCANERROR,
NetMsgType::MNBUDGETVOTESYNC, NetMsgType::mngovernanceVOTESYNC,
NetMsgType::MNBUDGETVOTE, NetMsgType::mngovernanceVOTE,
NetMsgType::MNBUDGETPROPOSAL, NetMsgType::mngovernancePROPOSAL,
NetMsgType::MNBUDGETFINAL, NetMsgType::mngovernanceFINAL,
NetMsgType::MNBUDGETFINALVOTE, NetMsgType::mngovernanceFINALVOTE,
NetMsgType::MNQUORUM, NetMsgType::MNQUORUM,
NetMsgType::MNANNOUNCE, NetMsgType::MNANNOUNCE,
NetMsgType::MNPING, NetMsgType::MNPING,

View File

@ -228,11 +228,11 @@ extern const char *GETSPORKS;
extern const char *MNWINNER; extern const char *MNWINNER;
extern const char *MNWINNERSSYNC; extern const char *MNWINNERSSYNC;
extern const char *MNSCANERROR; extern const char *MNSCANERROR;
extern const char *MNBUDGETVOTESYNC; extern const char *mngovernanceVOTESYNC;
extern const char *MNBUDGETVOTE; extern const char *mngovernanceVOTE;
extern const char *MNBUDGETPROPOSAL; extern const char *mngovernancePROPOSAL;
extern const char *MNBUDGETFINAL; extern const char *mngovernanceFINAL;
extern const char *MNBUDGETFINALVOTE; extern const char *mngovernanceFINALVOTE;
extern const char *MNQUORUM; extern const char *MNQUORUM;
extern const char *MNANNOUNCE; extern const char *MNANNOUNCE;
extern const char *MNPING; extern const char *MNPING;

View File

@ -111,8 +111,8 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "setban", 2 }, { "setban", 2 },
{ "setban", 3 }, { "setban", 3 },
{ "spork", 1 }, { "spork", 1 },
{ "mnbudgetvoteraw", 1 }, { "mngovernancevoteraw", 1 },
{ "mnbudgetvoteraw", 4 }, { "mngovernancevoteraw", 4 },
}; };
class CRPCConvertTable class CRPCConvertTable

View File

@ -34,16 +34,28 @@ using namespace std;
* *
* command structure: * command structure:
* *
* governance prepare new nTypeIn nParentID "name" epoch-start epoch-end parameter1 parameter2 parameter3 * For instructions on creating registers, see dashbrain
*
*
* governance prepare new nTypeIn nParentID "name" epoch-start epoch-end register1 register2 register3
* >> fee transaction hash * >> fee transaction hash
* *
* governance submit fee-hash nTypeIn nParentID, "name", epoch-start, epoch-end, fee-hash, parameter1, parameter2, parameter3 * governance submit fee-hash nTypeIn nParentID, "name", epoch-start, epoch-end, fee-hash, register1, register2, register3
* >> governance object hash * >> 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 mnbudget(const UniValue& params, bool fHelp) UniValue mngovernance(const UniValue& params, bool fHelp)
{ {
string strCommand; string strCommand;
if (params.size() >= 1) if (params.size() >= 1)
@ -51,20 +63,16 @@ UniValue mnbudget(const UniValue& params, bool fHelp)
if (fHelp || if (fHelp ||
(strCommand != "vote-many" && strCommand != "vote-alias" && strCommand != "prepare" && strCommand != "submit" && (strCommand != "vote-many" && strCommand != "vote-alias" && strCommand != "prepare" && strCommand != "submit" &&
strCommand != "vote" && strCommand != "getvotes" && strCommand != "getproposal" && strCommand != "vote" && strCommand != "get" && strCommand != "list" && strCommand != "diff"))
strCommand != "list" && strCommand != "projection" && strCommand != "check"))
throw runtime_error( throw runtime_error(
"mnbudget \"command\"...\n" "mngovernance \"command\"...\n"
"Manage proposals\n" "Manage proposals\n"
"\nAvailable commands:\n" "\nAvailable commands:\n"
" check - Scan proposals and remove invalid from proposals list\n"
" prepare - Prepare proposal by signing and creating tx\n" " prepare - Prepare proposal by signing and creating tx\n"
" submit - Submit proposal to network\n" " submit - Submit proposal to network\n"
" getproposalhash - Get proposal hash(es) by proposal name\n" " get - Get proposal hash(es) by proposal name\n"
" getproposal - Show proposal\n"
" getvotes - Show detailed votes list for proposal\n"
" list - List all proposals\n" " list - List all proposals\n"
" projection - Show the projection of which proposals will be paid the next cycle\n" " diff - List differences since last diff\n"
" vote - Vote on a proposal by single masternode (using dash.conf setup)\n" " vote - Vote on a proposal by single masternode (using dash.conf setup)\n"
" vote-many - Vote on a proposal by all masternodes (using masternode.conf setup)\n" " vote-many - Vote on a proposal by all masternodes (using masternode.conf setup)\n"
" vote-alias - Vote on a proposal by alias\n" " vote-alias - Vote on a proposal by alias\n"
@ -73,7 +81,7 @@ UniValue mnbudget(const UniValue& params, bool fHelp)
if(strCommand == "prepare") if(strCommand == "prepare")
{ {
if (params.size() != 7) if (params.size() != 7)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'mnbudget prepare <proposal-name> <url> <payment-count> <block-start> <dash-address> <monthly-payment-dash>'"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'mngovernance prepare <proposal-name> <url> <payment-count> <block-start> <dash-address> <monthly-payment-dash>'");
int nBlockMin = 0; int nBlockMin = 0;
LOCK(cs_main); LOCK(cs_main);
@ -83,15 +91,10 @@ UniValue mnbudget(const UniValue& params, bool fHelp)
mnEntries = masternodeConfig.getEntries(); mnEntries = masternodeConfig.getEntries();
std::string strName = SanitizeString(params[1].get_str()); std::string strName = SanitizeString(params[1].get_str());
std::string strURL = SanitizeString(params[2].get_str());
int nBlockStart = params[4].get_int();
//set block min //set block min
if(pindex != NULL) nBlockMin = pindex->nHeight; if(pindex != NULL) nBlockMin = pindex->nHeight;
if(nBlockStart < nBlockMin)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block start, must be more than current height.");
CBitcoinAddress address(params[5].get_str()); CBitcoinAddress address(params[5].get_str());
if (!address.IsValid()) if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Dash address"); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Dash address");
@ -99,7 +102,7 @@ UniValue mnbudget(const UniValue& params, bool fHelp)
//************************************************************************* //*************************************************************************
// create transaction 15 minutes into the future, to allow for confirmation time // create transaction 15 minutes into the future, to allow for confirmation time
CGovernanceObject budgetProposalBroadcast(strName, strURL, GetTime(), 253370764800, uint256()); CGovernanceObject budgetProposalBroadcast(strName, GetTime(), 253370764800, uint256());
std::string strError = ""; std::string strError = "";
if(!budgetProposalBroadcast.IsValid(pindex, strError, false)) if(!budgetProposalBroadcast.IsValid(pindex, strError, false))
@ -121,7 +124,7 @@ UniValue mnbudget(const UniValue& params, bool fHelp)
if(strCommand == "submit") if(strCommand == "submit")
{ {
if (params.size() != 8) if (params.size() != 8)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'mnbudget submit <proposal-name> <url> <payment-count> <block-start> <dash-address> <monthly-payment-dash> <fee-tx>'"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'mngovernance submit <proposal-name> <url> <payment-count> <block-start> <dash-address> <monthly-payment-dash> <fee-tx>'");
if(!masternodeSync.IsBlockchainSynced()){ if(!masternodeSync.IsBlockchainSynced()){
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Must wait for client to sync with masternode network. Try again in a minute or so."); throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Must wait for client to sync with masternode network. Try again in a minute or so.");
@ -135,7 +138,6 @@ UniValue mnbudget(const UniValue& params, bool fHelp)
mnEntries = masternodeConfig.getEntries(); mnEntries = masternodeConfig.getEntries();
std::string strName = SanitizeString(params[1].get_str()); std::string strName = SanitizeString(params[1].get_str());
std::string strURL = SanitizeString(params[2].get_str());
//set block min //set block min
if(pindex != NULL) nBlockMin = pindex->nHeight; if(pindex != NULL) nBlockMin = pindex->nHeight;
@ -143,7 +145,7 @@ UniValue mnbudget(const UniValue& params, bool fHelp)
// create new governance object // create new governance object
uint256 hash = ParseHashV(params[7], "Proposal hash"); uint256 hash = ParseHashV(params[7], "Proposal hash");
CGovernanceObject budgetProposalBroadcast(strName, strURL, GetTime(), 253370764800, uint256()); CGovernanceObject budgetProposalBroadcast(strName, GetTime(), 253370764800, uint256());
std::string strError = ""; std::string strError = "";
@ -167,7 +169,7 @@ UniValue mnbudget(const UniValue& params, bool fHelp)
if(strCommand == "vote-many") if(strCommand == "vote-many")
{ {
if(params.size() != 3) if(params.size() != 3)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'mnbudget vote-many <proposal-hash> [yes|no]'"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'mngovernance vote-many <proposal-hash> [yes|no]'");
uint256 hash; uint256 hash;
std::string strVote; std::string strVote;
@ -254,7 +256,7 @@ UniValue mnbudget(const UniValue& params, bool fHelp)
if(strCommand == "vote-alias") if(strCommand == "vote-alias")
{ {
if(params.size() != 4) if(params.size() != 4)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'mnbudget vote-alias <proposal-hash> [yes|no] <alias-name>'"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'mngovernance vote-alias <proposal-hash> [yes|no] <alias-name>'");
uint256 hash; uint256 hash;
std::string strVote; std::string strVote;
@ -345,7 +347,7 @@ UniValue mnbudget(const UniValue& params, bool fHelp)
if(strCommand == "vote") if(strCommand == "vote")
{ {
if (params.size() != 3) if (params.size() != 3)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'mnbudget vote <proposal-hash> [yes|no]'"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'mngovernance vote <proposal-hash> [yes|no]'");
uint256 hash = ParseHashV(params[1], "Proposal hash"); uint256 hash = ParseHashV(params[1], "Proposal hash");
std::string strVote = params[2].get_str(); std::string strVote = params[2].get_str();
@ -385,10 +387,10 @@ UniValue mnbudget(const UniValue& params, bool fHelp)
} }
} }
if(strCommand == "list") if(strCommand == "list" || strCommand == "diff")
{ {
if (params.size() > 2) if (params.size() > 2)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'mnbudget list [valid]'"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'mngovernance list [valid]'");
std::string strShow = "valid"; std::string strShow = "valid";
if (params.size() == 2) strShow = params[1].get_str(); if (params.size() == 2) strShow = params[1].get_str();
@ -401,14 +403,14 @@ UniValue mnbudget(const UniValue& params, bool fHelp)
pindex = chainActive.Tip(); pindex = chainActive.Tip();
} }
std::vector<CGovernanceObject*> winningProps = governance.GetAllProposals(); std::vector<CGovernanceObject*> winningProps = governance.GetAllProposals(governance.GetLastDiffTime());
governance.UpdateLastDiffTime(GetTime());
BOOST_FOREACH(CGovernanceObject* pbudgetProposal, winningProps) BOOST_FOREACH(CGovernanceObject* pbudgetProposal, winningProps)
{ {
if(strShow == "valid" && !pbudgetProposal->fValid) continue; if(strShow == "valid" && !pbudgetProposal->fValid) continue;
UniValue bObj(UniValue::VOBJ); UniValue bObj(UniValue::VOBJ);
bObj.push_back(Pair("Name", pbudgetProposal->GetName())); bObj.push_back(Pair("Name", pbudgetProposal->GetName()));
bObj.push_back(Pair("URL", pbudgetProposal->GetURL()));
bObj.push_back(Pair("Hash", pbudgetProposal->GetHash().ToString())); bObj.push_back(Pair("Hash", pbudgetProposal->GetHash().ToString()));
bObj.push_back(Pair("FeeTXHash", pbudgetProposal->nFeeTXHash.ToString())); bObj.push_back(Pair("FeeTXHash", pbudgetProposal->nFeeTXHash.ToString()));
bObj.push_back(Pair("StartTime", (int64_t)pbudgetProposal->GetStartTime())); bObj.push_back(Pair("StartTime", (int64_t)pbudgetProposal->GetStartTime()));
@ -433,7 +435,7 @@ UniValue mnbudget(const UniValue& params, bool fHelp)
if(strCommand == "getproposal") if(strCommand == "getproposal")
{ {
if (params.size() != 2) if (params.size() != 2)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'mnbudget getproposal <proposal-hash>'"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'mngovernance getproposal <proposal-hash>'");
uint256 hash = ParseHashV(params[1], "Proposal hash"); uint256 hash = ParseHashV(params[1], "Proposal hash");
@ -453,7 +455,6 @@ UniValue mnbudget(const UniValue& params, bool fHelp)
obj.push_back(Pair("Name", pbudgetProposal->GetName())); obj.push_back(Pair("Name", pbudgetProposal->GetName()));
obj.push_back(Pair("Hash", pbudgetProposal->GetHash().ToString())); obj.push_back(Pair("Hash", pbudgetProposal->GetHash().ToString()));
obj.push_back(Pair("FeeTXHash", pbudgetProposal->nFeeTXHash.ToString())); obj.push_back(Pair("FeeTXHash", pbudgetProposal->nFeeTXHash.ToString()));
obj.push_back(Pair("URL", pbudgetProposal->GetURL()));
obj.push_back(Pair("StartTime", (int64_t)pbudgetProposal->GetStartTime())); obj.push_back(Pair("StartTime", (int64_t)pbudgetProposal->GetStartTime()));
obj.push_back(Pair("EndTime", (int64_t)pbudgetProposal->GetEndTime())); obj.push_back(Pair("EndTime", (int64_t)pbudgetProposal->GetEndTime()));
obj.push_back(Pair("AbsoluteYesCount", (int64_t)pbudgetProposal->GetYesCount()-(int64_t)pbudgetProposal->GetNoCount())); obj.push_back(Pair("AbsoluteYesCount", (int64_t)pbudgetProposal->GetYesCount()-(int64_t)pbudgetProposal->GetNoCount()));
@ -472,7 +473,7 @@ UniValue mnbudget(const UniValue& params, bool fHelp)
if(strCommand == "getvotes") if(strCommand == "getvotes")
{ {
if (params.size() != 2) if (params.size() != 2)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'mnbudget getvotes <proposal-hash>'"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'mngovernance getvotes <proposal-hash>'");
uint256 hash = ParseHashV(params[1], "Proposal hash"); uint256 hash = ParseHashV(params[1], "Proposal hash");
@ -505,11 +506,11 @@ UniValue mnbudget(const UniValue& params, bool fHelp)
return NullUniValue; return NullUniValue;
} }
UniValue mnbudgetvoteraw(const UniValue& params, bool fHelp) UniValue mngovernancevoteraw(const UniValue& params, bool fHelp)
{ {
if (fHelp || params.size() != 6) if (fHelp || params.size() != 6)
throw runtime_error( throw runtime_error(
"mnbudgetvoteraw <masternode-tx-hash> <masternode-tx-index> <proposal-hash> [yes|no] <time> <vote-sig>\n" "mngovernancevoteraw <masternode-tx-hash> <masternode-tx-index> <proposal-hash> [yes|no] <time> <vote-sig>\n"
"Compile and relay a proposal vote with provided external signature instead of signing vote internally\n" "Compile and relay a proposal vote with provided external signature instead of signing vote internally\n"
); );

View File

@ -120,7 +120,7 @@ UniValue debug(const UniValue& params, bool fHelp)
throw runtime_error( throw runtime_error(
"debug ( 0|1|addrman|alert|bench|coindb|db|lock|rand|rpc|selectcoins|mempool" "debug ( 0|1|addrman|alert|bench|coindb|db|lock|rand|rpc|selectcoins|mempool"
"|mempoolrej|net|proxy|prune|http|libevent|tor|zmq|" "|mempoolrej|net|proxy|prune|http|libevent|tor|zmq|"
"dash|darksend|instantx|masternode|keepass|mnpayments|mnbudget )\n" "dash|darksend|instantx|masternode|keepass|mnpayments|mngovernance )\n"
"Change debug category on the fly. Specify single category or use comma to specify many.\n" "Change debug category on the fly. Specify single category or use comma to specify many.\n"
"\nExamples:\n" "\nExamples:\n"
+ HelpExampleCli("debug", "dash") + HelpExampleCli("debug", "dash")

View File

@ -338,8 +338,8 @@ static const CRPCCommand vRPCCommands[] =
{ "dash", "masternode", &masternode, true }, { "dash", "masternode", &masternode, true },
{ "dash", "masternodelist", &masternodelist, true }, { "dash", "masternodelist", &masternodelist, true },
{ "dash", "masternodebroadcast", &masternodebroadcast, true }, { "dash", "masternodebroadcast", &masternodebroadcast, true },
{ "dash", "mnbudget", &mnbudget, true }, { "dash", "mngovernance", &mngovernance, true },
{ "dash", "mnbudgetvoteraw", &mnbudgetvoteraw, true }, { "dash", "mngovernancevoteraw", &mngovernancevoteraw, true },
{ "dash", "mnsync", &mnsync, true }, { "dash", "mnsync", &mnsync, true },
{ "dash", "spork", &spork, true }, { "dash", "spork", &spork, true },
{ "dash", "getpoolinfo", &getpoolinfo, true }, { "dash", "getpoolinfo", &getpoolinfo, true },

View File

@ -264,8 +264,8 @@ extern UniValue spork(const UniValue& params, bool fHelp);
extern UniValue masternode(const UniValue& params, bool fHelp); extern UniValue masternode(const UniValue& params, bool fHelp);
extern UniValue masternodelist(const UniValue& params, bool fHelp); extern UniValue masternodelist(const UniValue& params, bool fHelp);
extern UniValue masternodebroadcast(const UniValue& params, bool fHelp); extern UniValue masternodebroadcast(const UniValue& params, bool fHelp);
extern UniValue mnbudget(const UniValue& params, bool fHelp); extern UniValue mngovernance(const UniValue& params, bool fHelp);
extern UniValue mnbudgetvoteraw(const UniValue& params, bool fHelp); extern UniValue mngovernancevoteraw(const UniValue& params, bool fHelp);
extern UniValue mnsync(const UniValue& params, bool fHelp); extern UniValue mnsync(const UniValue& params, bool fHelp);
extern UniValue getblockcount(const UniValue& params, bool fHelp); // in rpcblockchain.cpp extern UniValue getblockcount(const UniValue& params, bool fHelp); // in rpcblockchain.cpp

View File

@ -283,7 +283,7 @@ bool LogAcceptCategory(const char* category)
ptrCategory->insert(string("masternode")); ptrCategory->insert(string("masternode"));
ptrCategory->insert(string("keepass")); ptrCategory->insert(string("keepass"));
ptrCategory->insert(string("mnpayments")); ptrCategory->insert(string("mnpayments"));
ptrCategory->insert(string("mnbudget")); ptrCategory->insert(string("mngovernance"));
} }
} }
const set<string>& setCategories = *ptrCategory.get(); const set<string>& setCategories = *ptrCategory.get();