2014-12-09 02:17:57 +01:00
|
|
|
|
|
|
|
#include "protocol.h"
|
|
|
|
#include "activemasternode.h"
|
2015-02-23 21:01:21 +01:00
|
|
|
#include "masternodeman.h"
|
2015-04-17 17:10:38 +02:00
|
|
|
#include "masternode.h"
|
2015-07-09 05:34:30 +02:00
|
|
|
#include "masternodeconfig.h"
|
2014-12-09 02:17:57 +01:00
|
|
|
#include <boost/lexical_cast.hpp>
|
|
|
|
|
|
|
|
//
|
2015-03-05 09:10:15 +01:00
|
|
|
// Bootup the Masternode, look for a 1000DRK input and register on the network
|
2014-12-09 02:17:57 +01:00
|
|
|
//
|
2014-12-06 20:41:53 +01:00
|
|
|
void CActiveMasternode::ManageStatus()
|
2014-12-09 02:17:57 +01:00
|
|
|
{
|
2014-12-06 20:41:53 +01:00
|
|
|
std::string errorMessage;
|
|
|
|
|
2014-12-23 02:23:04 +01:00
|
|
|
if(!fMasterNode) return;
|
2014-12-06 20:41:53 +01:00
|
|
|
|
2014-12-23 02:23:04 +01:00
|
|
|
if (fDebug) LogPrintf("CActiveMasternode::ManageStatus() - Begin\n");
|
2014-12-09 02:17:57 +01:00
|
|
|
|
|
|
|
//need correct adjusted time to send ping
|
|
|
|
bool fIsInitialDownload = IsInitialBlockDownload();
|
|
|
|
if(fIsInitialDownload) {
|
2014-12-06 20:41:53 +01:00
|
|
|
status = MASTERNODE_SYNC_IN_PROCESS;
|
2015-03-05 09:10:15 +01:00
|
|
|
LogPrintf("CActiveMasternode::ManageStatus() - Sync in progress. Must wait until sync is complete to start Masternode.\n");
|
2014-12-09 02:17:57 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
if(status == MASTERNODE_INPUT_TOO_NEW || status == MASTERNODE_NOT_CAPABLE || status == MASTERNODE_SYNC_IN_PROCESS){
|
|
|
|
status = MASTERNODE_NOT_PROCESSED;
|
2014-12-09 02:17:57 +01:00
|
|
|
}
|
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
if(status == MASTERNODE_NOT_PROCESSED) {
|
2014-12-09 02:17:57 +01:00
|
|
|
if(strMasterNodeAddr.empty()) {
|
2014-12-06 20:41:53 +01:00
|
|
|
if(!GetLocal(service)) {
|
2015-03-05 09:10:15 +01:00
|
|
|
notCapableReason = "Can't detect external address. Please use the Masternodeaddr configuration option.";
|
2014-12-06 20:41:53 +01:00
|
|
|
status = MASTERNODE_NOT_CAPABLE;
|
|
|
|
LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason.c_str());
|
2014-12-09 02:17:57 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
2015-03-22 00:58:18 +01:00
|
|
|
service = CService(strMasterNodeAddr);
|
2014-12-09 02:17:57 +01:00
|
|
|
}
|
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
LogPrintf("CActiveMasternode::ManageStatus() - Checking inbound connection to '%s'\n", service.ToString().c_str());
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2015-04-03 00:51:08 +02:00
|
|
|
if(Params().NetworkID() == CBaseChainParams::MAIN) {
|
2015-02-06 20:41:39 +01:00
|
|
|
if(service.GetPort() != 9999) {
|
2015-02-16 00:01:06 +01:00
|
|
|
notCapableReason = "Invalid port: " + boost::lexical_cast<string>(service.GetPort()) + " - only 9999 is supported on mainnet.";
|
2015-02-06 20:41:39 +01:00
|
|
|
status = MASTERNODE_NOT_CAPABLE;
|
|
|
|
LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason.c_str());
|
|
|
|
return;
|
|
|
|
}
|
2015-03-11 20:26:39 +01:00
|
|
|
} else if(service.GetPort() == 9999) {
|
|
|
|
notCapableReason = "Invalid port: " + boost::lexical_cast<string>(service.GetPort()) + " - 9999 is only supported on mainnet.";
|
|
|
|
status = MASTERNODE_NOT_CAPABLE;
|
|
|
|
LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason.c_str());
|
|
|
|
return;
|
2015-02-06 20:41:39 +01:00
|
|
|
}
|
|
|
|
|
2015-03-13 10:28:20 +01:00
|
|
|
if(!ConnectNode((CAddress)service, service.ToString().c_str())){
|
|
|
|
notCapableReason = "Could not connect to " + service.ToString();
|
|
|
|
status = MASTERNODE_NOT_CAPABLE;
|
|
|
|
LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason.c_str());
|
|
|
|
return;
|
2014-12-09 02:17:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(pwalletMain->IsLocked()){
|
2014-12-06 20:41:53 +01:00
|
|
|
notCapableReason = "Wallet is locked.";
|
|
|
|
status = MASTERNODE_NOT_CAPABLE;
|
|
|
|
LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason.c_str());
|
2014-12-09 02:17:57 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
// Set defaults
|
|
|
|
status = MASTERNODE_NOT_CAPABLE;
|
2014-12-24 02:41:13 +01:00
|
|
|
notCapableReason = "Unknown. Check debug.log for more information.";
|
2014-12-09 02:17:57 +01:00
|
|
|
|
|
|
|
// Choose coins to use
|
2014-12-06 20:41:53 +01:00
|
|
|
CPubKey pubKeyCollateralAddress;
|
|
|
|
CKey keyCollateralAddress;
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
if(GetMasterNodeVin(vin, pubKeyCollateralAddress, keyCollateralAddress)) {
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
if(GetInputAge(vin) < MASTERNODE_MIN_CONFIRMATIONS){
|
2015-02-16 00:01:06 +01:00
|
|
|
notCapableReason = "Input must have least " + boost::lexical_cast<string>(MASTERNODE_MIN_CONFIRMATIONS) +
|
|
|
|
" confirmations - " + boost::lexical_cast<string>(GetInputAge(vin)) + " confirmations";
|
|
|
|
LogPrintf("CActiveMasternode::ManageStatus() - %s\n", notCapableReason.c_str());
|
2014-12-06 20:41:53 +01:00
|
|
|
status = MASTERNODE_INPUT_TOO_NEW;
|
2014-12-09 02:17:57 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
LogPrintf("CActiveMasternode::ManageStatus() - Is capable master node!\n");
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
status = MASTERNODE_IS_CAPABLE;
|
|
|
|
notCapableReason = "";
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
pwalletMain->LockCoin(vin.prevout);
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
// send to all nodes
|
|
|
|
CPubKey pubKeyMasternode;
|
|
|
|
CKey keyMasternode;
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, keyMasternode, pubKeyMasternode))
|
|
|
|
{
|
2015-03-22 00:58:18 +01:00
|
|
|
LogPrintf("Register::ManageStatus() - Error upon calling SetKey: %s\n", errorMessage.c_str());
|
|
|
|
return;
|
2014-12-09 02:17:57 +01:00
|
|
|
}
|
|
|
|
|
2015-06-23 18:38:28 +02:00
|
|
|
if(!Register(vin, service, keyCollateralAddress, pubKeyCollateralAddress, keyMasternode, pubKeyMasternode, errorMessage)) {
|
2015-02-16 00:01:06 +01:00
|
|
|
LogPrintf("CActiveMasternode::ManageStatus() - Error on Register: %s\n", errorMessage.c_str());
|
2014-12-09 02:17:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
2014-12-06 20:41:53 +01:00
|
|
|
} else {
|
2015-02-16 00:01:06 +01:00
|
|
|
notCapableReason = "Could not find suitable coins!";
|
|
|
|
LogPrintf("CActiveMasternode::ManageStatus() - %s\n", notCapableReason.c_str());
|
2014-12-09 02:17:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
//send to all peers
|
2015-04-17 17:10:38 +02:00
|
|
|
if(!Mnping(errorMessage)) {
|
2015-02-16 00:01:06 +01:00
|
|
|
LogPrintf("CActiveMasternode::ManageStatus() - Error on Ping: %s\n", errorMessage.c_str());
|
2014-12-06 20:41:53 +01:00
|
|
|
}
|
|
|
|
}
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2015-04-17 17:10:38 +02:00
|
|
|
bool CActiveMasternode::Mnping(std::string& errorMessage) {
|
2015-03-22 00:58:18 +01:00
|
|
|
if(status != MASTERNODE_IS_CAPABLE && status != MASTERNODE_REMOTELY_ENABLED) {
|
|
|
|
errorMessage = "Masternode is not in a running status";
|
2015-04-17 17:10:38 +02:00
|
|
|
LogPrintf("CActiveMasternode::Mnping() - Error: %s\n", errorMessage.c_str());
|
2015-03-22 00:58:18 +01:00
|
|
|
return false;
|
|
|
|
}
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
CPubKey pubKeyMasternode;
|
|
|
|
CKey keyMasternode;
|
|
|
|
|
|
|
|
if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, keyMasternode, pubKeyMasternode))
|
|
|
|
{
|
2015-04-17 17:10:38 +02:00
|
|
|
LogPrintf("CActiveMasternode::Mnping() - Error upon calling SetKey: %s\n", errorMessage.c_str());
|
2015-03-22 00:58:18 +01:00
|
|
|
return false;
|
2014-12-09 02:17:57 +01:00
|
|
|
}
|
|
|
|
|
2015-04-17 17:10:38 +02:00
|
|
|
return Mnping(vin, service, keyMasternode, pubKeyMasternode, errorMessage);
|
2014-12-06 20:41:53 +01:00
|
|
|
}
|
|
|
|
|
2015-04-17 17:10:38 +02:00
|
|
|
bool CActiveMasternode::Mnping(CTxIn vin, CService service, CKey keyMasternode, CPubKey pubKeyMasternode, std::string &retErrorMessage) {
|
|
|
|
//send to all peers
|
|
|
|
LogPrintf("CActiveMasternode::Mnping() - RelayMasternodeEntryPing vin = %s\n", vin.ToString().c_str());
|
|
|
|
|
|
|
|
CMasternodePing mnp(vin);
|
|
|
|
if(!mnp.Sign(keyMasternode, pubKeyMasternode))
|
2014-12-09 02:17:57 +01:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-03-05 09:10:15 +01:00
|
|
|
// Update Last Seen timestamp in Masternode list
|
2015-02-25 12:54:03 +01:00
|
|
|
CMasternode* pmn = mnodeman.Find(vin);
|
|
|
|
if(pmn != NULL)
|
2015-02-23 21:01:21 +01:00
|
|
|
{
|
2015-04-17 17:10:38 +02:00
|
|
|
pmn->UpdateLastSeen();
|
2014-12-09 02:17:57 +01:00
|
|
|
}
|
2015-02-23 21:01:21 +01:00
|
|
|
else
|
|
|
|
{
|
2015-03-22 00:58:18 +01:00
|
|
|
// Seems like we are trying to send a ping while the Masternode is not registered in the network
|
2015-04-03 00:51:08 +02:00
|
|
|
retErrorMessage = "Darksend Masternode List doesn't include our Masternode, shutting down Masternode pinging service! " + vin.ToString();
|
2015-04-17 17:10:38 +02:00
|
|
|
LogPrintf("CActiveMasternode::Mnping() - Error: %s\n", retErrorMessage.c_str());
|
2014-12-06 20:41:53 +01:00
|
|
|
status = MASTERNODE_NOT_CAPABLE;
|
|
|
|
notCapableReason = retErrorMessage;
|
2014-12-09 02:17:57 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-05-04 17:04:09 +02:00
|
|
|
mapSeenMasternodePing[mnp.GetHash()] = mnp;
|
2015-04-17 17:10:38 +02:00
|
|
|
mnp.Relay();
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
return true;
|
|
|
|
}
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2015-06-23 18:38:28 +02:00
|
|
|
bool CActiveMasternode::Register(std::string strService, std::string strKeyMasternode, std::string txHash, std::string strOutputIndex, std::string& errorMessage) {
|
2015-03-22 00:58:18 +01:00
|
|
|
CTxIn vin;
|
2014-12-06 20:41:53 +01:00
|
|
|
CPubKey pubKeyCollateralAddress;
|
|
|
|
CKey keyCollateralAddress;
|
|
|
|
CPubKey pubKeyMasternode;
|
|
|
|
CKey keyMasternode;
|
|
|
|
|
|
|
|
if(!darkSendSigner.SetKey(strKeyMasternode, errorMessage, keyMasternode, pubKeyMasternode))
|
|
|
|
{
|
2015-03-22 00:58:18 +01:00
|
|
|
LogPrintf("CActiveMasternode::Register() - Error upon calling SetKey: %s\n", errorMessage.c_str());
|
|
|
|
return false;
|
2014-12-09 02:17:57 +01:00
|
|
|
}
|
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
if(!GetMasterNodeVin(vin, pubKeyCollateralAddress, keyCollateralAddress, txHash, strOutputIndex)) {
|
2015-03-22 00:58:18 +01:00
|
|
|
errorMessage = "could not allocate vin";
|
|
|
|
LogPrintf("CActiveMasternode::Register() - Error: %s\n", errorMessage.c_str());
|
|
|
|
return false;
|
|
|
|
}
|
2015-03-16 20:01:11 +01:00
|
|
|
|
2015-06-23 18:38:28 +02:00
|
|
|
return Register(vin, CService(strService), keyCollateralAddress, pubKeyCollateralAddress, keyMasternode, pubKeyMasternode, errorMessage);
|
2014-12-06 20:41:53 +01:00
|
|
|
}
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2015-06-23 18:38:28 +02:00
|
|
|
bool CActiveMasternode::Register(CTxIn vin, CService service, CKey keyCollateralAddress, CPubKey pubKeyCollateralAddress, CKey keyMasternode, CPubKey pubKeyMasternode, std::string &retErrorMessage) {
|
2015-02-25 12:54:03 +01:00
|
|
|
CMasternode* pmn = mnodeman.Find(vin);
|
|
|
|
if(pmn == NULL)
|
2015-02-23 21:01:21 +01:00
|
|
|
{
|
2015-03-05 09:10:15 +01:00
|
|
|
LogPrintf("CActiveMasternode::Register() - Adding to Masternode list service: %s - vin: %s\n", service.ToString().c_str(), vin.ToString().c_str());
|
2015-06-23 18:38:28 +02:00
|
|
|
CMasternodeBroadcast mnb(service, vin, pubKeyCollateralAddress, pubKeyMasternode, PROTOCOL_VERSION);
|
2015-04-17 17:10:38 +02:00
|
|
|
if(!mnb.Sign(keyCollateralAddress)){
|
|
|
|
//send to all peers
|
|
|
|
LogPrintf("CActiveMasternode::Register() - Failed to sign %s\n", vin.ToString().c_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
CMasternode mn(mnb);
|
2015-06-15 02:05:51 +02:00
|
|
|
mn.UpdateLastSeen();
|
2015-02-23 21:01:21 +01:00
|
|
|
mnodeman.Add(mn);
|
2014-12-06 20:41:53 +01:00
|
|
|
}
|
2015-04-17 17:10:38 +02:00
|
|
|
|
|
|
|
if(pmn == NULL) pmn = mnodeman.Find(vin);
|
|
|
|
if(pmn != NULL)
|
|
|
|
{
|
|
|
|
CMasternodeBroadcast mnb(*pmn);
|
2015-05-04 17:04:09 +02:00
|
|
|
|
|
|
|
mapSeenMasternodeBroadcast[mnb.GetHash()] = mnb;
|
2015-04-17 17:10:38 +02:00
|
|
|
//send to all peers
|
|
|
|
LogPrintf("CActiveMasternode::Register() - RelayElectionEntry vin = %s\n", vin.ToString().c_str());
|
|
|
|
mnb.Relay(false);
|
|
|
|
}
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CActiveMasternode::GetMasterNodeVin(CTxIn& vin, CPubKey& pubkey, CKey& secretKey) {
|
2015-03-22 00:58:18 +01:00
|
|
|
return GetMasterNodeVin(vin, pubkey, secretKey, "", "");
|
2014-12-06 20:41:53 +01:00
|
|
|
}
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
bool CActiveMasternode::GetMasterNodeVin(CTxIn& vin, CPubKey& pubkey, CKey& secretKey, std::string strTxHash, std::string strOutputIndex) {
|
|
|
|
CScript pubScript;
|
|
|
|
|
|
|
|
// Find possible candidates
|
|
|
|
vector<COutput> possibleCoins = SelectCoinsMasternode();
|
|
|
|
COutput *selectedOutput;
|
|
|
|
|
|
|
|
// Find the vin
|
2015-03-22 00:58:18 +01:00
|
|
|
if(!strTxHash.empty()) {
|
|
|
|
// Let's find it
|
|
|
|
uint256 txHash(strTxHash);
|
2015-01-08 17:05:59 +01:00
|
|
|
int outputIndex = boost::lexical_cast<int>(strOutputIndex);
|
2015-03-22 00:58:18 +01:00
|
|
|
bool found = false;
|
|
|
|
BOOST_FOREACH(COutput& out, possibleCoins) {
|
|
|
|
if(out.tx->GetHash() == txHash && out.i == outputIndex)
|
|
|
|
{
|
|
|
|
selectedOutput = &out;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!found) {
|
|
|
|
LogPrintf("CActiveMasternode::GetMasterNodeVin - Could not locate valid vin\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// No output specified, Select the first one
|
|
|
|
if(possibleCoins.size() > 0) {
|
|
|
|
selectedOutput = &possibleCoins[0];
|
|
|
|
} else {
|
|
|
|
LogPrintf("CActiveMasternode::GetMasterNodeVin - Could not locate specified vin from possible list\n");
|
|
|
|
return false;
|
|
|
|
}
|
2014-12-09 02:17:57 +01:00
|
|
|
}
|
|
|
|
|
2015-03-22 00:58:18 +01:00
|
|
|
// At this point we have a selected output, retrieve the associated info
|
|
|
|
return GetVinFromOutput(*selectedOutput, vin, pubkey, secretKey);
|
2014-12-09 02:17:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-05 09:10:15 +01:00
|
|
|
// Extract Masternode vin information from output
|
2014-12-06 20:41:53 +01:00
|
|
|
bool CActiveMasternode::GetVinFromOutput(COutput out, CTxIn& vin, CPubKey& pubkey, CKey& secretKey) {
|
|
|
|
|
2014-12-09 02:17:57 +01:00
|
|
|
CScript pubScript;
|
|
|
|
|
2015-03-22 00:58:18 +01:00
|
|
|
vin = CTxIn(out.tx->GetHash(),out.i);
|
2014-12-06 20:41:53 +01:00
|
|
|
pubScript = out.tx->vout[out.i].scriptPubKey; // the inputs PubKey
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2015-03-22 00:58:18 +01:00
|
|
|
CTxDestination address1;
|
2014-12-09 02:17:57 +01:00
|
|
|
ExtractDestination(pubScript, address1);
|
|
|
|
CBitcoinAddress address2(address1);
|
|
|
|
|
|
|
|
CKeyID keyID;
|
|
|
|
if (!address2.GetKeyID(keyID)) {
|
|
|
|
LogPrintf("CActiveMasternode::GetMasterNodeVin - Address does not refer to a key\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pwalletMain->GetKey(keyID, secretKey)) {
|
|
|
|
LogPrintf ("CActiveMasternode::GetMasterNodeVin - Private key for address is not known\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
pubkey = secretKey.GetPubKey();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-03-05 09:10:15 +01:00
|
|
|
// get all possible outputs for running Masternode
|
2014-12-06 20:41:53 +01:00
|
|
|
vector<COutput> CActiveMasternode::SelectCoinsMasternode()
|
|
|
|
{
|
|
|
|
vector<COutput> vCoins;
|
|
|
|
vector<COutput> filteredCoins;
|
2015-07-09 05:34:30 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2014-12-06 20:41:53 +01:00
|
|
|
|
|
|
|
// Retrieve all possible outputs
|
2015-01-29 23:15:04 +01:00
|
|
|
pwalletMain->AvailableCoins(vCoins);
|
2014-12-06 20:41:53 +01:00
|
|
|
|
2015-07-09 05:34:30 +02:00
|
|
|
// Lock MN coins from masternode.conf back if they where temporary unlocked
|
|
|
|
if(!confLockedCoins.empty()) {
|
|
|
|
BOOST_FOREACH(COutPoint outpoint, confLockedCoins)
|
|
|
|
pwalletMain->LockCoin(outpoint);
|
|
|
|
}
|
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
// Filter
|
|
|
|
BOOST_FOREACH(const COutput& out, vCoins)
|
|
|
|
{
|
|
|
|
if(out.tx->vout[out.i].nValue == 1000*COIN) { //exactly
|
2015-03-22 00:58:18 +01:00
|
|
|
filteredCoins.push_back(out);
|
2014-12-06 20:41:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return filteredCoins;
|
|
|
|
}
|
|
|
|
|
2015-03-05 09:10:15 +01:00
|
|
|
// when starting a Masternode, this can enable to run as a hot wallet with no funds
|
2014-12-06 20:41:53 +01:00
|
|
|
bool CActiveMasternode::EnableHotColdMasterNode(CTxIn& newVin, CService& newService)
|
2014-12-09 02:17:57 +01:00
|
|
|
{
|
|
|
|
if(!fMasterNode) return false;
|
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
status = MASTERNODE_REMOTELY_ENABLED;
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2015-04-17 17:10:38 +02:00
|
|
|
//The values below are needed for signing mnping messages going forward
|
2014-12-06 20:41:53 +01:00
|
|
|
this->vin = newVin;
|
|
|
|
this->service = newService;
|
2014-12-09 02:17:57 +01:00
|
|
|
|
|
|
|
LogPrintf("CActiveMasternode::EnableHotColdMasterNode() - Enabled! You may shut down the cold daemon.\n");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|