Merge branch 'v0.12.0.x' of https://github.com/dashpay/dash into v0.12.0.x

This commit is contained in:
Evan Duffield 2015-07-11 13:26:22 -07:00
commit 03d6f3c140
2 changed files with 31 additions and 4 deletions

View File

@ -3,6 +3,7 @@
#include "activemasternode.h"
#include "masternodeman.h"
#include "masternode.h"
#include "masternodeconfig.h"
#include <boost/lexical_cast.hpp>
//
@ -302,10 +303,28 @@ vector<COutput> CActiveMasternode::SelectCoinsMasternode()
{
vector<COutput> vCoins;
vector<COutput> filteredCoins;
vector<COutPoint> confLockedCoins;
// Temporary unlock MN coins from masternode.conf
if(GetBoolArg("-mnconflock", true)) {
uint256 mnTxHash;
BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) {
mnTxHash.SetHex(mne.getTxHash());
COutPoint outpoint = COutPoint(mnTxHash, boost::lexical_cast<unsigned int>(mne.getOutputIndex()));
confLockedCoins.push_back(outpoint);
pwalletMain->UnlockCoin(outpoint);
}
}
// Retrieve all possible outputs
pwalletMain->AvailableCoins(vCoins);
// Lock MN coins from masternode.conf back if they where temporary unlocked
if(!confLockedCoins.empty()) {
BOOST_FOREACH(COutPoint outpoint, confLockedCoins)
pwalletMain->LockCoin(outpoint);
}
// Filter
BOOST_FOREACH(const COutput& out, vCoins)
{

View File

@ -2,6 +2,7 @@
#include "net.h"
#include "masternodeconfig.h"
#include "util.h"
#include "ui_interface.h"
#include <base58.h>
CMasternodeConfig masternodeConfig;
@ -12,12 +13,14 @@ void CMasternodeConfig::add(std::string alias, std::string ip, std::string privK
}
bool CMasternodeConfig::read(std::string& strErr) {
int linenumber = 1;
boost::filesystem::ifstream streamConfig(GetMasternodeConfigFile());
if (!streamConfig.good()) {
return true; // No masternode.conf file is OK
}
for(std::string line; std::getline(streamConfig, line); )
for(std::string line; std::getline(streamConfig, line); linenumber++)
{
if(line.empty()) {
continue;
@ -28,7 +31,8 @@ bool CMasternodeConfig::read(std::string& strErr) {
iss.str(line);
iss.clear();
if (!(iss >> alias >> ip >> privKey >> txHash >> outputIndex)) {
strErr = "Could not parse masternode.conf line: " + line;
strErr = _("Could not parse masternode.conf") + "\n" +
strprintf(_("Line: %d"), linenumber) + "\n\"" + line + "\"";
streamConfig.close();
return false;
}
@ -36,12 +40,16 @@ bool CMasternodeConfig::read(std::string& strErr) {
if(Params().NetworkID() == CBaseChainParams::MAIN) {
if(CService(ip).GetPort() != 9999) {
strErr = "Invalid port detected in masternode.conf: " + line + " (must be 9999 for mainnet)";
strErr = _("Invalid port detected in masternode.conf") + "\n" +
strprintf(_("Line: %d"), linenumber) + "\n\"" + line + "\"" + "\n" +
_("(must be 9999 for mainnet)");
streamConfig.close();
return false;
}
} else if(CService(ip).GetPort() == 9999) {
strErr = "Invalid port detected in masternode.conf: " + line + " (9999 must be only on mainnet)";
strErr = _("Invalid port detected in masternode.conf") + "\n" +
strprintf(_("Line: %d"), linenumber) + "\n\"" + line + "\"" + "\n" +
_(" (9999 could be used only on mainnet)");
streamConfig.close();
return false;
}