Few fixes for mnbudget rpc
- do not ask for vote on prepare and submit - fix bug found by @thelazier - fix command descriptions to avoid confusions - tiny refactoring for tx/ix
This commit is contained in:
parent
640e721487
commit
2dbf8290f7
@ -50,8 +50,8 @@ Value mnbudget(const Array& params, bool fHelp)
|
||||
std::vector<CMasternodeConfig::CMasternodeEntry> mnEntries;
|
||||
mnEntries = masternodeConfig.getEntries();
|
||||
|
||||
if (params.size() != 8 || params.size() != 9)
|
||||
throw runtime_error("Correct usage of vote-many is 'mnbudget prepare PROPOSAL-NAME URL PAYMENT_COUNT BLOCK_START DASH_ADDRESS DASH_AMOUNT YES|NO|ABSTAIN [USE_IX(TRUE|FALSE)]'");
|
||||
if (params.size() != 7 && params.size() != 8)
|
||||
throw runtime_error("Correct usage of prepare is 'mnbudget prepare PROPOSAL-NAME URL PAYMENT_COUNT BLOCK_START DASH_ADDRESS DASH_AMOUNT [USE_IX(true|false)]'");
|
||||
|
||||
std::string strProposalName = params[1].get_str();
|
||||
if(strProposalName.size() > 20)
|
||||
@ -90,12 +90,6 @@ Value mnbudget(const Array& params, bool fHelp)
|
||||
CScript scriptPubKey = GetScriptForDestination(address.Get());
|
||||
|
||||
CAmount nAmount = AmountFromValue(params[6]);
|
||||
std::string strVote = params[7].get_str().c_str();
|
||||
|
||||
if(strVote != "yes" && strVote != "no") return "You can only vote 'yes' or 'no'";
|
||||
int nVote = VOTE_ABSTAIN;
|
||||
if(strVote == "yes") nVote = VOTE_YES;
|
||||
if(strVote == "no") nVote = VOTE_NO;
|
||||
|
||||
CPubKey pubKeyMasternode;
|
||||
CKey keyMasternode;
|
||||
@ -107,18 +101,12 @@ Value mnbudget(const Array& params, bool fHelp)
|
||||
//*************************************************************************
|
||||
|
||||
CBudgetProposalBroadcast budgetProposalBroadcast(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, 0);
|
||||
std::string strCommand = "tx";
|
||||
bool useIX = true;
|
||||
if (params.size() > 8)
|
||||
useIX = params[8].get_bool();
|
||||
|
||||
if(useIX)
|
||||
{
|
||||
strCommand = "ix";
|
||||
}
|
||||
bool useIX = true;
|
||||
if (params.size() > 7) useIX = params[7].get_bool();
|
||||
|
||||
CWalletTx wtx;
|
||||
pwalletMain->GetBudgetSystemCollateralTX(wtx, budgetProposalBroadcast.GetHash(), useIX);
|
||||
pwalletMain->GetBudgetSystemCollateralTX(wtx, budgetProposalBroadcast.GetHash(), useIX ? "ix" : "tx");
|
||||
|
||||
// make our change address
|
||||
CReserveKey reservekey(pwalletMain);
|
||||
@ -137,8 +125,8 @@ Value mnbudget(const Array& params, bool fHelp)
|
||||
std::vector<CMasternodeConfig::CMasternodeEntry> mnEntries;
|
||||
mnEntries = masternodeConfig.getEntries();
|
||||
|
||||
if (params.size() != 9)
|
||||
throw runtime_error("Correct usage of vote-many is 'mnbudget submit PROPOSAL-NAME URL PAYMENT_COUNT BLOCK_START DASH_ADDRESS DASH_AMOUNT YES|NO|ABSTAIN FEE_TX'");
|
||||
if (params.size() != 8)
|
||||
throw runtime_error("Correct usage of submit is 'mnbudget submit PROPOSAL-NAME URL PAYMENT_COUNT BLOCK_START DASH_ADDRESS DASH_AMOUNT FEE_TX'");
|
||||
|
||||
// Check these inputs the same way we check the vote commands:
|
||||
// **********************************************************
|
||||
@ -180,12 +168,6 @@ Value mnbudget(const Array& params, bool fHelp)
|
||||
CScript scriptPubKey = GetScriptForDestination(address.Get());
|
||||
|
||||
CAmount nAmount = AmountFromValue(params[6]);
|
||||
std::string strVote = params[7].get_str().c_str();
|
||||
|
||||
if(strVote != "yes" && strVote != "no") return "You can only vote 'yes' or 'no'";
|
||||
int nVote = VOTE_ABSTAIN;
|
||||
if(strVote == "yes") nVote = VOTE_YES;
|
||||
if(strVote == "no") nVote = VOTE_NO;
|
||||
|
||||
CPubKey pubKeyMasternode;
|
||||
CKey keyMasternode;
|
||||
@ -194,7 +176,7 @@ Value mnbudget(const Array& params, bool fHelp)
|
||||
if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, keyMasternode, pubKeyMasternode))
|
||||
return(" Error upon calling SetKey");
|
||||
|
||||
uint256 hash = ParseHashV(params[8], "parameter 1");
|
||||
uint256 hash = ParseHashV(params[7], "parameter 1");
|
||||
|
||||
//create the proposal incase we're the first to make it
|
||||
CBudgetProposalBroadcast budgetProposalBroadcast(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, hash);
|
||||
@ -220,7 +202,7 @@ Value mnbudget(const Array& params, bool fHelp)
|
||||
mnEntries = masternodeConfig.getEntries();
|
||||
|
||||
if (params.size() != 3)
|
||||
throw runtime_error("Correct usage of vote-many is 'mnbudget vote-many PROPOSAL-HASH YES|NO|ABSTAIN'");
|
||||
throw runtime_error("Correct usage of vote-many is 'mnbudget vote-many PROPOSAL-HASH yes|no'");
|
||||
|
||||
uint256 hash = ParseHashV(params[1], "parameter 1");
|
||||
std::string strVote = params[2].get_str().c_str();
|
||||
@ -279,7 +261,7 @@ Value mnbudget(const Array& params, bool fHelp)
|
||||
mnEntries = masternodeConfig.getEntries();
|
||||
|
||||
if (params.size() != 3)
|
||||
throw runtime_error("Correct usage of vote-many is 'mnbudget vote PROPOSAL-HASH YES|NO|ABSTAIN'");
|
||||
throw runtime_error("Correct usage of vote is 'mnbudget vote PROPOSAL-HASH yes|no'");
|
||||
|
||||
uint256 hash = ParseHashV(params[1], "parameter 1");
|
||||
std::string strVote = params[2].get_str().c_str();
|
||||
|
Loading…
Reference in New Issue
Block a user