Skip to content

Commit

Permalink
Merge pull request #46 from MrBitKoin/v2.0.0.1g-critfix
Browse files Browse the repository at this point in the history
V2.0.0.1g critfix
  • Loading branch information
nisanb committed Apr 9, 2018
2 parents 98655da + a6d3642 commit 9ed5c48
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 27 deletions.
41 changes: 29 additions & 12 deletions src/activemasternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ void CActiveMasternode::ManageStatus()

//need correct adjusted time to send ping
bool fIsInitialDownload = IsInitialBlockDownload();
if(fIsInitialDownload) {
if(fIsInitialDownload)
{
status = MASTERNODE_SYNC_IN_PROCESS;
LogPrintf("CActiveMasternode::ManageStatus() - Sync in progress. Must wait until sync is complete to start masternode.\n");
return;
Expand All @@ -31,15 +32,21 @@ void CActiveMasternode::ManageStatus()
status = MASTERNODE_NOT_PROCESSED;
}

if(status == MASTERNODE_NOT_PROCESSED) {
if(strMasterNodeAddr.empty()) {
if(!GetLocal(service)) {
if(status == MASTERNODE_NOT_PROCESSED)
{
if(strMasterNodeAddr.empty())
{
if(!GetLocal(service))
{
notCapableReason = "Can't detect external address. Please use the masternodeaddr configuration option.";
status = MASTERNODE_NOT_CAPABLE;
LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason.c_str());
return;
}
} else {

}
else
{
service = CService(strMasterNodeAddr);
}

Expand All @@ -55,15 +62,17 @@ void CActiveMasternode::ManageStatus()
*/


if(!ConnectNode((CAddress)service, service.ToString().c_str())){
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;
}


if(pwalletMain->IsLocked()){
if(pwalletMain->IsLocked())
{
notCapableReason = "Wallet is locked.";
status = MASTERNODE_NOT_CAPABLE;
LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason.c_str());
Expand All @@ -78,9 +87,11 @@ void CActiveMasternode::ManageStatus()
CPubKey pubKeyCollateralAddress;
CKey keyCollateralAddress;

if(GetMasterNodeVin(vin, pubKeyCollateralAddress, keyCollateralAddress)) {
if(GetMasterNodeVin(vin, pubKeyCollateralAddress, keyCollateralAddress))
{

if(GetInputAge(vin) < MASTERNODE_MIN_CONFIRMATIONS){
if(GetInputAge(vin) < MASTERNODE_MIN_CONFIRMATIONS)
{
LogPrintf("CActiveMasternode::ManageStatus() - Input must have least %d confirmations - %d confirmations\n", MASTERNODE_MIN_CONFIRMATIONS, GetInputAge(vin));
status = MASTERNODE_INPUT_TOO_NEW;
return;
Expand All @@ -103,20 +114,26 @@ void CActiveMasternode::ManageStatus()
return;
}

if(!Register(vin, service, keyCollateralAddress, pubKeyCollateralAddress, keyMasternode, pubKeyMasternode, errorMessage)) {
if(!Register(vin, service, keyCollateralAddress, pubKeyCollateralAddress, keyMasternode, pubKeyMasternode, errorMessage))
{
LogPrintf("CActiveMasternode::ManageStatus() - Error on Register: %s\n", errorMessage.c_str());
}

return;
} else {
}
else
{
LogPrintf("CActiveMasternode::ManageStatus() - Could not find suitable coins!\n");
}

}

//send to all peers
if(!Dseep(errorMessage)) {
if(!Dseep(errorMessage))
{
LogPrintf("CActiveMasternode::ManageStatus() - Error on Ping: %s", errorMessage.c_str());
}

}

// Send stop dseep to network for remote masternode
Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define CLIENT_VERSION_MAJOR 2
#define CLIENT_VERSION_MINOR 0
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_BUILD 0
#define CLIENT_VERSION_BUILD 1

// Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true
Expand Down
9 changes: 8 additions & 1 deletion src/darksend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2025,7 +2025,14 @@ bool CDarkSendSigner::IsVinAssociatedWithPubkey(CTxIn& vin, CPubKey& pubkey){
{
BOOST_FOREACH(CTxOut out, txVin.vout)
{
if(out.nValue == nDarkSendCollateral*COIN)
// MBK: Added some additional degugging information
if(MBK_EXTRA_DEBUG)
{
LogPrintf("CDarkSendSigner::IsVinAssociatedWithPubkey() -> nValue=%d(%s) nDarkSendCollateral=%d(%s) extra=%d\n", out.nValue, FormatMoney(out.nValue), nDarkSendCollateral, FormatMoney(nDarkSendCollateral), nDarkSendCollateral*COIN);
}

// MBK: Corrected calculation. *COIN is done in main.h and should have been removed
if(out.nValue == nDarkSendCollateral/**COIN*/)
{
if(out.scriptPubKey == payee2) return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4429,6 +4429,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
int64_t GetMasternodePayment(int nHeight, int64_t blockValue)
{
// MBK: Set masternode reward phase
int64_t ret = static_cast<int64_t>(67.33333333333333333); // ~2/3 masternode stake reward
// NOTE: Fixed the reward, now it actually is applied to blockValue
int64_t ret = static_cast<int64_t>(blockValue * 0.677777777777777777); // ~2/3 masternode stake reward
return ret;
}
29 changes: 23 additions & 6 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,27 +356,41 @@ CNode* FindNode(const CService& addr)

CNode* ConnectNode(CAddress addrConnect, const char *pszDest, bool darkSendMaster)
{
if (pszDest == NULL) {
// MBK: Added additional debug information
if(MBK_EXTRA_DEBUG)
{
LogPrintf("ConnectNode() [PreNullCheck] -> pszDest=%s darkSendMaster=%s\n", (pszDest == NULL ? "NULL" : pszDest), (darkSendMaster == true ? "True" : "False"));
}

if (pszDest == NULL)
{
if (IsLocal(addrConnect))
{
// MBK: Added additional debug information
if(MBK_EXTRA_DEBUG)
{
LogPrintf("ConnectNode() [PostNullCheck] -> IsLocal() = True\n");
}

return NULL;
}

// Look for an existing connection
CNode* pnode = FindNode((CService)addrConnect);
if (pnode)
{
if(darkSendMaster)
if(darkSendMaster)
pnode->fDarkSendMaster = true;

pnode->AddRef();
return pnode;
}

}


/// debug print
LogPrint("net", "trying connection %s lastseen=%.1fhrs\n",
pszDest ? pszDest : addrConnect.ToString(),
pszDest ? 0 : (double)(GetAdjustedTime() - addrConnect.nTime)/3600.0);
LogPrint("net", "trying connection %s lastseen=%.1fhrs\n", pszDest ? pszDest : addrConnect.ToString(), pszDest ? 0 : (double)(GetAdjustedTime() - addrConnect.nTime)/3600.0);

// Connect
SOCKET hSocket;
Expand Down Expand Up @@ -409,7 +423,9 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest, bool darkSendMaste

pnode->nTimeConnected = GetTime();
return pnode;
} else if (!proxyConnectionFailed) {
}
else if (!proxyConnectionFailed)
{
// If connecting to the node failed, and failure is not caused by a problem connecting to
// the proxy, mark this as an attempt.
addrman.Attempt(addrConnect);
Expand Down Expand Up @@ -1582,6 +1598,7 @@ bool BindListenPort(const CService &addrBind, string& strError)
LogPrintf("%s\n", strError);
return false;
}

LogPrintf("Bound to %s\n", addrBind.ToString());

// Listen for incoming connections
Expand Down
4 changes: 2 additions & 2 deletions src/rpcdarksend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ Value masternode(const Array& params, bool fHelp)
if(activeMasternode.status == MASTERNODE_INPUT_TOO_NEW) return "masternode input must have at least 15 confirmations";
if(activeMasternode.status == MASTERNODE_STOPPED) return "masternode is stopped";
if(activeMasternode.status == MASTERNODE_IS_CAPABLE) return "successfully started masternode";
if(activeMasternode.status == MASTERNODE_NOT_CAPABLE) return "not capable masternode: " + activeMasternode.notCapableReason;
if(activeMasternode.status == MASTERNODE_NOT_CAPABLE) return "not capable masternode(cmd=start): " + activeMasternode.notCapableReason;
if(activeMasternode.status == MASTERNODE_SYNC_IN_PROCESS) return "sync in process. Must wait until client is synced to start.";

return "unknown";
Expand Down Expand Up @@ -467,7 +467,7 @@ Value masternode(const Array& params, bool fHelp)
if(activeMasternode.status == MASTERNODE_INPUT_TOO_NEW) return "masternode input must have at least 15 confirmations";
if(activeMasternode.status == MASTERNODE_IS_CAPABLE) return "successfully started masternode";
if(activeMasternode.status == MASTERNODE_STOPPED) return "masternode is stopped";
if(activeMasternode.status == MASTERNODE_NOT_CAPABLE) return "not capable masternode: " + activeMasternode.notCapableReason;
if(activeMasternode.status == MASTERNODE_NOT_CAPABLE) return "not capable masternode(cmd=debug): " + activeMasternode.notCapableReason;
if(activeMasternode.status == MASTERNODE_SYNC_IN_PROCESS) return "sync in process. Must wait until client is synced to start.";

CTxIn vin = CTxIn();
Expand Down
8 changes: 4 additions & 4 deletions src/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3464,7 +3464,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
return false;

// MBK: Added some additional debug information
if (MBK_EXTRA_DEBUG) LogPrintf("CWallet::CreateCoinStake() -> [PreInputCollection] nCredit=%d", nCredit);
if (MBK_EXTRA_DEBUG) LogPrintf("CWallet::CreateCoinStake() -> [PreInputCollection] nCredit=%d\n", nCredit);

BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins)
{
Expand Down Expand Up @@ -3498,7 +3498,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
}

// MBK: Added some additional debugging information
if (MBK_EXTRA_DEBUG) LogPrintf("CWallet::CreateCoinStake() -> [AfterInputCollection] nCredit=%d", nCredit);
if (MBK_EXTRA_DEBUG) LogPrintf("CWallet::CreateCoinStake() -> [AfterInputCollection] nCredit=%d\n", nCredit);

// Calculate coin age reward
int64_t nReward;
Expand Down Expand Up @@ -3526,7 +3526,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
}

// MBK: Added some additional debugging information
if (MBK_EXTRA_DEBUG) LogPrintf("CWallet::CreateCoinStake() -> nReward=%d, nCredit=%d", nReward, nCredit);
if (MBK_EXTRA_DEBUG) LogPrintf("CWallet::CreateCoinStake() -> nReward=%d, nCredit=%d\n", nReward, nCredit);

// Masternode Payments
int payments = 1;
Expand Down Expand Up @@ -3576,7 +3576,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
int64_t masternodePayment = GetMasternodePayment(pindexPrev->nHeight+1, nReward);

// MBK: Added some additional debugging information
if (MBK_EXTRA_DEBUG) LogPrintf("CWallet::CreateCoinStake() -> blockValue=%d, masternodePayment=%d", blockValue, masternodePayment);
if (MBK_EXTRA_DEBUG) LogPrintf("CWallet::CreateCoinStake() -> blockValue=%d(%s), masternodePayment=%d(%s)\n", blockValue, FormatMoney(blockValue), masternodePayment, FormatMoney(masternodePayment));

// Set output amount
if (!hasPayment && txNew.vout.size() == 3) // 2 stake outputs, stake was split, no masternode payment
Expand Down

0 comments on commit 9ed5c48

Please sign in to comment.