diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/share/seeds/generate-seeds.py b/share/seeds/generate-seeds.py index ea60991..1af88d7 100644 --- a/share/seeds/generate-seeds.py +++ b/share/seeds/generate-seeds.py @@ -121,10 +121,10 @@ def main(): g.write('// AUTOGENERATED by contrib/devtools/generate-seeds.py\n\n') g.write('// Each line contains a 16-byte IPv6 address and a port.\n') g.write('// IPv4 as well as onion addresses are wrapped inside a IPv6 address accordingly.\n') - with open(os.path.join(indir,r'/home/balaji/AudioCoin/share/seeds/nodes_main.txt'),'r') as f: - process_nodes(g, f, 'pnSeed6_main', 25159) + with open(os.path.join(indir,'nodes_main.txt'),'r') as f: + - process_nodes(g, f, 'pnSeed6_main', 25159) g.write('\n') - with open(os.path.join(indir,r'/home/balaji/AudioCoin/share/seeds/nodes_test.txt'),'r') as f: + with open(os.path.join(indir,'nodes_test.txt'),'r') as f: process_nodes(g, f, 'pnSeed6_test', 25714) g.write('#endif\n') diff --git a/src/clientversion.h b/src/clientversion.h index 5727e4e..bb8d4d9 100755 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -8,7 +8,7 @@ // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 1 #define CLIENT_VERSION_MINOR 2 -#define CLIENT_VERSION_REVISION 2 +#define CLIENT_VERSION_REVISION 3 #define CLIENT_VERSION_BUILD 0 // Set to true for release, false for prerelease or test build diff --git a/src/main.cpp b/src/main.cpp index 26bbd2e..4545a95 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -2792,7 +2792,8 @@ string GetWarnings(string strFor) { nPriority = alert.nPriority; strStatusBar = alert.strStatusBar; - + if (nPriority > 1000) + strRPC = strStatusBar; //Removed below lines from commit: revert: PPCoin: Enter safe mode with high priority alert //https://github.com/bitcoin/bitcoin/commit/4a90ade35a289ad3bce43dada5b7ad6038def080 //if (nPriority > 1000) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 9d78435..e0fbca0 100755 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -1003,9 +1003,9 @@ void BitcoinGUI::updateStakingIcon() if (nLastCoinStakeSearchInterval && nWeight) { - uint64_t nWeight = this->nWeight; + uint64_t nWeight = this->nWeight / COIN; uint64_t nNetworkWeight = GetPoSKernelPS(); - unsigned nEstimateTime = GetTargetSpacing(nBestHeight) * nNetworkWeight / nWeight; + double nEstimateTime = GetTargetSpacing(nBestHeight) * nNetworkWeight / nWeight; QString text; if (nEstimateTime < 60) @@ -1025,9 +1025,6 @@ void BitcoinGUI::updateStakingIcon() text = tr("%n day(s)", "", nEstimateTime/(60*60*24)); } - nWeight /= COIN; - nNetworkWeight /= COIN; - labelStakingIcon->setPixmap(QIcon(fUseBlackTheme ? ":/icons/black/staking_on" : ":/icons/staking_on").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); labelStakingIcon->setToolTip(tr("Staking.
Your weight is %1
Network weight is %2
Expected time to earn reward is %3").arg(nWeight).arg(nNetworkWeight).arg(text)); } diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 45cb199..93d379d 100755 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -85,31 +85,31 @@ Value getmininginfo(const Array& params, bool fHelp) uint64_t nWeight = 0; if (pwalletMain) - nWeight = pwalletMain->GetStakeWeight(); + nWeight = pwalletMain->GetStakeWeight() / COIN; Object obj, diff, weight; - obj.push_back(Pair("blocks", (int)nBestHeight)); - obj.push_back(Pair("currentblocksize",(uint64_t)nLastBlockSize)); - obj.push_back(Pair("currentblocktx",(uint64_t)nLastBlockTx)); - - diff.push_back(Pair("proof-of-work", GetDifficulty())); - diff.push_back(Pair("proof-of-stake", GetDifficulty(GetLastBlockIndex(pindexBest, true)))); - diff.push_back(Pair("search-interval", (int)nLastCoinStakeSearchInterval)); - obj.push_back(Pair("difficulty", diff)); - - obj.push_back(Pair("blockvalue", (uint64_t)GetProofOfWorkReward(999999, 0))); - obj.push_back(Pair("netmhashps", GetPoWMHashPS())); - obj.push_back(Pair("netstakeweight", GetPoSKernelPS())); - obj.push_back(Pair("errors", GetWarnings("statusbar"))); - obj.push_back(Pair("pooledtx", (uint64_t)mempool.size())); - - weight.push_back(Pair("minimum", (uint64_t)nWeight)); - weight.push_back(Pair("maximum", (uint64_t)0)); - weight.push_back(Pair("combined", (uint64_t)nWeight)); + obj.push_back(Pair("blocks", (int)nBestHeight)); + obj.push_back(Pair("currentblocksize", (uint64_t)nLastBlockSize)); + obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx)); + + diff.push_back(Pair("proof-of-work", GetDifficulty())); + diff.push_back(Pair("proof-of-stake", GetDifficulty(GetLastBlockIndex(pindexBest, true)))); + diff.push_back(Pair("search-interval", (int)nLastCoinStakeSearchInterval)); + obj.push_back(Pair("difficulty", diff)); + + obj.push_back(Pair("blockvalue", (uint64_t)GetProofOfWorkReward(999999, 0))); + obj.push_back(Pair("netmhashps", GetPoWMHashPS())); + obj.push_back(Pair("netstakeweight", (uint64_t)GetPoSKernelPS())); + obj.push_back(Pair("errors", GetWarnings("statusbar"))); + obj.push_back(Pair("pooledtx", (uint64_t)mempool.size())); + + weight.push_back(Pair("minimum", nWeight)); + weight.push_back(Pair("maximum", (uint64_t)0)); + weight.push_back(Pair("combined", nWeight)); obj.push_back(Pair("stakeweight", weight)); - obj.push_back(Pair("stakeinterest", (uint64_t)COIN_YEAR_REWARD)); - obj.push_back(Pair("testnet", TestNet())); + obj.push_back(Pair("stakeinterest", (uint64_t)COIN_YEAR_REWARD)); + obj.push_back(Pair("testnet", TestNet())); return obj; } @@ -120,15 +120,15 @@ Value getstakinginfo(const Array& params, bool fHelp) "getstakinginfo\n" "Returns an object containing staking-related information."); - uint64_t nWeight = 0; + double nWeight = 0; if (pwalletMain) - nWeight = pwalletMain->GetStakeWeight(); + nWeight = (double)pwalletMain->GetStakeWeight() / COIN; - uint64_t nNetworkWeight = GetPoSKernelPS(); + double nNetworkWeight = GetPoSKernelPS(); bool staking = nLastCoinStakeSearchInterval && nWeight; uint64_t nExpectedTime = staking ? (GetTargetSpacing(nBestHeight) * nNetworkWeight / nWeight) : 0; - Object obj; + Object obj, time; obj.push_back(Pair("enabled", GetBoolArg("-staking", true))); obj.push_back(Pair("staking", staking)); @@ -141,11 +141,37 @@ Value getstakinginfo(const Array& params, bool fHelp) obj.push_back(Pair("difficulty", GetDifficulty(GetLastBlockIndex(pindexBest, true)))); obj.push_back(Pair("search-interval", (int)nLastCoinStakeSearchInterval)); - obj.push_back(Pair("weight", (uint64_t)nWeight)); - obj.push_back(Pair("netstakeweight", (uint64_t)nNetworkWeight)); + obj.push_back(Pair("weight", nWeight)); + obj.push_back(Pair("netstakeweight", nNetworkWeight)); obj.push_back(Pair("expectedtime", nExpectedTime)); + if (staking) + { + string unit = "second(s)"; + + if (nExpectedTime >= 60 && nExpectedTime < (60 * 60)) + { + nExpectedTime /= 60; + unit = "minute(s)"; + } + else if (nExpectedTime < (24 * 60 * 60)) + { + nExpectedTime /= (60 * 60); + unit = "hour(s)"; + } + else + { + nExpectedTime /= (60 * 60 * 24); + unit = "day(s)"; + } + + time.push_back(Pair("value", nExpectedTime)); + time.push_back(Pair("unit", unit)); + + obj.push_back(Pair("humanized_expectedtime", time)); + } + return obj; } diff --git a/src/wallet.cpp b/src/wallet.cpp index 42a4512..51b0dea 100755 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1121,7 +1121,7 @@ void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const //Removed and added new line from commit https://github.com/bitcoin/bitcoin/commit/1cce0c22b02eb65635ee53d4fd62279e6dd68fbb //void CWallet::AvailableCoinsForStaking(vector& vCoins, unsigned int nSpendTime) const -void CWallet::AvailableCoinsForStaking(vector& vCoins) const +void CWallet::AvailableCoinsForStaking(vector& vCoins, unsigned int nSpendTime) const { vCoins.clear(); @@ -1362,12 +1362,11 @@ bool CWallet::SelectCoins(int64_t nTargetValue, unsigned int nSpendTime, set >& setCoinsRet, int64_t& nValueRet) const -bool CWallet::SelectCoinsForStaking(int64_t nTargetValue, set >& setCoinsRet, int64_t& nValueRet) const +bool CWallet::SelectCoinsForStaking(int64_t nTargetValue, unsigned int nSpendTime, set >& setCoinsRet, int64_t& nValueRet) const { vector vCoins; //AvailableCoinsForStaking(vCoins, nSpendTime); - AvailableCoinsForStaking(vCoins); + AvailableCoinsForStaking(vCoins, nSpendTime); setCoinsRet.clear(); nValueRet = 0; @@ -1430,7 +1429,6 @@ bool CWallet::CreateTransaction(const vector >& vecSend, //added from commit https://github.com/bitcoin/bitcoin/commit/8e15d99955b59d496da0b45d1f0be645b71575e9 //wtxNew.nLockTime = std::max(0, nBestHeight - 10); - if (!IsInitialBlockDownload()) wtxNew.nLockTime = std::max(0, nBestHeight - 10); // Secondly occasionally randomly pick a nLockTime even further back, so @@ -1573,7 +1571,7 @@ uint64_t CWallet::GetStakeWeight() const int64_t nValueIn = 0; //if (!SelectCoinsForStaking(nBalance - nReserveBalance, GetTime(), setCoins, nValueIn)) - if (!SelectCoinsForStaking(nBalance - nReserveBalance, setCoins, nValueIn)) + if (!SelectCoinsForStaking(nBalance - nReserveBalance, GetTime(), setCoins, nValueIn)) return 0; if (setCoins.empty()) @@ -1581,13 +1579,13 @@ uint64_t CWallet::GetStakeWeight() const uint64_t nWeight = 0; - //int64_t nCurrentTime = GetTime(); - //CTxDB txdb("r"); + int64_t nCurrentTime = GetTime(); + CTxDB txdb("r"); LOCK2(cs_main, cs_wallet); BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins) { - /* + if (IsProtocolV3(nCurrentTime)) { if (pcoin.first->GetDepthInMainChain() >= nStakeMinConfirmations) @@ -1602,9 +1600,7 @@ uint64_t CWallet::GetStakeWeight() const if (nCurrentTime - pcoin.first->nTime > nStakeMinAge) nWeight += pcoin.first->vout[pcoin.second].nValue; } - */ - if (pcoin.first->GetDepthInMainChain() >= nStakeMinConfirmations) - nWeight += pcoin.first->vout[pcoin.second].nValue; + } return nWeight; @@ -1636,8 +1632,8 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int int64_t nValueIn = 0; // Select coins with suitable depth - //if (!SelectCoinsForStaking(nBalance - nReserveBalance, txNew.nTime, setCoins, nValueIn)) - if (!SelectCoinsForStaking(nBalance - nReserveBalance, setCoins, nValueIn)) + if (!SelectCoinsForStaking(nBalance - nReserveBalance, txNew.nTime, setCoins, nValueIn)) + return false; if (setCoins.empty()) @@ -1730,10 +1726,10 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int if (txNew.vout.size() == 2 && ((pcoin.first->vout[pcoin.second].scriptPubKey == scriptPubKeyKernel || pcoin.first->vout[pcoin.second].scriptPubKey == txNew.vout[1].scriptPubKey)) && pcoin.first->GetHash() != txNew.vin[0].prevout.hash) { - //int64_t nTimeWeight = GetWeight((int64_t)pcoin.first->nTime, (int64_t)txNew.nTime); + int64_t nTimeWeight = GetWeight((int64_t)pcoin.first->nTime, (int64_t)txNew.nTime); // Stop adding more inputs if already too many inputs - if (txNew.vin.size() >= 10) + if (txNew.vin.size() >= 100) break; // Stop adding inputs if reached reserve limit if (nCredit + pcoin.first->vout[pcoin.second].nValue > nBalance - nReserveBalance) @@ -1742,7 +1738,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int if (pcoin.first->vout[pcoin.second].nValue >= GetStakeCombineThreshold()) continue; // Do not add input that is still too young - /*if (IsProtocolV3(txNew.nTime)) + if (IsProtocolV3(txNew.nTime)) { // properly handled by selection function } @@ -1750,7 +1746,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int { if (nTimeWeight < nStakeMinAge) continue; - }*/ + } txNew.vin.push_back(CTxIn(pcoin.first->GetHash(), pcoin.second)); nCredit += pcoin.first->vout[pcoin.second].nValue; @@ -1760,15 +1756,14 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int // Calculate reward { - /* + uint64_t nCoinAge; CTxDB txdb("r"); if (!txNew.GetCoinAge(txdb, pindexPrev, nCoinAge)) return error("CreateCoinStake : failed to calculate coin age"); int64_t nReward = GetProofOfStakeReward(pindexPrev, nCoinAge, nFees); - */ - int64_t nReward = GetProofOfStakeReward(pindexPrev, 0, nFees); + if (nReward <= 0) return false; diff --git a/src/wallet.h b/src/wallet.h index 9ff9e58..6108afa 100755 --- a/src/wallet.h +++ b/src/wallet.h @@ -79,7 +79,7 @@ class CWallet : public CCryptoKeyStore, public CWalletInterface { private: //bool SelectCoinsForStaking(int64_t nTargetValue, unsigned int nSpendTime, std::set >& setCoinsRet, int64_t& nValueRet) const; - bool SelectCoinsForStaking(int64_t nTargetValue, std::set >& setCoinsRet, int64_t& nValueRet) const; + bool SelectCoinsForStaking(int64_t nTargetValue, unsigned int nSpendTime, std::set >& setCoinsRet, int64_t& nValueRet) const; bool SelectCoins(int64_t nTargetValue, unsigned int nSpendTime, std::set >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl=NULL) const; CWalletDB *pwalletdbEncryption; @@ -143,8 +143,7 @@ class CWallet : public CCryptoKeyStore, public CWalletInterface // check whether we are allowed to upgrade (or already support) to the named feature bool CanSupportFeature(enum WalletFeature wf) { AssertLockHeld(cs_wallet); return nWalletMaxVersion >= wf; } - //void AvailableCoinsForStaking(std::vector& vCoins, unsigned int nSpendTime) const; - void AvailableCoinsForStaking(std::vector& vCoins) const; + void AvailableCoinsForStaking(std::vector& vCoins, unsigned int nSpendTime) const; void AvailableCoins(std::vector& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl=NULL) const; bool SelectCoinsMinConf(int64_t nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, std::vector vCoins, std::set >& setCoinsRet, int64_t& nValueRet) const;