Merge remote-tracking branch 'upstream/v0.12.1.x' into Crownium

This commit is contained in:
crowning- 2015-09-16 20:20:33 +02:00
commit b5efb1e065
8 changed files with 184 additions and 151 deletions

View File

@ -1382,7 +1382,7 @@ bool CDarksendPool::DoAutomaticDenominating(bool fDryRun)
return false;
}
if(chainActive.Tip()->nHeight - cachedLastSuccess < minBlockSpacing) {
if(!fDarksendMultiSession && chainActive.Tip()->nHeight - cachedLastSuccess < minBlockSpacing) {
LogPrintf("CDarksendPool::DoAutomaticDenominating - Last successful Darksend action was too recent\n");
strAutoDenomResult = _("Last successful Darksend action was too recent.");
return false;
@ -1475,7 +1475,7 @@ bool CDarksendPool::DoAutomaticDenominating(bool fDryRun)
int nUseQueue = rand()%100;
UpdateState(POOL_STATUS_ACCEPTING_ENTRIES);
if(pwalletMain->GetDenominatedBalance(true) > 0){ //get denominated unconfirmed inputs
if(!fDarksendMultiSession && pwalletMain->GetDenominatedBalance(true) > 0) { //get denominated unconfirmed inputs
LogPrintf("DoAutomaticDenominating -- Found unconfirmed denominated outputs, will wait till they confirm to continue.\n");
strAutoDenomResult = _("Found unconfirmed denominated outputs, will wait till they confirm to continue.");
return false;

View File

@ -419,6 +419,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += "\n" + _("Darksend options:") + "\n";
strUsage += " -enabledarksend=<n> " + strprintf(_("Enable use of automated darksend for funds stored in this wallet (0-1, default: %u)"), 0) + "\n";
strUsage += " -darksendmultisession=<n> " + strprintf(_("Enable multiple darksend mixing sessions per block, experimental (0-1, default: %u)"), 0) + "\n";
strUsage += " -darksendrounds=<n> " + strprintf(_("Use N separate masternodes to anonymize funds (2-8, default: %u)"), 2) + "\n";
strUsage += " -anonymizedashamount=<n> " + strprintf(_("Keep N DASH anonymized (default: %u)"), 0) + "\n";
strUsage += " -liquidityprovider=<n> " + strprintf(_("Provide liquidity to Darksend by infrequently mixing coins on a continual basis (0-100, default: %u, 1=very frequent, high fees, 100=very infrequent, low fees)"), 0) + "\n";
@ -1516,6 +1517,7 @@ bool AppInit2(boost::thread_group& threadGroup)
}
fEnableDarksend = GetBoolArg("-enabledarksend", false);
fDarksendMultiSession = GetBoolArg("-darksendmultisession", false);
nDarksendRounds = GetArg("-darksendrounds", 2);
if(nDarksendRounds > 16) nDarksendRounds = 16;
@ -1526,6 +1528,7 @@ bool AppInit2(boost::thread_group& threadGroup)
darkSendPool.SetMinBlockSpacing(std::min(nLiquidityProvider,100)*15);
fEnableDarksend = true;
nDarksendRounds = 99999;
fDarksendMultiSession = false;
}
nAnonymizeDarkcoinAmount = GetArg("-anonymizedashamount", 0);

View File

@ -1265,18 +1265,6 @@ CBudgetProposal::CBudgetProposal()
fValid = true;
}
CBudgetProposal::CBudgetProposal(std::string strProposalNameIn, std::string strURLIn, int nBlockStartIn, int nBlockEndIn, CScript addressIn, CAmount nAmountIn, uint256 nFeeTXHashIn)
{
strProposalName = strProposalNameIn;
strURL = strURLIn;
nBlockStart = nBlockStartIn;
nBlockEnd = nBlockEndIn;
address = addressIn;
nAmount = nAmountIn;
nFeeTXHash = nFeeTXHashIn;
fValid = true;
}
CBudgetProposal::CBudgetProposal(const CBudgetProposal& other)
{
strProposalName = other.strProposalName;
@ -1291,6 +1279,23 @@ CBudgetProposal::CBudgetProposal(const CBudgetProposal& other)
fValid = true;
}
CBudgetProposal::CBudgetProposal(std::string strProposalNameIn, std::string strURLIn, int nPaymentCount, CScript addressIn, CAmount nAmountIn, int nBlockStartIn, uint256 nFeeTXHashIn)
{
strProposalName = strProposalNameIn;
strURL = strURLIn;
nBlockStart = nBlockStartIn;
int nPaymentsStart = nBlockStart - nBlockStart % GetBudgetPaymentCycleBlocks();
//calculate the end of the cycle for this vote, add half a cycle (vote will be deleted after that block)
nBlockEnd = nPaymentsStart + GetBudgetPaymentCycleBlocks() * nPaymentCount + GetBudgetPaymentCycleBlocks()/2;
address = addressIn;
nAmount = nAmountIn;
nFeeTXHash = nFeeTXHashIn;
}
bool CBudgetProposal::IsValid(std::string& strError, bool fCheckCollateral)
{
if(GetNays() - GetYeas() > mnodeman.CountEnabled(MIN_BUDGET_PEER_PROTO_VERSION)/10){
@ -1303,18 +1308,52 @@ bool CBudgetProposal::IsValid(std::string& strError, bool fCheckCollateral)
return false;
}
CBlockIndex* pindexPrev = chainActive.Tip();
if(pindexPrev == NULL) {strError = "Tip is NULL"; return true;}
if(nBlockStart % GetBudgetPaymentCycleBlocks() != 0){
int nNext = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks();
strError = strprintf("Invalid block start - must be a budget cycle block. Next valid block: %d", nNext);
return false;
}
if(nBlockEnd % GetBudgetPaymentCycleBlocks() != GetBudgetPaymentCycleBlocks()/2){
strError = "Invalid block end";
return false;
}
if(nBlockEnd < nBlockStart) {
strError = "Invalid nBlockEnd";
strError = "Invalid block end - must be greater then block start.";
return false;
}
if(nAmount < 1*COIN) {
strError = "Invalid nAmount";
strError = "Invalid proposal amount";
return false;
}
if(strProposalName.size() > 20) {
strError = "Invalid proposal name, limit of 20 characters.";
return false;
}
if(strProposalName != SanitizeString(strProposalName)) {
strError = "Invalid proposal name, unsafe characters found.";
return false;
}
if(strURL.size() > 64) {
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()) {
strError = "Invalid Payment Address";
strError = "Invalid proposal Payment Address";
return false;
}
@ -1349,9 +1388,6 @@ bool CBudgetProposal::IsValid(std::string& strError, bool fCheckCollateral)
return false;
}
CBlockIndex* pindexPrev = chainActive.Tip();
if(pindexPrev == NULL) {strError = "Tip is NULL"; return true;}
if(GetBlockEnd() < pindexPrev->nHeight - GetBudgetPaymentCycleBlocks()/2 ) return false;
@ -1493,23 +1529,6 @@ int CBudgetProposal::GetRemainingPaymentCount()
return (nPayments <= nTotal ? nPayments : nTotal);
}
CBudgetProposalBroadcast::CBudgetProposalBroadcast(std::string strProposalNameIn, std::string strURLIn, int nPaymentCount, CScript addressIn, CAmount nAmountIn, int nBlockStartIn, uint256 nFeeTXHashIn)
{
strProposalName = strProposalNameIn;
strURL = strURLIn;
nBlockStart = nBlockStartIn;
int nCycleStart = nBlockStart - nBlockStart % GetBudgetPaymentCycleBlocks();
//calculate the end of the cycle for this vote, add half a cycle (vote will be deleted after that block)
nBlockEnd = nCycleStart + GetBudgetPaymentCycleBlocks() * nPaymentCount + GetBudgetPaymentCycleBlocks()/2;
address = addressIn;
nAmount = nAmountIn;
nFeeTXHash = nFeeTXHashIn;
}
void CBudgetProposalBroadcast::Relay()
{
CInv inv(MSG_BUDGET_PROPOSAL, GetHash());

View File

@ -415,7 +415,7 @@ public:
CBudgetProposal();
CBudgetProposal(const CBudgetProposal& other);
CBudgetProposal(std::string strProposalNameIn, std::string strURLIn, int nBlockStartIn, int nBlockEndIn, CScript addressIn, CAmount nAmountIn, uint256 nFeeTXHashIn);
CBudgetProposal(std::string strProposalNameIn, std::string strURLIn, int nPaymentCount, CScript addressIn, CAmount nAmountIn, int nBlockStartIn, uint256 nFeeTXHashIn);
void Calculate();
bool AddOrUpdateVote(CBudgetVote& vote, std::string& strError);
@ -492,7 +492,7 @@ public:
CBudgetProposalBroadcast() : CBudgetProposal(){}
CBudgetProposalBroadcast(const CBudgetProposal& other) : CBudgetProposal(other){}
CBudgetProposalBroadcast(const CBudgetProposalBroadcast& other) : CBudgetProposal(other){}
CBudgetProposalBroadcast(std::string strProposalNameIn, std::string strURLIn, int nPaymentCount, CScript addressIn, CAmount nAmountIn, int nBlockStartIn, uint256 nFeeTXHashIn);
CBudgetProposalBroadcast(std::string strProposalNameIn, std::string strURLIn, int nPaymentCount, CScript addressIn, CAmount nAmountIn, int nBlockStartIn, uint256 nFeeTXHashIn) {}
void swap(CBudgetProposalBroadcast& first, CBudgetProposalBroadcast& second) // nothrow
{

View File

@ -24,22 +24,24 @@ Value mnbudget(const Array& params, bool fHelp)
strCommand = params[0].get_str();
if (fHelp ||
(strCommand != "vote-many" && strCommand != "prepare" && strCommand != "submit" && strCommand != "vote" && strCommand != "getvotes" && strCommand != "getinfo" && strCommand != "show" && strCommand != "projection" && strCommand != "check" && strCommand != "nextblock"))
(strCommand != "vote-many" && strCommand != "prepare" && strCommand != "submit" &&
strCommand != "vote" && strCommand != "getvotes" && strCommand != "getproposal" && strCommand != "getproposalhash" &&
strCommand != "list" && strCommand != "projection" && strCommand != "check" && strCommand != "nextblock"))
throw runtime_error(
"mnbudget \"command\"... ( \"passphrase\" )\n"
"Vote or show current budgets\n"
"mnbudget \"command\"...\n"
"Manage proposals\n"
"\nAvailable commands:\n"
" prepare - Prepare proposal for network by signing and creating tx\n"
" submit - Submit proposal for network\n"
" vote-many - Vote on a Dash initiative\n"
" vote-alias - Vote on a Dash initiative\n"
" vote - Vote on a Dash initiative/budget\n"
" getvotes - Show current masternode budgets\n"
" getinfo - Show current masternode budgets\n"
" show - Show all budgets\n"
" check - Scan proposals and remove invalid from proposals list\n"
" prepare - Prepare proposal by signing and creating tx\n"
" submit - Submit proposal to network\n"
" getproposalhash - 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"
" nextblock - Get info about next superblock for budget system\n"
" projection - Show the projection of which proposals will be paid the next cycle\n"
" check - Scan proposals and remove invalid\n"
" nextblock - Get next superblock for budget system\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"
);
if(strCommand == "nextblock")
@ -53,44 +55,26 @@ Value mnbudget(const Array& params, bool fHelp)
if(strCommand == "prepare")
{
if (params.size() != 7)
throw runtime_error("Correct usage is 'mnbudget prepare <proposal-name> <url> <payment-count> <block-start> <dash-address> <monthly-payment-dash>'");
int nBlockMin = 0;
CBlockIndex* pindexPrev = chainActive.Tip();
std::vector<CMasternodeConfig::CMasternodeEntry> mnEntries;
mnEntries = masternodeConfig.getEntries();
if (params.size() != 7)
throw runtime_error("Correct usage is 'mnbudget prepare proposal-name url payment_count block_start dash_address monthly_payment_dash'");
std::string strProposalName = SanitizeString(params[1].get_str());
if(strProposalName.size() > 20)
return "Invalid proposal name, limit of 20 characters.";
std::string strURL = SanitizeString(params[2].get_str());
if(strURL.size() > 64)
return "Invalid url, limit of 64 characters.";
int nPaymentCount = params[3].get_int();
if(nPaymentCount < 1)
return "Invalid payment count, must be more than zero.";
int nBlockStart = params[4].get_int();
//set block min
if(pindexPrev != NULL) nBlockMin = pindexPrev->nHeight - GetBudgetPaymentCycleBlocks() * (nPaymentCount + 1);
int nBlockStart = params[4].get_int();
if(nBlockStart % GetBudgetPaymentCycleBlocks() != 0){
int nNext = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks();
return strprintf("Invalid block start - must be a budget cycle block. Next valid block: %d", nNext);
}
int nBlockEnd = nBlockStart + GetBudgetPaymentCycleBlocks() * nPaymentCount;
if(pindexPrev != NULL) nBlockMin = pindexPrev->nHeight;
if(nBlockStart < nBlockMin)
return "Invalid block start, must be more than current height.";
if(nBlockEnd < pindexPrev->nHeight)
return "Invalid ending block, starting block + (payment_cycle*payments) must be more than current height.";
CBitcoinAddress address(params[5].get_str());
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Dash address");
@ -130,47 +114,30 @@ Value mnbudget(const Array& params, bool fHelp)
if(strCommand == "submit")
{
if (params.size() != 8)
throw runtime_error("Correct usage is 'mnbudget submit <proposal-name> <url> <payment-count> <block-start> <dash-address> <monthly-payment-dash> <fee-tx>'");
if(!masternodeSync.IsBlockchainSynced()){
return "Must wait for client to sync with masternode network. Try again in a minute or so.";
}
int nBlockMin = 0;
CBlockIndex* pindexPrev = chainActive.Tip();
std::vector<CMasternodeConfig::CMasternodeEntry> mnEntries;
mnEntries = masternodeConfig.getEntries();
if (params.size() != 8)
throw runtime_error("Correct usage is 'mnbudget submit proposal-name url payment_count block_start dash_address monthly_payment_dash fee_tx'");
// Check these inputs the same way we check the vote commands:
// **********************************************************
std::string strProposalName = SanitizeString(params[1].get_str());
if(strProposalName.size() > 20)
return "Invalid proposal name, limit of 20 characters.";
std::string strURL = SanitizeString(params[2].get_str());
if(strURL.size() > 64)
return "Invalid url, limit of 64 characters.";
int nPaymentCount = params[3].get_int();
if(nPaymentCount < 1)
return "Invalid payment count, must be more than zero.";
int nBlockStart = params[4].get_int();
//set block min
if(pindexPrev != NULL) nBlockMin = pindexPrev->nHeight - GetBudgetPaymentCycleBlocks() * (nPaymentCount + 1);
int nBlockStart = params[4].get_int();
if(nBlockStart % GetBudgetPaymentCycleBlocks() != 0){
int nNext = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks();
return strprintf("Invalid block start - must be a budget cycle block. Next valid block: %d", nNext);
}
int nBlockEnd = nBlockStart + (GetBudgetPaymentCycleBlocks()*nPaymentCount);
if(pindexPrev != NULL) nBlockMin = pindexPrev->nHeight;
if(nBlockStart < nBlockMin)
return "Invalid payment count, must be more than current height.";
if(nBlockEnd < pindexPrev->nHeight)
return "Invalid ending block, starting block + (payment_cycle*payments) must be more than current height.";
CBitcoinAddress address(params[5].get_str());
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Dash address");
@ -178,25 +145,22 @@ Value mnbudget(const Array& params, bool fHelp)
// Parse Dash address
CScript scriptPubKey = GetScriptForDestination(address.Get());
CAmount nAmount = AmountFromValue(params[6]);
uint256 hash = ParseHashV(params[7], "parameter 1");
uint256 hash = ParseHashV(params[7], "Proposal hash");
//create the proposal incase we're the first to make it
CBudgetProposalBroadcast budgetProposalBroadcast(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, hash);
std::string strError = "";
if(!budgetProposalBroadcast.IsValid(strError)){
return "Proposal is not valid - " + budgetProposalBroadcast.GetHash().ToString() + " - " + strError;
}
int nConf = 0;
if(!IsBudgetCollateralValid(hash, budgetProposalBroadcast.GetHash(), strError, budgetProposalBroadcast.nTime, nConf)){
return "Proposal FeeTX is not valid - " + hash.ToString() + " - " + strError;
}
if(!masternodeSync.IsBlockchainSynced()){
return "Must wait for client to sync with masternode network. Try again in a minute or so.";
}
// if(!budgetProposalBroadcast.IsValid(strError)){
// return "Proposal is not valid - " + budgetProposalBroadcast.GetHash().ToString() + " - " + strError;
// }
budget.mapSeenMasternodeBudgetProposals.insert(make_pair(budgetProposalBroadcast.GetHash(), budgetProposalBroadcast));
budgetProposalBroadcast.Relay();
budget.AddProposal(budgetProposalBroadcast);
@ -207,14 +171,14 @@ Value mnbudget(const Array& params, bool fHelp)
if(strCommand == "vote-many")
{
std::vector<CMasternodeConfig::CMasternodeEntry> mnEntries;
mnEntries = masternodeConfig.getEntries();
if(params.size() != 3)
throw runtime_error("Correct usage is 'mnbudget vote-many <proposal-hash> <yes|no>'");
if (params.size() != 3)
throw runtime_error("Correct usage is 'mnbudget vote-many proposal-hash yes|no'");
uint256 hash;
std::string strVote;
uint256 hash = ParseHashV(params[1], "parameter 1");
std::string strVote = params[2].get_str();
hash = ParseHashV(params[1], "Proposal hash");
strVote = params[2].get_str();
if(strVote != "yes" && strVote != "no") return "You can only vote 'yes' or 'no'";
int nVote = VOTE_ABSTAIN;
@ -224,6 +188,9 @@ Value mnbudget(const Array& params, bool fHelp)
int success = 0;
int failed = 0;
std::vector<CMasternodeConfig::CMasternodeEntry> mnEntries;
mnEntries = masternodeConfig.getEntries();
Object resultsObj;
BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) {
@ -289,13 +256,10 @@ Value mnbudget(const Array& params, bool fHelp)
if(strCommand == "vote")
{
std::vector<CMasternodeConfig::CMasternodeEntry> mnEntries;
mnEntries = masternodeConfig.getEntries();
if (params.size() != 3)
throw runtime_error("Correct usage is 'mnbudget vote proposal-hash yes|no'");
throw runtime_error("Correct usage is 'mnbudget vote <proposal-hash> <yes|no>'");
uint256 hash = ParseHashV(params[1], "parameter 1");
uint256 hash = ParseHashV(params[1], "Proposal hash");
std::string strVote = params[2].get_str();
if(strVote != "yes" && strVote != "no") return "You can only vote 'yes' or 'no'";
@ -360,7 +324,6 @@ Value mnbudget(const Array& params, bool fHelp)
bObj.push_back(Pair("TotalPayment", ValueFromAmount(pbudgetProposal->GetAmount()*pbudgetProposal->GetTotalPaymentCount())));
bObj.push_back(Pair("MonthlyPayment", ValueFromAmount(pbudgetProposal->GetAmount())));
bObj.push_back(Pair("Alloted", ValueFromAmount(pbudgetProposal->GetAllotted())));
bObj.push_back(Pair("TotalBudgetAlloted", ValueFromAmount(nTotalAllotted)));
std::string strError = "";
bObj.push_back(Pair("IsValid", pbudgetProposal->IsValid(strError)));
@ -369,15 +332,18 @@ Value mnbudget(const Array& params, bool fHelp)
resultObj.push_back(Pair(pbudgetProposal->GetName(), bObj));
}
resultObj.push_back(Pair("TotalBudgetAlloted", ValueFromAmount(nTotalAllotted)));
return resultObj;
}
if(strCommand == "show")
if(strCommand == "list")
{
if (params.size() > 2)
throw runtime_error("Correct usage is 'mnbudget list [valid]'");
std::string strShow = "valid";
if (params.size() == 2)
std::string strProposalName = params[1].get_str();
if (params.size() == 2) strShow = params[1].get_str();
Object resultObj;
int64_t nTotalAllotted = 0;
@ -423,16 +389,62 @@ Value mnbudget(const Array& params, bool fHelp)
return resultObj;
}
if(strCommand == "getinfo")
if(strCommand == "getproposalhash")
{
if (params.size() != 2)
throw runtime_error("Correct usage is 'mnbudget getinfo profilename'");
throw runtime_error("Correct usage is 'mnbudget getproposalhash <proposal-name>'");
std::string strProposalName = params[1].get_str();
std::string strProposalName = SanitizeString(params[1].get_str());
CBudgetProposal* pbudgetProposal = budget.FindProposal(strProposalName);
if(pbudgetProposal == NULL) return "Unknown proposal name";
if(pbudgetProposal == NULL) return "Unknown proposal";
Object resultObj;
std::vector<CBudgetProposal*> winningProps = budget.GetAllProposals();
BOOST_FOREACH(CBudgetProposal* pbudgetProposal, winningProps)
{
if(pbudgetProposal->GetName() != strProposalName) continue;
if(!pbudgetProposal->fValid) continue;
CTxDestination address1;
ExtractDestination(pbudgetProposal->GetPayee(), address1);
CBitcoinAddress address2(address1);
Object bObj;
bObj.push_back(Pair("Hash", pbudgetProposal->GetHash().ToString()));
bObj.push_back(Pair("PaymentAddress", address2.ToString()));
bObj.push_back(Pair("Ratio", pbudgetProposal->GetRatio()));
bObj.push_back(Pair("Yeas", (int64_t)pbudgetProposal->GetYeas()));
bObj.push_back(Pair("Nays", (int64_t)pbudgetProposal->GetNays()));
bObj.push_back(Pair("Abstains", (int64_t)pbudgetProposal->GetAbstains()));
bObj.push_back(Pair("IsEstablished", pbudgetProposal->IsEstablished()));
std::string strError = "";
bObj.push_back(Pair("IsValid", pbudgetProposal->IsValid(strError)));
bObj.push_back(Pair("IsValidReason", strError.c_str()));
bObj.push_back(Pair("fValid", pbudgetProposal->fValid));
resultObj.push_back(Pair(pbudgetProposal->GetHash().ToString(), bObj));
}
if(resultObj.size() > 1) return resultObj;
return pbudgetProposal->GetHash().ToString();
}
if(strCommand == "getproposal")
{
if (params.size() != 2)
throw runtime_error("Correct usage is 'mnbudget getproposal <proposal-hash>'");
uint256 hash = ParseHashV(params[1], "Proposal hash");
CBudgetProposal* pbudgetProposal = budget.FindProposal(hash);
if(pbudgetProposal == NULL) return "Unknown proposal";
CTxDestination address1;
ExtractDestination(pbudgetProposal->GetPayee(), address1);
@ -467,15 +479,15 @@ Value mnbudget(const Array& params, bool fHelp)
if(strCommand == "getvotes")
{
if (params.size() != 2)
throw runtime_error("Correct usage is 'mnbudget getvotes profilename'");
throw runtime_error("Correct usage is 'mnbudget getvotes <proposal-hash>'");
std::string strProposalName = params[1].get_str();
uint256 hash = ParseHashV(params[1], "Proposal hash");
Object obj;
CBudgetProposal* pbudgetProposal = budget.FindProposal(strProposalName);
CBudgetProposal* pbudgetProposal = budget.FindProposal(hash);
if(pbudgetProposal == NULL) return "Unknown proposal name";
if(pbudgetProposal == NULL) return "Unknown proposal";
std::map<uint256, CBudgetVote>::iterator it = pbudgetProposal->mapVotes.begin();
while(it != pbudgetProposal->mapVotes.end()){
@ -512,24 +524,21 @@ Value mnfinalbudget(const Array& params, bool fHelp)
strCommand = params[0].get_str();
if (fHelp ||
(strCommand != "suggest" && strCommand != "vote-many" && strCommand != "vote" && strCommand != "show" && strCommand != "getvotes"))
(strCommand != "vote-many" && strCommand != "vote" && strCommand != "list" && strCommand != "getvotes"))
throw runtime_error(
"mnfinalbudget \"command\"... ( \"passphrase\" )\n"
"Vote or show current budgets\n"
"mnfinalbudget \"command\"...\n"
"Manage current budgets\n"
"\nAvailable commands:\n"
" vote-many - Vote on a finalized budget\n"
" vote - Vote on a finalized budget\n"
" show - Show existing finalized budgets\n"
" getvotes - Get vote information for each finalized budget\n"
" list - List existing finalized budgets\n"
" vote - Vote on a finalized budget by single masternode (using dash.conf setup)\n"
" vote-many - Vote on a finalized budget by all masternodes (using masternode.conf setup)\n"
" getvotes - Get vote information for each finalized budget\n"
);
if(strCommand == "vote-many")
{
std::vector<CMasternodeConfig::CMasternodeEntry> mnEntries;
mnEntries = masternodeConfig.getEntries();
if (params.size() != 2)
throw runtime_error("Correct usage is 'mnfinalbudget vote-many BUDGET_HASH'");
throw runtime_error("Correct usage is 'mnfinalbudget vote-many <budget-hash>'");
std::string strHash = params[1].get_str();
uint256 hash(strHash);
@ -537,6 +546,9 @@ Value mnfinalbudget(const Array& params, bool fHelp)
int success = 0;
int failed = 0;
std::vector<CMasternodeConfig::CMasternodeEntry> mnEntries;
mnEntries = masternodeConfig.getEntries();
Object resultsObj;
BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) {
@ -602,11 +614,8 @@ Value mnfinalbudget(const Array& params, bool fHelp)
if(strCommand == "vote")
{
std::vector<CMasternodeConfig::CMasternodeEntry> mnEntries;
mnEntries = masternodeConfig.getEntries();
if (params.size() != 2)
throw runtime_error("Correct usage is 'mnfinalbudget vote BUDGET_HASH'");
throw runtime_error("Correct usage is 'mnfinalbudget vote <budget-hash>'");
std::string strHash = params[1].get_str();
uint256 hash(strHash);
@ -640,7 +649,7 @@ Value mnfinalbudget(const Array& params, bool fHelp)
}
if(strCommand == "show")
if(strCommand == "list")
{
Object resultObj;
@ -670,7 +679,7 @@ Value mnfinalbudget(const Array& params, bool fHelp)
if(strCommand == "getvotes")
{
if (params.size() != 2)
throw runtime_error("Correct usage is 'mnbudget getvotes budget-hash'");
throw runtime_error("Correct usage is 'mnbudget getvotes <budget-hash>'");
std::string strHash = params[1].get_str();
uint256 hash(strHash);

View File

@ -116,6 +116,7 @@ int nLiquidityProvider = 0;
int64_t enforceMasternodePaymentsTime = 4085657524;
bool fSucessfullyLoaded = false;
bool fEnableDarksend = false;
bool fDarksendMultiSession = false;
/** All denominations used by darksend */
std::vector<int64_t> darkSendDenominations;
string strBudgetMode = "";

View File

@ -37,6 +37,7 @@ extern int nDarksendRounds;
extern int nAnonymizeDarkcoinAmount;
extern int nLiquidityProvider;
extern bool fEnableDarksend;
extern bool fDarksendMultiSession;
extern int64_t enforceMasternodePaymentsTime;
extern std::string strMasterNodeAddr;
extern int keysLoaded;

View File

@ -26,7 +26,7 @@ string SanitizeString(const string& str)
* safeChars chosen to allow simple messages/URLs/email addresses, but avoid anything
* even possibly remotely dangerous like & or >
*/
static string safeChars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890 .,;_/:?@()");
static string safeChars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890 .,;_-/:?@()");
string strResult;
for (std::string::size_type i = 0; i < str.size(); i++)
{