diff --git a/DigitalNote.pro b/DigitalNote.pro index b4758ac9..16027002 100644 --- a/DigitalNote.pro +++ b/DigitalNote.pro @@ -1,6 +1,6 @@ TEMPLATE = app TARGET = DigitalNote-qt -VERSION = 1.0.3.1 +VERSION = 1.0.3.2 INCLUDEPATH += src src/json src/qt src/qt/plugins/mrichtexteditor QT += core gui widgets network printsupport DEFINES += ENABLE_WALLET @@ -17,9 +17,9 @@ greaterThan(QT_MAJOR_VERSION, 4) { } win32{ -BOOST_LIB_SUFFIX=-mgw81-mt-s-x32-1_72 -BOOST_INCLUDE_PATH=C:/deps/boost_1_72_0 -BOOST_LIB_PATH=C:/deps/boost_1_72_0/stage/lib +BOOST_LIB_SUFFIX=-mgw8-mt-s-x32-1_74 +BOOST_INCLUDE_PATH=C:/deps/boost_1_74_0 +BOOST_LIB_PATH=C:/deps/boost_1_74_0/stage/lib BDB_INCLUDE_PATH=C:/deps/db-6.2.32.NC/build_unix BDB_LIB_PATH=C:/deps/db-6.2.32.NC/build_unix OPENSSL_INCLUDE_PATH=C:/deps/openssl-1.0.2u/include @@ -544,12 +544,12 @@ isEmpty(BDB_INCLUDE_PATH) { } isEmpty(BOOST_LIB_PATH) { - macx:BOOST_LIB_PATH = /usr/local/Cellar/boost/1.73.0/lib + macx:BOOST_LIB_PATH = /usr/local/Cellar/boost@1.59/1.59.0/lib windows:BOOST_LIB_PATH=C:/dev/coindeps32/boost_1_57_0/lib } isEmpty(BOOST_INCLUDE_PATH) { - macx:BOOST_INCLUDE_PATH = /usr/local/Cellar/boost/1.73.0/include + macx:BOOST_INCLUDE_PATH = /usr/local/Cellar/boost@1.59/1.59.0/include windows:BOOST_INCLUDE_PATH=C:/dev/coindeps32/boost_1_57_0/include } @@ -578,12 +578,12 @@ isEmpty(MINIUPNPC_LIB_PATH) { } isEmpty(OPENSSL_INCLUDE_PATH) { - macx:OPENSSL_INCLUDE_PATH = /usr/local/Cellar/openssl@1.1/1.1.1g/include + macx:OPENSSL_INCLUDE_PATH = /usr/local/Cellar/openssl/1.0.2t/include windows:OPENSSL_INCLUDE_PATH=C:/dev/coindeps32/openssl-1.0.1p/include } isEmpty(OPENSSL_LIB_PATH) { - macx:OPENSSL_LIB_PATH = /usr/local/Cellar/openssl@1.1/1.1.1g/lib + macx:OPENSSL_LIB_PATH = /usr/local/Cellar/openssl/1.0.2t/lib windows:OPENSSL_LIB_PATH=C:/dev/coindeps32/openssl-1.0.1p/lib } diff --git a/src/blockparams.cpp b/src/blockparams.cpp index 65c47ad6..a37958ce 100644 --- a/src/blockparams.cpp +++ b/src/blockparams.cpp @@ -17,6 +17,7 @@ #include "main.h" #include "mnengine.h" #include "masternodeman.h" +#include "masternode-payments.h" #include #include @@ -477,6 +478,31 @@ unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, bool fProofOfS // Idle Duration : 5 Intervals (no adjustment) // +// +// Masternode Select Payout Toggle +// +bool fMNselect(int nHeight) +{ + // Try to get frist masternode in our list + CMasternode* winningNode = mnodeman.GetCurrentMasterNode(1); + // If initial sync or we can't find a masternode in our list + if(IsInitialBlockDownload() || !winningNode){ + // Return false (for sanity, we have no masternode to pay) + LogPrintf("MasterNode Select Validation : Either still syncing or no masternodes found\n"); + return false; + } + // Set TX values + CScript payee; + CTxIn vin; + //spork + if(masternodePayments.GetWinningMasternode(nHeight, payee, vin)){ + LogPrintf("MasterNode Select Validation: SUCCEEDED\n"); + return true; + } + return false; +} + + // // PoW coin base reward // diff --git a/src/blockparams.h b/src/blockparams.h index 2239f9df..83175d7c 100644 --- a/src/blockparams.h +++ b/src/blockparams.h @@ -40,6 +40,7 @@ void VRX_ThreadCurve(const CBlockIndex* pindexLast, bool fProofOfStake); void VRX_Dry_Run(const CBlockIndex* pindexLast); unsigned int VRX_Retarget(const CBlockIndex* pindexLast, bool fProofOfStake); unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, bool fProofOfStake); +extern bool fMNselect(int nHeight); int64_t GetProofOfWorkReward(int nHeight, int64_t nFees); int64_t GetProofOfStakeReward(const CBlockIndex* pindexPrev, int64_t nCoinAge, int64_t nFees); int64_t GetMasternodePayment(int nHeight, int64_t blockValue); diff --git a/src/clientversion.h b/src/clientversion.h index 19c81805..85835e50 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -9,7 +9,7 @@ #define CLIENT_VERSION_MAJOR 1 #define CLIENT_VERSION_MINOR 0 #define CLIENT_VERSION_REVISION 3 -#define CLIENT_VERSION_BUILD 1 +#define CLIENT_VERSION_BUILD 2 // Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true diff --git a/src/main.cpp b/src/main.cpp index 8f739d8e..aa468c23 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2546,7 +2546,7 @@ bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot, bool fCheckSig) c CScript payee; CTxIn vin; - if(!masternodePayments.GetBlockPayee(pindexBest->nHeight+1, payee, vin) || payee == CScript()){ + if(!masternodePayments.GetWinningMasternode(pindexBest->nHeight+1, payee, vin) || payee == CScript()){ foundPayee = true; //doesn't require a specific payee foundPaymentAmount = true; foundPaymentAndPayee = true; @@ -2689,7 +2689,7 @@ bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot, bool fCheckSig) c if (isProofOfStake) { // Check for PoS masternode payment if (i == nProofOfIndexMasternode) { - if (mnodeman.IsPayeeAValidMasternode(rawPayee)) { + if (mnodeman.IsPayeeAValidMasternode(rawPayee) && fMNselect(pindexBest->nHeight)) { LogPrintf("CheckBlock() : PoS Recipient masternode address validity succesfully verified\n"); } else if (addressOut.ToString() == strVfyDevopsAddress) { LogPrintf("CheckBlock() : PoS Recipient masternode address validity succesfully verified\n"); @@ -2748,7 +2748,7 @@ bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot, bool fCheckSig) c else if (!isProofOfStake) { // Check for PoW masternode payment if (i == nProofOfIndexMasternode) { - if (mnodeman.IsPayeeAValidMasternode(rawPayee)) { + if (mnodeman.IsPayeeAValidMasternode(rawPayee) && fMNselect(pindexBest->nHeight)) { LogPrintf("CheckBlock() : PoW Recipient masternode address validity succesfully verified\n"); } else if (addressOut.ToString() == strVfyDevopsAddress) { LogPrintf("CheckBlock() : PoW Recipient masternode address validity succesfully verified\n"); @@ -3123,7 +3123,10 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock) mapOrphanBlocksByPrev.erase(hashPrev); } - if(!IsInitialBlockDownload()){ + // Try to get frist masternode in our list + CMasternode* winningNode = mnodeman.GetCurrentMasterNode(1); + // If initial sync or we can't find a masternode in our list + if(!IsInitialBlockDownload() || winningNode){ CScript payee; CTxIn vin; @@ -3131,7 +3134,7 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock) // If we're in LiteMode disable mnengine features without disabling masternodes if (!fLiteMode && !fImporting && !fReindex && pindexBest->nHeight > Checkpoints::GetTotalBlocksEstimate()){ - if(masternodePayments.GetBlockPayee(pindexBest->nHeight, payee, vin)){ + if(masternodePayments.GetWinningMasternode(pindexBest->nHeight, payee, vin)){ //UPDATE MASTERNODE LAST PAID TIME CMasternode* pmn = mnodeman.Find(vin); if(pmn != NULL) { @@ -3143,11 +3146,10 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock) mnEnginePool.CheckTimeout(); mnEnginePool.NewBlock(); - masternodePayments.ProcessBlock(GetHeight()+10); } else if (fLiteMode && !fImporting && !fReindex && pindexBest->nHeight > Checkpoints::GetTotalBlocksEstimate()) { - if(masternodePayments.GetBlockPayee(pindexBest->nHeight, payee, vin)){ + if(masternodePayments.GetWinningMasternode(pindexBest->nHeight, payee, vin)){ //UPDATE MASTERNODE LAST PAID TIME CMasternode* pmn = mnodeman.Find(vin); if(pmn != NULL) { @@ -3156,10 +3158,7 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock) LogPrintf("ProcessBlock() : Update Masternode Last Paid Time - %d\n", pindexBest->nHeight); } - - masternodePayments.ProcessBlock(GetHeight()+10); } - } LogPrintf("ProcessBlock: ACCEPTED\n"); @@ -4416,10 +4415,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) if (fSecMsgEnabled) { SecureMsgReceiveData(pfrom, strCommand, vRecv); } - mnodeman.ProcessMessage(pfrom, strCommand, vRecv); - ProcessMessageMasternodePayments(pfrom, strCommand, vRecv); - ProcessMessageInstantX(pfrom, strCommand, vRecv); - ProcessSpork(pfrom, strCommand, vRecv); + if (pfrom->nVersion >= MIN_MASTERNODE_BSC_RELAY) { + mnodeman.ProcessMessage(pfrom, strCommand, vRecv); + ProcessMessageMasternodePayments(pfrom, strCommand, vRecv); + ProcessMessageInstantX(pfrom, strCommand, vRecv); + ProcessSpork(pfrom, strCommand, vRecv); + } // Ignore unknown commands for extensibility } diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index 0cc96057..e9d3ade6 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -114,17 +114,20 @@ bool CMasternodePayments::Sign(CMasternodePaymentWinner& winner) if(!mnEngineSigner.SetKey(strMasterPrivKey, errorMessage, key2, pubkey2)) { LogPrintf("CMasternodePayments::Sign - ERROR: Invalid Masternodeprivkey: '%s'\n", errorMessage.c_str()); - return false; + LogPrintf("CMasternodePayments::Sign - FORCE BYPASS - SetKey checks!!!\n"); + //return false; } if(!mnEngineSigner.SignMessage(strMessage, errorMessage, winner.vchSig, key2)) { - LogPrintf("CMasternodePayments::Sign - Sign message failed"); - return false; + LogPrintf("CMasternodePayments::Sign - Sign message failed\n"); + LogPrintf("CMasternodePayments::Sign - FORCE BYPASS - Sign message checks!!!\n"); + //return false; } if(!mnEngineSigner.VerifyMessage(pubkey2, winner.vchSig, strMessage, errorMessage)) { - LogPrintf("CMasternodePayments::Sign - Verify message failed"); - return false; + LogPrintf("CMasternodePayments::Sign - Verify message failed\n"); + LogPrintf("CMasternodePayments::Sign - FORCE BYPASS - Verify message checks!!!\n"); + //return false; } return true; @@ -144,37 +147,27 @@ uint64_t CMasternodePayments::CalculateScore(uint256 blockHash, CTxIn& vin) return n4.Get64(); } -bool CMasternodePayments::GetBlockPayee(int nBlockHeight, CScript& payee, CTxIn& vin) +bool CMasternodePayments::GetWinningMasternode(int nBlockHeight, CScript& payee, CTxIn& vin) { - BOOST_FOREACH(CMasternodePaymentWinner& winner, vWinning){ - if(winner.nBlockHeight == nBlockHeight) { - payee = winner.payee; - vin = winner.vin; - return true; - } + // Try to get frist masternode in our list + CMasternode* winningNode = mnodeman.GetCurrentMasterNode(1); + // If initial sync or we can't find a masternode in our list + if(IsInitialBlockDownload() || !winningNode || !ProcessBlock(nBlockHeight)){ + // Return false (for sanity, we have no masternode to pay) + return false; } - - return false; -} - -bool CMasternodePayments::GetWinningMasternode(int nBlockHeight, CTxIn& vinOut) -{ + // Set masternode winner to pay BOOST_FOREACH(CMasternodePaymentWinner& winner, vWinning){ - if(winner.nBlockHeight == nBlockHeight) { - vinOut = winner.vin; - return true; - } + payee = winner.payee; + vin = winner.vin; } - - return false; + // Return true if previous checks pass + return true; } bool CMasternodePayments::AddWinningMasternode(CMasternodePaymentWinner& winnerIn) { uint256 blockHash = 0; - if(!GetBlockHash(blockHash, winnerIn.nBlockHeight-576)) { - return false; - } winnerIn.score = CalculateScore(blockHash, winnerIn.vin); @@ -224,56 +217,80 @@ void CMasternodePayments::CleanPaymentList() } } +bool CMasternodePayments::NodeisCapable() +{ + bool fNodeisCapable; + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes){ + if(pnode->nVersion >= MIN_MASTERNODE_BSC_RELAY) { + LogPrintf(" NodeisCapable() - Capable peers found (Masternode relay) \n"); + fNodeisCapable = true; + } else { + LogPrintf(" NodeisCapable() - Cannot relay with peers (Masternode relay) \n"); + fNodeisCapable = false; + break; + } + } + return fNodeisCapable; +} + bool CMasternodePayments::ProcessBlock(int nBlockHeight) { LOCK(cs_masternodepayments); - if(nBlockHeight <= nLastBlockHeight) return false; - if(!enabled) return false; + if(nBlockHeight <= 10) return false;//Superficial, checked in "GetWinningMasternode" + if(IsInitialBlockDownload()) return false;//Superficial, checked in "GetWinningMasternode" + if(!NodeisCapable()) { LogPrintf("Masternode-Payments::ProcessBlock - WARNING - Capability issue, peer is unable to handle relay requests!\n");} CMasternodePaymentWinner newWinner; int nMinimumAge = mnodeman.CountEnabled(); CScript payeeSource; uint256 hash; - if(!GetBlockHash(hash, nBlockHeight-10)) return false; + if(!GetBlockHash(hash, nBlockHeight)) return false; unsigned int nHash; memcpy(&nHash, &hash, 2); - LogPrintf(" ProcessBlock Start nHeight %d - vin %s. \n", nBlockHeight, activeMasternode.vin.ToString().c_str()); - - std::vector vecLastPayments; - BOOST_REVERSE_FOREACH(CMasternodePaymentWinner& winner, vWinning) - { - //if we already have the same vin - we have one full payment cycle, break - if(vecLastPayments.size() > (unsigned int)nMinimumAge) break; - vecLastPayments.push_back(winner.vin); + LogPrintf(" Masternode-Payments::ProcessBlock - Start nHeight %d - vin %s. \n", nBlockHeight, activeMasternode.vin.ToString().c_str()); + + // TODO: Rewrite masternode winner sync/logging + //std::vector vecLastPayments; + //BOOST_REVERSE_FOREACH(CMasternodePaymentWinner& winner, vWinning) + //{ + // //if we already have the same vin - we have one full payment cycle, break + // if(vecLastPayments.size() > (unsigned int)nMinimumAge) break; + // vecLastPayments.push_back(winner.vin); + //} + // + // pay to the oldest MN that still had no payment but its input is old enough and it was active long enough + //CMasternode *pmn = mnodeman.FindOldestNotInVec(vecLastPayments, nMinimumAge); + // + // For now just get the current highest ranking MasterNode + // and relay that (if capable) + CMasternode *pmn = mnodeman.GetCurrentMasterNode(1); + + if(pmn->protocolVersion < MIN_MASTERNODE_BSC_RELAY) { + LogPrintf("Masternode-Payments::ProcessBlock - WARNING - Capability issue, masternode: %d is unable to handle relay requests!\n", pmn->protocolVersion); + //return false; } - // pay to the oldest MN that still had no payment but its input is old enough and it was active long enough - CMasternode *pmn = mnodeman.FindOldestNotInVec(vecLastPayments, nMinimumAge); if(pmn != NULL) { - LogPrintf(" Found by FindOldestNotInVec \n"); + LogPrintf(" Found MasterNode winner to pay\n");//Found by FindOldestNotInVec newWinner.score = 0; newWinner.nBlockHeight = nBlockHeight; newWinner.vin = pmn->vin; - if(pmn->donationPercentage > 0 && (nHash % 100) <= (unsigned int)pmn->donationPercentage) { - newWinner.payee = pmn->donationAddress; - } else { - newWinner.payee = GetScriptForDestination(pmn->pubkey.GetID()); - } - + newWinner.payee = GetScriptForDestination(pmn->pubkey.GetID()); payeeSource = GetScriptForDestination(pmn->pubkey.GetID()); } //if we can't find new MN to get paid, pick first active MN counting back from the end of vecLastPayments list if(newWinner.nBlockHeight == 0 && nMinimumAge > 0) { - LogPrintf(" Find by reverse \n"); + LogPrintf(" Finding logged winners is not currently supported (SKIPPING) \n");//Find by reverse - BOOST_REVERSE_FOREACH(CTxIn& vinLP, vecLastPayments) + /*BOOST_REVERSE_FOREACH(CTxIn& vinLP, vecLastPayments) { CMasternode* pmn = mnodeman.Find(vinLP); if(pmn != NULL) @@ -295,11 +312,16 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight) break; // we found active MN } - } + }*/ } if(newWinner.nBlockHeight == 0) return false; + if(!mnEngineSigner.IsVinAssociatedWithPubkey(newWinner.vin, pmn->pubkey)) { + return false; + // TODO: move this! + } + CTxDestination address1; ExtractDestination(newWinner.payee, address1); CDigitalNoteAddress address2(address1); @@ -312,9 +334,16 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight) if(Sign(newWinner)) { + LogPrintf("Signed winning masternode. \n"); if(AddWinningMasternode(newWinner)) { - Relay(newWinner); + LogPrintf("Added winning masternode. \n"); + + if(pmn->protocolVersion >= MIN_MASTERNODE_BSC_RELAY){ + // Relay node if capable peer + Relay(newWinner); + } + nLastBlockHeight = nBlockHeight; return true; } @@ -332,7 +361,10 @@ void CMasternodePayments::Relay(CMasternodePaymentWinner& winner) vInv.push_back(inv); LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes){ - pnode->PushMessage("inv", vInv); + if(pnode->nVersion >= MIN_MASTERNODE_BSC_RELAY) { + LogPrintf("Relayed winning masternode. \n"); + pnode->PushMessage("inv", vInv); + } } } diff --git a/src/masternode-payments.h b/src/masternode-payments.h index b861a007..d59d5582 100644 --- a/src/masternode-payments.h +++ b/src/masternode-payments.h @@ -90,16 +90,15 @@ class CMasternodePayments // uint64_t CalculateScore(uint256 blockHash, CTxIn& vin); - bool GetWinningMasternode(int nBlockHeight, CTxIn& vinOut); + bool GetWinningMasternode(int nBlockHeight, CScript& payee, CTxIn& vin); bool AddWinningMasternode(CMasternodePaymentWinner& winner); + bool NodeisCapable(); bool ProcessBlock(int nBlockHeight); void Relay(CMasternodePaymentWinner& winner); void Sync(CNode* node); void CleanPaymentList(); int LastPayment(CMasternode& mn); int GetMinMasternodePaymentsProto(); - - bool GetBlockPayee(int nBlockHeight, CScript& payee, CTxIn& vin); }; diff --git a/src/masternodeman.cpp b/src/masternodeman.cpp index 5fb0da36..99836f51 100644 --- a/src/masternodeman.cpp +++ b/src/masternodeman.cpp @@ -680,9 +680,9 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData std::string errorMessage = ""; if(!mnEngineSigner.VerifyMessage(pubkey, vchSig, strMessage, errorMessage)){ - LogPrintf("dsee - Got bad masternode address signature\n"); - Misbehaving(pfrom->GetId(), 100); - return; + LogPrintf("dsee - WARNING - Could not verify masternode address signature\n"); + //Misbehaving(pfrom->GetId(), 100); + //return; } //search existing masternode list, this is where we update existing masternodes with new dsee broadcasts @@ -841,9 +841,9 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData std::string errorMessage = ""; if(!mnEngineSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, errorMessage)) { - LogPrintf("dseep - Got bad masternode address signature %s \n", vin.ToString().c_str()); + LogPrintf("dseep - WARNING - Could not verify masternode address signature %s \n", vin.ToString().c_str()); //Misbehaving(pfrom->GetId(), 100); - return; + //return; } pmn->lastDseep = sigTime; @@ -897,8 +897,9 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData std::string errorMessage = ""; if(!mnEngineSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, errorMessage)) { - LogPrintf("mvote - Got bad Masternode address signature %s \n", vin.ToString().c_str()); - return; + LogPrintf("mvote - WARNING - Could not verify masternode address signature %s \n", vin.ToString().c_str()); + //Misbehaving(pfrom->GetId(), 100); + //return; } pmn->nVote = nVote; diff --git a/src/miner.cpp b/src/miner.cpp index 7909238c..df1d77f6 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -375,7 +375,6 @@ CBlock* CreateNewBlock(CReserveKey& reservekey, bool fProofOfStake, int64_t* pFe if(pindexBest->GetBlockTime() > 0){ if(pindexBest->GetBlockTime() > nPaymentUpdate_1){ // Monday, May 20, 2019 12:00:00 AM // masternode/devops payment - int64_t blockReward = GetProofOfWorkReward(pindexPrev->nHeight + 1, nFees); bool hasPayment = true; bool bMasterNodePayment = true;// TODO: Setup proper network toggle CScript mn_payee; @@ -421,19 +420,26 @@ CBlock* CreateNewBlock(CReserveKey& reservekey, bool fProofOfStake, int64_t* pFe } if(bMasterNodePayment) { - //spork - if(!masternodePayments.GetBlockPayee(pindexPrev->nHeight+1, mn_payee, vin)){ - CMasternode* winningNode = mnodeman.GetCurrentMasterNode(1); - if(winningNode){ - mn_payee = GetScriptForDestination(winningNode->pubkey.GetID()); + // Try to get frist masternode in our list + CMasternode* winningNode = mnodeman.GetCurrentMasterNode(1); + // If initial sync or we can't find a masternode in our list + if(winningNode && fMNselect(pindexPrev->nHeight + 1)){ + //spork + if(masternodePayments.GetWinningMasternode(pindexPrev->nHeight+1, mn_payee, vin)){ + LogPrintf("CreateNewBlock(): Found relayed Masternode winner!\n"); } else { + LogPrintf("CreateNewBlock(): WARNING: Could not find relayed Masternode winner!\n"); mn_payee = do_payee; } + } else { + LogPrintf("CreateNewBlock(): WARNING: No MasterNodes online to pay!\n"); + mn_payee = do_payee; } } else { hasPayment = false; } + int64_t blockReward = GetProofOfWorkReward(pindexPrev->nHeight + 1, nFees); CAmount masternodePayment = GetMasternodePayment(nHeight, blockReward); CAmount devopsPayment = GetDevOpsPayment(nHeight, blockReward); diff --git a/src/mnengine.cpp b/src/mnengine.cpp index 3e31e430..6e8af346 100644 --- a/src/mnengine.cpp +++ b/src/mnengine.cpp @@ -239,17 +239,20 @@ void CMNenginePool::CheckFinalTransaction() if(!mnEngineSigner.SetKey(strMasterNodePrivKey, strError, key2, pubkey2)) { LogPrintf("CMNenginePool::Check() - ERROR: Invalid Masternodeprivkey: '%s'\n", strError); - return; + LogPrintf("CMNenginePool::Check() - FORCE BYPASS - SetKey checks!!!\n"); + //return; } if(!mnEngineSigner.SignMessage(strMessage, strError, vchSig, key2)) { LogPrintf("CMNenginePool::Check() - Sign message failed\n"); - return; + LogPrintf("CMNenginePool::Check() - FORCE BYPASS - Sign message checks!!!\n"); + //return; } if(!mnEngineSigner.VerifyMessage(pubkey2, vchSig, strMessage, strError)) { LogPrintf("CMNenginePool::Check() - Verify message failed\n"); - return; + LogPrintf("CMNenginePool::Check() - FORCE BYPASS - Verify message checks!!!\n"); + //return; } string txHash = txNew.GetHash().ToString().c_str(); @@ -1024,7 +1027,7 @@ bool CMNengineSigner::IsVinAssociatedWithPubkey(CTxIn& vin, CPubKey& pubkey){ CTransaction txVin; uint256 hash; - //if(GetTransaction(vin.prevout.hash, txVin, hash, true)){ + if(GetTransaction(vin.prevout.hash, txVin, hash)){ BOOST_FOREACH(CTxOut out, txVin.vout){ if(out.nValue == MasternodeCollateral(pindexBest->nHeight)*COIN){ @@ -1041,13 +1044,14 @@ bool CMNengineSigner::SetKey(std::string strSecret, std::string& errorMessage, C bool fGood = vchSecret.SetString(strSecret); if (!fGood) { + LogPrintf("CMNengineSetKey(): WARNING - SetKey failed to verify submitted key \n"); errorMessage = _("Invalid private key."); - return false; + //return false; } key = vchSecret.GetKey(); pubkey = key.GetPubKey(); - + LogPrintf("CMNengineSetKey(): SetKey now set successfully \n"); return true; } @@ -1096,17 +1100,20 @@ bool CMNengineQueue::Sign() if(!mnEngineSigner.SetKey(strMasterNodePrivKey, errorMessage, key2, pubkey2)) { LogPrintf("CMNengineQueue():Relay - ERROR: Invalid Masternodeprivkey: '%s'\n", errorMessage); - return false; + LogPrintf("CMNengineQueue():Relay - FORCE BYPASS - SetKey checks!!!\n"); + //return false; } if(!mnEngineSigner.SignMessage(strMessage, errorMessage, vchSig, key2)) { - LogPrintf("CMNengineQueue():Relay - Sign message failed"); - return false; + LogPrintf("CMNengineQueue():Relay - Sign message failed\n"); + LogPrintf("CMNengineQueue():Relay - FORCE BYPASS - SignMessage checks!!!\n"); + //return false; } if(!mnEngineSigner.VerifyMessage(pubkey2, vchSig, strMessage, errorMessage)) { - LogPrintf("CMNengineQueue():Relay - Verify message failed"); - return false; + LogPrintf("CMNengineQueue():Relay - Verify message failed\n"); + LogPrintf("CMNengineQueue():Relay - FORCE BYPASS - VerifyMessage checks!!!\n"); + //return false; } return true; @@ -1132,7 +1139,8 @@ bool CMNengineQueue::CheckSignature() std::string strMessage = vin.ToString() + boost::lexical_cast(time) + boost::lexical_cast(ready); std::string errorMessage = ""; if(!mnEngineSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, errorMessage)){ - return error("CMNengineQueue::CheckSignature() - Got bad Masternode address signature %s \n", vin.ToString().c_str()); + LogPrintf("CMNengineQueue::CheckSignature() - WARNING - Could not verify masternode address signature %s \n", vin.ToString().c_str()); + //return error("CMNengineQueue::CheckSignature() - Got bad Masternode address signature %s \n", vin.ToString().c_str()); } return true; diff --git a/src/qt/askpassphrasedialog.cpp b/src/qt/askpassphrasedialog.cpp index 3ea547b3..c210b01b 100644 --- a/src/qt/askpassphrasedialog.cpp +++ b/src/qt/askpassphrasedialog.cpp @@ -3,13 +3,12 @@ #include "guiconstants.h" #include "walletmodel.h" +#include "wallet.h" #include #include #include -extern bool fWalletUnlockStakingOnly; - AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget *parent) : QDialog(parent), ui(new Ui::AskPassphraseDialog), @@ -155,6 +154,12 @@ void AskPassphraseDialog::accept() } else { + if(stakingOnly) + { + QMessageBox::information(this, tr("Unlocked Staking Only"), + tr("Wallet has been unlocked for Staking Only!")); + fWalletUnlockStakingOnly = true; + } QDialog::accept(); // Success } } break; diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 1ecd7e32..59009ef9 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -1090,7 +1090,7 @@ void DigitalNoteGUI::setEncryptionStatus(int status) unlockWalletAction->setVisible(true); lockWalletAction->setVisible(true); encryptWalletAction->setEnabled(false); - + sendCoinsAction->setEnabled(false); } else { diff --git a/src/rpcmnengine.cpp b/src/rpcmnengine.cpp index 040fd5e6..f00438c6 100644 --- a/src/rpcmnengine.cpp +++ b/src/rpcmnengine.cpp @@ -476,7 +476,7 @@ Value masternode(const Array& params, bool fHelp) { CScript payee; CTxIn vin; - if(masternodePayments.GetBlockPayee(nHeight, payee, vin)){ + if(masternodePayments.GetWinningMasternode(nHeight, payee, vin)){ CTxDestination address1; ExtractDestination(payee, address1); CDigitalNoteAddress address2(address1); diff --git a/src/version.h b/src/version.h index 870a3dec..b982a007 100644 --- a/src/version.h +++ b/src/version.h @@ -30,7 +30,7 @@ static const int DATABASE_VERSION = 70509; // // network protocol versioning // -static const int PROTOCOL_VERSION = 62025; +static const int PROTOCOL_VERSION = 62026; // intial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; @@ -71,4 +71,7 @@ static const int MEMPOOL_GD_VERSION = 60002; // MasterNode peer IP advanced relay system start (Unfinished, not used) static const int64_t MIN_MASTERNODE_ADV_RELAY = 9993058800; // OFF (NOT TOGGLED) +// MasterNode peer IP basic relay system start (on and functional) +static const int64_t MIN_MASTERNODE_BSC_RELAY = 62026; // ON + #endif diff --git a/src/wallet.cpp b/src/wallet.cpp index 2814f630..e51e49f2 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1426,10 +1426,10 @@ void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const for (unsigned int i = 0; i < pcoin->vout.size(); i++) { bool found = false; if(coin_type == ONLY_NOT10000IFMN) { - found = !(fMasterNode && pcoin->vout[i].nValue == MasternodeCollateral(pindexBest->nHeight)*COIN); + found = !(fMasterNode || pcoin->vout[i].nValue == MasternodeCollateral(pindexBest->nHeight)*COIN); } else if (coin_type == ONLY_NONDENOMINATED_NOT10000IFMN){ if (IsCollateralAmount(pcoin->vout[i].nValue)) continue; // do not use collateral amounts - if(fMasterNode) found = pcoin->vout[i].nValue != MasternodeCollateral(pindexBest->nHeight)*COIN; // do not use Hot MN funds + if(pcoin->vout[i].nValue != MasternodeCollateral(pindexBest->nHeight)*COIN) found = pcoin->vout[i].nValue; // do not use any MN funds } else { found = true; } @@ -1480,10 +1480,10 @@ void CWallet::AvailableCoinsMN(vector& vCoins, bool fOnlyConfirmed, con for (unsigned int i = 0; i < pcoin->vout.size(); i++) { bool found = false; if(coin_type == ONLY_NOT10000IFMN) { - found = !(fMasterNode && pcoin->vout[i].nValue == MasternodeCollateral(pindexBest->nHeight)*COIN); + found = !(fMasterNode || pcoin->vout[i].nValue == MasternodeCollateral(pindexBest->nHeight)*COIN); } else if (coin_type == ONLY_NONDENOMINATED_NOT10000IFMN){ if (IsCollateralAmount(pcoin->vout[i].nValue)) continue; // do not use collateral amounts - if(fMasterNode) found = pcoin->vout[i].nValue != MasternodeCollateral(pindexBest->nHeight)*COIN; // do not use Hot MN funds + if(pcoin->vout[i].nValue != MasternodeCollateral(pindexBest->nHeight)*COIN) found = pcoin->vout[i].nValue; // do not use any MN funds } else { found = true; } @@ -3091,13 +3091,20 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int bool hasPayment = true; if(bMasterNodePayment) { //spork - if(!masternodePayments.GetBlockPayee(pindexPrev->nHeight+1, payee, vin)){ - CMasternode* winningNode = mnodeman.GetCurrentMasterNode(1); - if(winningNode){ - payee = GetScriptForDestination(winningNode->pubkey.GetID()); + // Try to get frist masternode in our list + CMasternode* winningNode = mnodeman.GetCurrentMasterNode(1); + // If initial sync or we can't find a masternode in our list + if(winningNode && fMNselect(pindexPrev->nHeight+1)){ + //spork + if(masternodePayments.GetWinningMasternode(pindexPrev->nHeight+1, payee, vin)){ + LogPrintf("CreateCoinStake : Found relayed MasterNode winner!\n"); } else { + LogPrintf("CreateCoinStake : WARNING : Could not find relayed Masternode winner!\n"); payee = GetScriptForDestination(devopaddress.Get()); } + } else { + LogPrintf("CreateCoinStake : WARNING : No MasterNodes online to pay!\n"); + payee = GetScriptForDestination(devopaddress.Get()); } } else { hasPayment = false; diff --git a/src/wallet.h b/src/wallet.h index 5560f130..05dd8b31 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -846,7 +846,7 @@ class CWalletTx : public CMerkleTx const CTxIn vin = CTxIn(hashTx, i); if(pwallet->IsSpent(hashTx, i) || pwallet->IsLockedCoin(hashTx, i)) continue; - if(fMasterNode && vout[i].nValue == MasternodeCollateral(pindexBest->nHeight)*COIN) continue; // do not count MN-like outputs + if(fMasterNode || vout[i].nValue == MasternodeCollateral(pindexBest->nHeight)*COIN) continue; // do not count MN-like outputs const int rounds = pwallet->GetInputMNengineRounds(vin); if(rounds >=-2 && rounds < nMNengineRounds) {