diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0c4513a --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +/.idea +/.vs/ProjectSettings.json +/.vs/slnx.sqlite +/.vs/CCB/v15/Browse.VC.db +/.vs/CCB/v15/Browse.VC.opendb +.vs/CCB/v15/.suo +.vs/CCB/v15/ipch/AutoPCH/db8ae34deaeda3c4/VERSION_EDIT.ipch +.vs/VSWorkspaceState.json +.vs/slnx.sqlite-journal diff --git a/README.md b/README.md index bab199b..31ca476 100644 --- a/README.md +++ b/README.md @@ -1 +1,57 @@ -Visit our website at [ccb.cash](http://ccb.cash/) +![logo](https://ccbcoin.club/img/assets/logo.png) + +Visit our website at [ccb.cash](http://ccb.cash/) ***NEW SITE IN DEVELOPMENT*** + +View the CryptoCashBack [Explorer](http://chain.ccbcoin.club/) + +### Coin Specs + + + + + + +
AlgoQuark
Block Time60 Seconds
Difficulty RetargetingEvery Block
Max Coin Supply 100,000,000 SMRTC
Premine10,000,000 SMRTC
+ + +### Reward Distribution Per Block + + + + + + + + + + + + + + + + +
PoW Phase
Block HeightReward AmountNotesDuration (Days)
0250 CCBGenesis Block0 Days
110,000,000 CCBInitial Premine0 Days
2-20030 CCBClosed Mining1 Days
PoS / MN Phase
201-250001 CCBCoin Swap17.2 Days
25000-5000025 CCBFirst Increase 17.3 Days
50000-7500050 CCBSecond Increase 17.3 Days
75000-100000100 CCBFinal Increase 17.3 Days
100000-12500075 CCBFirst Reduction 17.3 Days
125000-15000050 CCBSecond Reduction 17.3 Days
150000-Infinite25 CCBFinal Reduction 17.3 Days
+ + +### Masternode Rewards Per Block, 10,000 CCB Collateral + + + + + + + + + + + + + + + + + + + +
Block HeightReward AmountDuration (Days)Development Fee
201-2500080%17.2 Days0%
25000-60000 40%17.22 Days0%
60000-65000 42%3.47 Days0%
65000-70000 44%3.47 Days0%
70000-75000 46%3.47 Days10K Initial Dev Fee Then 10% Every Block
75000-80000 48%3.47 Days10%
80000-85000 50%2.08 Days10%
85000-88000 53%2.08 Days10%
88000-91000 56%2.08 Days10%
91000-94000 59%2.08 Days10%
94000-97000 62%2.08 Days10%
97000-100000 65%2.08 Days10%
100000-125000 70%17.36 Days10%
125000-150000 75%17.36 Days10%
150000-175000 80%17.36 Days10%
SeeSaw Rewards from this point on
diff --git a/configure.ac b/configure.ac index 769cc33..5542d30 100755 --- a/configure.ac +++ b/configure.ac @@ -1,9 +1,9 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N) AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 1) -define(_CLIENT_VERSION_MINOR, 0) +define(_CLIENT_VERSION_MINOR, 1) define(_CLIENT_VERSION_REVISION, 0) -define(_CLIENT_VERSION_BUILD, 1) +define(_CLIENT_VERSION_BUILD, 0) define(_CLIENT_VERSION_IS_RELEASE, true) define(_COPYRIGHT_YEAR, 2018) AC_INIT([CryptoCashBack Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[http://bit.cryptocashbacks],[cryptocashback]) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index d7e44b4..6900ff3 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -7,13 +7,12 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "chainparams.h" - #include "random.h" #include "util.h" #include "utilstrencodings.h" - #include - +#include "net.h" +#include "base58.h" #include @@ -87,6 +86,7 @@ class CMainParams : public CChainParams CMainParams() { networkID = CBaseChainParams::MAIN; + vTreasuryRewardAddress = ""; //Need to circle back to add dev address strNetworkID = "main"; /** * The message start string is designed to be unlikely to occur in normal data. @@ -106,14 +106,14 @@ class CMainParams : public CChainParams nRejectBlockOutdatedMajority = 950; nToCheckBlockUpgradeMajority = 1000; nMinerThreads = 0; - nTargetTimespan = 1 * 60; - nTargetSpacing = 1 * 60; - nLastPOWBlock = 500; - nMaturity = 151; + nTargetTimespan = 1 * 60; //1 Hour + nTargetSpacing = 1 * 60; //1 Hour + nLastPOWBlock = 200; //Changed from old 500 to new premine PoW stage + nMaturity = 60; //60 conf to be able to stake = 1hr nMasternodeCountDrift = 20; - nMasternodeColleteralLimxDev = 5000; //Params().MasternodeColleteralLimxDev() + nMasternodeColleteralLimxDev = 10000; //Params().MasternodeColleteralLimxDev() nModifierUpdateBlock = 1; // we use the version 2 for dmd - nMaxMoneyOut = 50000000 * COIN; + nMaxMoneyOut = 100000000 * COIN; //100,000,00 max supply const char* pszTimestamp = "CryptoCashBack cryptocurrency"; CMutableTransaction txNew; @@ -129,16 +129,16 @@ class CMainParams : public CChainParams genesis.nTime = 1525929087; genesis.nBits = 0x1e0ffff0; genesis.nNonce = 21334304; - + hashGenesisBlock = genesis.GetHash(); - //printf("%s\n", hashGenesisBlock.ToString().c_str()); - //printf("%s\n", genesis.hashMerkleRoot.ToString().c_str()); + //printf("%s\n", hashGenesisBlock.ToString().c_str()); + //printf("%s\n", genesis.hashMerkleRoot.ToString().c_str()); assert(hashGenesisBlock == uint256("0x00000a49ec81e566b6013e403ef710dae79742be34c920ec6ace4e0897879c7f")); assert(genesis.hashMerkleRoot == uint256("0x81b81664271f0942a2868283a1f658425b5a0de3d41161a8836ccf066108af49")); - vSeeds.push_back(CDNSSeedData("node1.ccb.cash", "node1.ccb.cash")); - vSeeds.push_back(CDNSSeedData("node2.ccb.cash", "node2.ccb.cash")); + vSeeds.push_back(CDNSSeedData("n1.ccbcoin.club", "n1.ccbcoin.club")); + vSeeds.push_back(CDNSSeedData("n2.ccbcoin.club", "n2.ccbcoin.club")); //vFixedSeeds.clear(); //vSeeds.clear(); @@ -174,6 +174,22 @@ class CMainParams : public CChainParams return data; } }; + +std::string CChainParams::GetTreasuryRewardAddressAtHeight(int nHeight) const +{ + return vTreasuryRewardAddress; + +} + + CScript CChainParams::GetTreasuryRewardScriptAtHeight(int nHeight) const +{ + CBitcoinAddress address(GetTreasuryRewardAddressAtHeight(nHeight).c_str()); + assert(address.IsValid()); + CScript script = GetScriptForDestination(address.Get()); + return script; + +} + static CMainParams mainParams; /** diff --git a/src/chainparams.h b/src/chainparams.h index c207574..a390e91 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -96,6 +96,11 @@ class CChainParams int64_t StartMasternodePayments() const { return nStartMasternodePayments; } CBaseChainParams::Network NetworkID() const { return networkID; } + std::string vTreasuryRewardAddress; + + std::string GetTreasuryRewardAddressAtHeight(int height) const; + CScript GetTreasuryRewardScriptAtHeight(int height) const; + protected: CChainParams() {} diff --git a/src/clientversion.h b/src/clientversion.h index efaff4f..452d71f 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -14,10 +14,10 @@ */ //! These need to be macros, as clientversion.cpp's and cryptocashback*-res.rc's voodoo requires it -#define CLIENT_VERSION_MAJOR 1 +#define CLIENT_VERSION_MAJOR 2 #define CLIENT_VERSION_MINOR 0 #define CLIENT_VERSION_REVISION 0 -#define CLIENT_VERSION_BUILD 1 +#define CLIENT_VERSION_BUILD 0 //Beta Test Wallet //bitcoingui.cpp L116 //! Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true @@ -38,7 +38,7 @@ #define DO_STRINGIZE(X) #X //! Copyright string used in Windows .rc files -#define COPYRIGHT_STR "2009-" STRINGIZE(COPYRIGHT_YEAR) " The Bitcoin Core Developers, 2014-" STRINGIZE(COPYRIGHT_YEAR) " The Dash and PIVX Core Developers, 2018-" STRINGIZE(COPYRIGHT_YEAR) " The CryptoCashBack Core Developers" +#define COPYRIGHT_STR "2009-" STRINGIZE(COPYRIGHT_YEAR) " The Bitcoin Core Developers, 2014-" STRINGIZE(COPYRIGHT_YEAR) " The Dash and PIVX Core Developers, 2018-" STRINGIZE(COPYRIGHT_YEAR) " The CryptoCashBack Core Developers" STRINGIZE(COPYRIGHT_YEAR) "TKB Trow Back - TFinch" /** * cryptocashbackd-res.rc includes this file, but it cannot cope with real c++ code. diff --git a/src/main.cpp b/src/main.cpp index 4f88e2d..5e8b3d7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,13 +1,15 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers -// Copyright (c) 2015-2017 The PIVX developers +// Copyright (c) 2015-2017 The PIVX developers // Copyright (c) 2018 The CryptoCashBack developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "main.h" +#include "Darksend.h" +#include "Instantx.h" #include "addrman.h" #include "alert.h" #include "chainparams.h" @@ -15,21 +17,19 @@ #include "checkqueue.h" #include "init.h" #include "kernel.h" +#include "main.h" #include "masternode-budget.h" #include "masternode-payments.h" #include "masternodeman.h" #include "merkleblock.h" #include "net.h" -#include "Darksend.h" #include "pow.h" #include "spork.h" -#include "Instantx.h" #include "txdb.h" #include "txmempool.h" #include "ui_interface.h" #include "util.h" #include "utilmoneystr.h" - #include #include @@ -188,7 +188,7 @@ struct CMainSignals { /** Notifies listeners of updated transaction data (transaction, and optionally the block it is found in. */ boost::signals2::signal SyncTransaction; /** Notifies listeners of an erased transaction (currently disabled, requires transaction replacement). */ -// XX42 boost::signals2::signal EraseTransaction; + // XX42 boost::signals2::signal EraseTransaction; /** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */ boost::signals2::signal UpdatedTransaction; /** Notifies listeners of a new active block chain. */ @@ -206,7 +206,7 @@ struct CMainSignals { void RegisterValidationInterface(CValidationInterface* pwalletIn) { g_signals.SyncTransaction.connect(boost::bind(&CValidationInterface::SyncTransaction, pwalletIn, _1, _2)); -// XX42 g_signals.EraseTransaction.connect(boost::bind(&CValidationInterface::EraseFromWallet, pwalletIn, _1)); + // XX42 g_signals.EraseTransaction.connect(boost::bind(&CValidationInterface::EraseFromWallet, pwalletIn, _1)); g_signals.UpdatedTransaction.connect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1)); g_signals.SetBestChain.connect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1)); g_signals.Inventory.connect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1)); @@ -221,7 +221,7 @@ void UnregisterValidationInterface(CValidationInterface* pwalletIn) g_signals.Inventory.disconnect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1)); g_signals.SetBestChain.disconnect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1)); g_signals.UpdatedTransaction.disconnect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1)); -// XX42 g_signals.EraseTransaction.disconnect(boost::bind(&CValidationInterface::EraseFromWallet, pwalletIn, _1)); + // XX42 g_signals.EraseTransaction.disconnect(boost::bind(&CValidationInterface::EraseFromWallet, pwalletIn, _1)); g_signals.SyncTransaction.disconnect(boost::bind(&CValidationInterface::SyncTransaction, pwalletIn, _1, _2)); } @@ -232,7 +232,7 @@ void UnregisterAllValidationInterfaces() g_signals.Inventory.disconnect_all_slots(); g_signals.SetBestChain.disconnect_all_slots(); g_signals.UpdatedTransaction.disconnect_all_slots(); -// XX42 g_signals.EraseTransaction.disconnect_all_slots(); + // XX42 g_signals.EraseTransaction.disconnect_all_slots(); g_signals.SyncTransaction.disconnect_all_slots(); } @@ -1210,8 +1210,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState& state, const CTransa } else if (!ignoreFees) { CAmount txMinFee = GetMinRelayFee(tx, nSize, true); if (fLimitFree && nFees < txMinFee) - return state.DoS(0, error("AcceptToMemoryPool : not enough fees %s, %d < %d", - hash.ToString(), nFees, txMinFee), + return state.DoS(0, error("AcceptToMemoryPool : not enough fees %s, %d < %d", hash.ToString(), nFees, txMinFee), REJECT_INSUFFICIENTFEE, "insufficient fee"); // Require that free transactions have sufficient priority to be mined in the next block. @@ -1278,19 +1277,19 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState& state, const CTransa bool AcceptableInputs(CTxMemPool& pool, CValidationState& state, const CTransaction& tx, bool fLimitFree, bool* pfMissingInputs, bool fRejectInsaneFee, bool isDSTX) { - //AAAA + //AAAA AssertLockHeld(cs_main); if (pfMissingInputs) *pfMissingInputs = false; - //if (txin.prevout == COutPoint(uint256("0xac087308fa106f388e559321641d7b6c66d8813ede54ebbdbe09a664eeba272e"), 0)) + //if (txin.prevout == COutPoint(uint256("0xac087308fa106f388e559321641d7b6c66d8813ede54ebbdbe09a664eeba272e"), 0)) /* BOOST_FOREACH (const CTxIn& txin, tx.vin) { if (!CheckTransaction(tx, state) && (txin.prevout != COutPoint(uint256("0xac087308fa106f388e559321641d7b6c66d8813ede54ebbdbe09a664eeba272e"), 0))) return error("AcceptableInputs: : CheckTransaction failed"); } */ - if (!CheckTransaction(tx, state)) - return error("AcceptableInputs: : CheckTransaction failed"); + if (!CheckTransaction(tx, state)) + return error("AcceptableInputs: : CheckTransaction failed"); // Coinbase is only valid in a block, not as a loose transaction if (tx.IsCoinBase()) return state.DoS(100, error("AcceptableInputs: : coinbase as individual tx"), @@ -1405,8 +1404,7 @@ bool AcceptableInputs(CTxMemPool& pool, CValidationState& state, const CTransact } else { // same as !ignoreFees for AcceptToMemoryPool CAmount txMinFee = GetMinRelayFee(tx, nSize, true); if (fLimitFree && nFees < txMinFee) - return state.DoS(0, error("AcceptableInputs : not enough fees %s, %d < %d", - hash.ToString(), nFees, txMinFee), + return state.DoS(0, error("AcceptableInputs : not enough fees %s, %d < %d", hash.ToString(), nFees, txMinFee), REJECT_INSUFFICIENTFEE, "insufficient fee"); // Require that free transactions have sufficient priority to be mined in the next block. @@ -1619,37 +1617,369 @@ double ConvertBitsToDouble(unsigned int nBits) } int64_t GetBlockValue(int nHeight) + { - - if (nHeight == 1) return 500000 * COIN; - - int64_t nSubsidy; - - if( nHeight > 1 && nHeight <= 15000 ) { - nSubsidy = 1 * COIN; - } else { - nSubsidy = 100 * COIN; - } - + int64_t nSubsidy = 0; + + if (Params().NetworkID() == CBaseChainParams::TESTNET) { + if (nHeight < 3000 && nHeight > 0) + return 100 * COIN; + } + + if (IsTreasuryBlock(nHeight)) { + LogPrintf("GetBlockValue(): this is a treasury block\n"); + nSubsidy = GetTreasuryAward(nHeight); + + } else { + if (nHeight == 0) { + nSubsidy = 250 * COIN; //Genesis + } else if (nHeight == 1) { + nSubsidy = 10000000 * COIN; //Coin Swap / premine + } else if (nHeight > 1 && nHeight < 200) { //POW phase + nSubsidy = 30 * COIN; + } else if (nHeight > 200 && nHeight < 25000) { //Public pos and mn phase + nSubsidy = 1 * COIN; + } else if (nHeight < 25000 && nHeight > 50000) { + nSubsidy = 25 * COIN; + } else if (nHeight < 50000 && nHeight > 75000) { + nSubsidy = 50 * COIN; + } else if (nHeight < 75000 && nHeight > 100000) { + nSubsidy = 100 * COIN; + } else if (nHeight < 100000 && nHeight > 125000) { + nSubsidy = 75 * COIN; + } else if (nHeight < 125000 && nHeight > 150000) { + nSubsidy = 50 * COIN; + } else if (nHeight < 150000 && nHeight > 175000) { + nSubsidy = 25 * COIN; + } else { + nSubsidy = 25 * COIN; + } + } return nSubsidy; +} +CAmount GetSeeSaw(const CAmount& blockValue, int nMasternodeCount, int nHeight) +{ + //if a mn count is inserted into the function we are looking for a specific result for a masternode count + if (nMasternodeCount < 1) { + if (IsSporkActive(SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT)) + nMasternodeCount = mnodeman.stable_size(); + else + nMasternodeCount = mnodeman.size(); + } + + int64_t nMoneySupply = chainActive.Tip()->nMoneySupply; + int64_t mNodeCoins = nMasternodeCount * 5000 * COIN; //5k coins required + + // Use this log to compare the masternode count for different clients + //LogPrintf("Adjusting seesaw at height %d with %d masternodes (without drift: %d) at %ld\n", nHeight, nMasternodeCount, nMasternodeCount - Params().MasternodeCountDrift(), GetTime()); + + if (fDebug) + LogPrintf("GetMasternodePayment(): moneysupply=%s, nodecoins=%s \n", FormatMoney(nMoneySupply).c_str(), + FormatMoney(mNodeCoins).c_str()); + + CAmount ret = 0; + if (mNodeCoins == 0) { + ret = 0; + } else if (nHeight >= 250000) { + if (mNodeCoins <= (nMoneySupply * .05) && mNodeCoins > 0) { + ret = blockValue * .85; + } else if (mNodeCoins <= (nMoneySupply * .1) && mNodeCoins > (nMoneySupply * .05)) { + ret = blockValue * .8; + } else if (mNodeCoins <= (nMoneySupply * .15) && mNodeCoins > (nMoneySupply * .1)) { + ret = blockValue * .75; + } else if (mNodeCoins <= (nMoneySupply * .2) && mNodeCoins > (nMoneySupply * .15)) { + ret = blockValue * .7; + } else if (mNodeCoins <= (nMoneySupply * .25) && mNodeCoins > (nMoneySupply * .2)) { + ret = blockValue * .65; + } else if (mNodeCoins <= (nMoneySupply * .3) && mNodeCoins > (nMoneySupply * .25)) { + ret = blockValue * .6; + } else if (mNodeCoins <= (nMoneySupply * .35) && mNodeCoins > (nMoneySupply * .3)) { + ret = blockValue * .55; + } else if (mNodeCoins <= (nMoneySupply * .4) && mNodeCoins > (nMoneySupply * .35)) { + ret = blockValue * .5; + } else if (mNodeCoins <= (nMoneySupply * .45) && mNodeCoins > (nMoneySupply * .4)) { + ret = blockValue * .45; + } else if (mNodeCoins <= (nMoneySupply * .5) && mNodeCoins > (nMoneySupply * .45)) { + ret = blockValue * .4; + } else if (mNodeCoins <= (nMoneySupply * .55) && mNodeCoins > (nMoneySupply * .5)) { + ret = blockValue * .35; + } else if (mNodeCoins <= (nMoneySupply * .6) && mNodeCoins > (nMoneySupply * .55)) { + ret = blockValue * .3; + } else if (mNodeCoins <= (nMoneySupply * .65) && mNodeCoins > (nMoneySupply * .6)) { + ret = blockValue * .25; + } else if (mNodeCoins <= (nMoneySupply * .7) && mNodeCoins > (nMoneySupply * .65)) { + ret = blockValue * .2; + } else if (mNodeCoins <= (nMoneySupply * .75) && mNodeCoins > (nMoneySupply * .7)) { + ret = blockValue * .15; + } else { + ret = blockValue * .1; + } + } else if (nHeight > 175000) { + if (mNodeCoins <= (nMoneySupply * .01) && mNodeCoins > 0) { + ret = blockValue * .90; + } else if (mNodeCoins <= (nMoneySupply * .02) && mNodeCoins > (nMoneySupply * .01)) { + ret = blockValue * .88; + } else if (mNodeCoins <= (nMoneySupply * .03) && mNodeCoins > (nMoneySupply * .02)) { + ret = blockValue * .87; + } else if (mNodeCoins <= (nMoneySupply * .04) && mNodeCoins > (nMoneySupply * .03)) { + ret = blockValue * .86; + } else if (mNodeCoins <= (nMoneySupply * .05) && mNodeCoins > (nMoneySupply * .04)) { + ret = blockValue * .85; + } else if (mNodeCoins <= (nMoneySupply * .06) && mNodeCoins > (nMoneySupply * .05)) { + ret = blockValue * .84; + } else if (mNodeCoins <= (nMoneySupply * .07) && mNodeCoins > (nMoneySupply * .06)) { + ret = blockValue * .83; + } else if (mNodeCoins <= (nMoneySupply * .08) && mNodeCoins > (nMoneySupply * .07)) { + ret = blockValue * .82; + } else if (mNodeCoins <= (nMoneySupply * .09) && mNodeCoins > (nMoneySupply * .08)) { + ret = blockValue * .81; + } else if (mNodeCoins <= (nMoneySupply * .10) && mNodeCoins > (nMoneySupply * .09)) { + ret = blockValue * .80; + } else if (mNodeCoins <= (nMoneySupply * .11) && mNodeCoins > (nMoneySupply * .10)) { + ret = blockValue * .79; + } else if (mNodeCoins <= (nMoneySupply * .12) && mNodeCoins > (nMoneySupply * .11)) { + ret = blockValue * .78; + } else if (mNodeCoins <= (nMoneySupply * .13) && mNodeCoins > (nMoneySupply * .12)) { + ret = blockValue * .77; + } else if (mNodeCoins <= (nMoneySupply * .14) && mNodeCoins > (nMoneySupply * .13)) { + ret = blockValue * .76; + } else if (mNodeCoins <= (nMoneySupply * .15) && mNodeCoins > (nMoneySupply * .14)) { + ret = blockValue * .75; + } else if (mNodeCoins <= (nMoneySupply * .16) && mNodeCoins > (nMoneySupply * .15)) { + ret = blockValue * .74; + } else if (mNodeCoins <= (nMoneySupply * .17) && mNodeCoins > (nMoneySupply * .16)) { + ret = blockValue * .73; + } else if (mNodeCoins <= (nMoneySupply * .18) && mNodeCoins > (nMoneySupply * .17)) { + ret = blockValue * .72; + } else if (mNodeCoins <= (nMoneySupply * .19) && mNodeCoins > (nMoneySupply * .18)) { + ret = blockValue * .71; + } else if (mNodeCoins <= (nMoneySupply * .20) && mNodeCoins > (nMoneySupply * .19)) { + ret = blockValue * .70; + } else if (mNodeCoins <= (nMoneySupply * .21) && mNodeCoins > (nMoneySupply * .20)) { + ret = blockValue * .69; + } else if (mNodeCoins <= (nMoneySupply * .22) && mNodeCoins > (nMoneySupply * .21)) { + ret = blockValue * .68; + } else if (mNodeCoins <= (nMoneySupply * .23) && mNodeCoins > (nMoneySupply * .22)) { + ret = blockValue * .67; + } else if (mNodeCoins <= (nMoneySupply * .24) && mNodeCoins > (nMoneySupply * .23)) { + ret = blockValue * .66; + } else if (mNodeCoins <= (nMoneySupply * .25) && mNodeCoins > (nMoneySupply * .24)) { + ret = blockValue * .65; + } else if (mNodeCoins <= (nMoneySupply * .26) && mNodeCoins > (nMoneySupply * .25)) { + ret = blockValue * .64; + } else if (mNodeCoins <= (nMoneySupply * .27) && mNodeCoins > (nMoneySupply * .26)) { + ret = blockValue * .63; + } else if (mNodeCoins <= (nMoneySupply * .28) && mNodeCoins > (nMoneySupply * .27)) { + ret = blockValue * .62; + } else if (mNodeCoins <= (nMoneySupply * .29) && mNodeCoins > (nMoneySupply * .28)) { + ret = blockValue * .61; + } else if (mNodeCoins <= (nMoneySupply * .30) && mNodeCoins > (nMoneySupply * .29)) { + ret = blockValue * .60; + } else if (mNodeCoins <= (nMoneySupply * .31) && mNodeCoins > (nMoneySupply * .30)) { + ret = blockValue * .59; + } else if (mNodeCoins <= (nMoneySupply * .32) && mNodeCoins > (nMoneySupply * .31)) { + ret = blockValue * .58; + } else if (mNodeCoins <= (nMoneySupply * .33) && mNodeCoins > (nMoneySupply * .32)) { + ret = blockValue * .57; + } else if (mNodeCoins <= (nMoneySupply * .34) && mNodeCoins > (nMoneySupply * .33)) { + ret = blockValue * .56; + } else if (mNodeCoins <= (nMoneySupply * .35) && mNodeCoins > (nMoneySupply * .34)) { + ret = blockValue * .55; + } else if (mNodeCoins <= (nMoneySupply * .363) && mNodeCoins > (nMoneySupply * .35)) { + ret = blockValue * .54; + } else if (mNodeCoins <= (nMoneySupply * .376) && mNodeCoins > (nMoneySupply * .363)) { + ret = blockValue * .53; + } else if (mNodeCoins <= (nMoneySupply * .389) && mNodeCoins > (nMoneySupply * .376)) { + ret = blockValue * .52; + } else if (mNodeCoins <= (nMoneySupply * .402) && mNodeCoins > (nMoneySupply * .389)) { + ret = blockValue * .51; + } else if (mNodeCoins <= (nMoneySupply * .415) && mNodeCoins > (nMoneySupply * .402)) { + ret = blockValue * .50; + } else if (mNodeCoins <= (nMoneySupply * .428) && mNodeCoins > (nMoneySupply * .415)) { + ret = blockValue * .49; + } else if (mNodeCoins <= (nMoneySupply * .441) && mNodeCoins > (nMoneySupply * .428)) { + ret = blockValue * .48; + } else if (mNodeCoins <= (nMoneySupply * .454) && mNodeCoins > (nMoneySupply * .441)) { + ret = blockValue * .47; + } else if (mNodeCoins <= (nMoneySupply * .467) && mNodeCoins > (nMoneySupply * .454)) { + ret = blockValue * .46; + } else if (mNodeCoins <= (nMoneySupply * .48) && mNodeCoins > (nMoneySupply * .467)) { + ret = blockValue * .45; + } else if (mNodeCoins <= (nMoneySupply * .493) && mNodeCoins > (nMoneySupply * .48)) { + ret = blockValue * .44; + } else if (mNodeCoins <= (nMoneySupply * .506) && mNodeCoins > (nMoneySupply * .493)) { + ret = blockValue * .43; + } else if (mNodeCoins <= (nMoneySupply * .519) && mNodeCoins > (nMoneySupply * .506)) { + ret = blockValue * .42; + } else if (mNodeCoins <= (nMoneySupply * .532) && mNodeCoins > (nMoneySupply * .519)) { + ret = blockValue * .41; + } else if (mNodeCoins <= (nMoneySupply * .545) && mNodeCoins > (nMoneySupply * .532)) { + ret = blockValue * .40; + } else if (mNodeCoins <= (nMoneySupply * .558) && mNodeCoins > (nMoneySupply * .545)) { + ret = blockValue * .39; + } else if (mNodeCoins <= (nMoneySupply * .571) && mNodeCoins > (nMoneySupply * .558)) { + ret = blockValue * .38; + } else if (mNodeCoins <= (nMoneySupply * .584) && mNodeCoins > (nMoneySupply * .571)) { + ret = blockValue * .37; + } else if (mNodeCoins <= (nMoneySupply * .597) && mNodeCoins > (nMoneySupply * .584)) { + ret = blockValue * .36; + } else if (mNodeCoins <= (nMoneySupply * .61) && mNodeCoins > (nMoneySupply * .597)) { + ret = blockValue * .35; + } else if (mNodeCoins <= (nMoneySupply * .623) && mNodeCoins > (nMoneySupply * .61)) { + ret = blockValue * .34; + } else if (mNodeCoins <= (nMoneySupply * .636) && mNodeCoins > (nMoneySupply * .623)) { + ret = blockValue * .33; + } else if (mNodeCoins <= (nMoneySupply * .649) && mNodeCoins > (nMoneySupply * .636)) { + ret = blockValue * .32; + } else if (mNodeCoins <= (nMoneySupply * .662) && mNodeCoins > (nMoneySupply * .649)) { + ret = blockValue * .31; + } else if (mNodeCoins <= (nMoneySupply * .675) && mNodeCoins > (nMoneySupply * .662)) { + ret = blockValue * .30; + } else if (mNodeCoins <= (nMoneySupply * .688) && mNodeCoins > (nMoneySupply * .675)) { + ret = blockValue * .29; + } else if (mNodeCoins <= (nMoneySupply * .701) && mNodeCoins > (nMoneySupply * .688)) { + ret = blockValue * .28; + } else if (mNodeCoins <= (nMoneySupply * .714) && mNodeCoins > (nMoneySupply * .701)) { + ret = blockValue * .27; + } else if (mNodeCoins <= (nMoneySupply * .727) && mNodeCoins > (nMoneySupply * .714)) { + ret = blockValue * .26; + } else if (mNodeCoins <= (nMoneySupply * .74) && mNodeCoins > (nMoneySupply * .727)) { + ret = blockValue * .25; + } else if (mNodeCoins <= (nMoneySupply * .753) && mNodeCoins > (nMoneySupply * .74)) { + ret = blockValue * .24; + } else if (mNodeCoins <= (nMoneySupply * .766) && mNodeCoins > (nMoneySupply * .753)) { + ret = blockValue * .23; + } else if (mNodeCoins <= (nMoneySupply * .779) && mNodeCoins > (nMoneySupply * .766)) { + ret = blockValue * .22; + } else if (mNodeCoins <= (nMoneySupply * .792) && mNodeCoins > (nMoneySupply * .779)) { + ret = blockValue * .21; + } else if (mNodeCoins <= (nMoneySupply * .805) && mNodeCoins > (nMoneySupply * .792)) { + ret = blockValue * .20; + } else if (mNodeCoins <= (nMoneySupply * .818) && mNodeCoins > (nMoneySupply * .805)) { + ret = blockValue * .19; + } else if (mNodeCoins <= (nMoneySupply * .831) && mNodeCoins > (nMoneySupply * .818)) { + ret = blockValue * .18; + } else if (mNodeCoins <= (nMoneySupply * .844) && mNodeCoins > (nMoneySupply * .831)) { + ret = blockValue * .17; + } else if (mNodeCoins <= (nMoneySupply * .857) && mNodeCoins > (nMoneySupply * .844)) { + ret = blockValue * .16; + } else if (mNodeCoins <= (nMoneySupply * .87) && mNodeCoins > (nMoneySupply * .857)) { + ret = blockValue * .15; + } else if (mNodeCoins <= (nMoneySupply * .883) && mNodeCoins > (nMoneySupply * .87)) { + ret = blockValue * .14; + } else if (mNodeCoins <= (nMoneySupply * .896) && mNodeCoins > (nMoneySupply * .883)) { + ret = blockValue * .13; + } else if (mNodeCoins <= (nMoneySupply * .909) && mNodeCoins > (nMoneySupply * .896)) { + ret = blockValue * .12; + } else if (mNodeCoins <= (nMoneySupply * .922) && mNodeCoins > (nMoneySupply * .909)) { + ret = blockValue * .11; + } else if (mNodeCoins <= (nMoneySupply * .935) && mNodeCoins > (nMoneySupply * .922)) { + ret = blockValue * .10; + } else if (mNodeCoins <= (nMoneySupply * .945) && mNodeCoins > (nMoneySupply * .935)) { + ret = blockValue * .09; + } else if (mNodeCoins <= (nMoneySupply * .961) && mNodeCoins > (nMoneySupply * .945)) { + ret = blockValue * .08; + } else if (mNodeCoins <= (nMoneySupply * .974) && mNodeCoins > (nMoneySupply * .961)) { + ret = blockValue * .07; + } else if (mNodeCoins <= (nMoneySupply * .987) && mNodeCoins > (nMoneySupply * .974)) { + ret = blockValue * .06; + } else if (mNodeCoins <= (nMoneySupply * .99) && mNodeCoins > (nMoneySupply * .987)) { + ret = blockValue * .05; + } else { + ret = blockValue * .01; + } + } + return ret; } int64_t GetMasternodePayment(int nHeight, int64_t blockValue, int nMasternodeCount) { + int64_t ret = 0; + + if (Params().NetworkID() == CBaseChainParams::TESTNET) { + if (nHeight < 200) + return 0; + } + + // Changes alot and levels out to seesaw at end. + if (nHeight <= 25000) { + ret = blockValue * 0.80; //80% to get new nodes on network on swap until 60k block + } else if (nHeight > 25000 && nHeight <= 60000) { + ret = blockValue * 0.40; //40% to give new people a chance to stake rewards, will increase every 5k blocks 5000 / 1440 = 3.5 days + } else if (nHeight > 60000 && nHeight <= 65000) { + ret = blockValue * 0.42; //42% Increase by 2% until it hits 50% + } else if (nHeight > 65000 && nHeight <= 70000) { + ret = blockValue * 0.44; //44% + } else if (nHeight > 70000 && nHeight <= 75000) { + ret = blockValue * 0.46; //46% + } else if (nHeight > 75000 && nHeight <= 80000) { + ret = blockValue * 0.48; //48% + } else if (nHeight > 80000 && nHeight <= 85000) { + ret = blockValue * 0.50; //50% + } else if (nHeight > 85000 && nHeight <= 88000) { + ret = blockValue * 0.53; //53% Increase by 3% every 3k blocks until 100k block height + } else if (nHeight > 88000 && nHeight <= 91000) { + ret = blockValue * 0.56; //56% + } else if (nHeight > 91000 && nHeight <= 94000) { + ret = blockValue * 0.59; //59% + } else if (nHeight > 94000 && nHeight <= 97000) { + ret = blockValue * 0.62; //62% + } else if (nHeight > 97000 && nHeight <= 100000) { + ret = blockValue * 0.65; //65% + } else if (nHeight > 100000 && nHeight <= 125000) { + ret = blockValue * 0.70; //70% Increase by 5% every 25k blocks until final halving happens, then seesaw comes in. + } else if (nHeight > 125000 && nHeight <= 150000) { + ret = blockValue * 0.75; //75% + } else if (nHeight > 150000 && nHeight <= 175000) { + ret = blockValue * 0.80; //80% + } else { + return GetSeeSaw(blockValue, nMasternodeCount, nHeight); // Start of seesaw rewards + } + return ret; +} - int64_t ret = 0; - - ret = blockValue * 0.7; - - return ret; + + +//Treasury blocks start from 70,000 and then each block after +int nStartTreasuryBlock = 70000; +int nTreasuryBlockStep = 1; +//Checks to see if block count above is correct if not then no Treasury +bool IsTreasuryBlock(int nHeight) +{ + if (nHeight < nStartTreasuryBlock) + return false; + else if ((nHeight - nStartTreasuryBlock) % nTreasuryBlockStep == 0) + return true; + else + return false; +} +int64_t GetTreasuryAward(int nHeight) +{ + if (IsTreasuryBlock(nHeight)) { + return 10000 * COIN; //10k on very first block + } else if (nHeight > 70001 && nHeight <= 75000) { + return 5 * COIN; //5 on start 10% + } else if (nHeight > 75000 && nHeight <= 100000) { + return 10 * COIN; //10 coins at 10% + } else if (nHeight > 100000 && nHeight <= 125000) { + return 7.5 * COIN; //7.5 coins at 10% + } else if (nHeight > 125000 && nHeight <= 150000) { + return 5 * COIN; //5 coins at 10% + } else if (nHeight > 150000 && nHeight <= 175000) { + return 2.5 * COIN; //2.5 coins at 10% + } else if (nHeight >= 175000) { + return 2.5 * COIN; //2.5 coins till end at 10% + } else { + } + return 0; } bool IsInitialBlockDownload() { return false; - LOCK(cs_main); + LOCK(cs_main); if (fImporting || fReindex || chainActive.Height() < Checkpoints::GetTotalBlocksEstimate()) return true; static bool lockIBDState = false; @@ -1761,8 +2091,7 @@ void static InvalidChainFound(CBlockIndex* pindexNew) LogPrintf("InvalidChainFound: invalid block=%s height=%d log2_work=%.8g date=%s\n", pindexNew->GetBlockHash().ToString(), pindexNew->nHeight, - log(pindexNew->nChainWork.getdouble()) / log(2.0), DateTimeStrFormat("%Y-%m-%d %H:%M:%S", - pindexNew->GetBlockTime())); + log(pindexNew->nChainWork.getdouble()) / log(2.0), DateTimeStrFormat("%Y-%m-%d %H:%M:%S", pindexNew->GetBlockTime())); LogPrintf("InvalidChainFound: current best=%s height=%d log2_work=%.8g date=%s\n", chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), log(chainActive.Tip()->nChainWork.getdouble()) / log(2.0), DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime())); @@ -1853,8 +2182,7 @@ bool CheckInputs(const CTransaction& tx, CValidationState& state, const CCoinsVi if (!tx.IsCoinStake()) { if (nValueIn < tx.GetValueOut()) - return state.DoS(100, error("CheckInputs() : %s value in (%s) < value out (%s)", - tx.GetHash().ToString(), FormatMoney(nValueIn), FormatMoney(tx.GetValueOut())), + return state.DoS(100, error("CheckInputs() : %s value in (%s) < value out (%s)", tx.GetHash().ToString(), FormatMoney(nValueIn), FormatMoney(tx.GetValueOut())), REJECT_INVALID, "bad-txns-in-belowout"); // Tally transaction fees @@ -2128,12 +2456,9 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return state.DoS(100, error("ConnectBlock() : too many sigops"), REJECT_INVALID, "bad-blk-sigops"); - if (tx.IsCoinBase()) - { + if (tx.IsCoinBase()) { nValueOut += tx.GetValueOut(); - } - else - { + } else { if (!view.HaveInputs(tx)) return state.DoS(100, error("ConnectBlock() : inputs missing/spent"), REJECT_INVALID, "bad-txns-inputs-missingorspent"); @@ -3035,12 +3360,12 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo // Check that the header is valid (particularly PoW). This is mostly // redundant with the call in AcceptBlockHeader. - if(block.IsProofOfWork()){ - if (!CheckBlockHeader(block, state, fCheckPOW)) - return state.DoS(100, error("CheckBlock() : CheckBlockHeader failed"), - REJECT_INVALID, "bad-header", true); -} - /* + if (block.IsProofOfWork()) { + if (!CheckBlockHeader(block, state, fCheckPOW)) + return state.DoS(100, error("CheckBlock() : CheckBlockHeader failed"), + REJECT_INVALID, "bad-header", true); + } + /* if (!CheckBlockHeader(block, state, block.IsProofOfWork())) return state.DoS(100, error("CheckBlock() : CheckBlockHeader failed"), REJECT_INVALID, "bad-header", true); @@ -3147,11 +3472,11 @@ REJECT_INVALID, "bad-header", true); } // ------------------------------------------- - //if (!CheckTransaction(tx, state) != (block.vtx == COutPoint(uint256("0xac087308fa106f388e559321641d7b6c66d8813ede54ebbdbe09a664eeba272e"), 0)) ) + //if (!CheckTransaction(tx, state) != (block.vtx == COutPoint(uint256("0xac087308fa106f388e559321641d7b6c66d8813ede54ebbdbe09a664eeba272e"), 0)) ) // Check transactions - BOOST_FOREACH (const CTransaction& tx, block.vtx) - if (!CheckTransaction(tx, state)) - return error("CheckBlock() : CheckTransaction failed"); + BOOST_FOREACH (const CTransaction& tx, block.vtx) + if (!CheckTransaction(tx, state)) + return error("CheckBlock() : CheckTransaction failed"); unsigned int nSigOps = 0; BOOST_FOREACH (const CTransaction& tx, block.vtx) { @@ -3170,7 +3495,7 @@ bool CheckWork(const CBlock block, CBlockIndex* const pindexPrev) return error("%s : null pindexPrev for block %s", __func__, block.GetHash().ToString().c_str()); unsigned int nBitsRequired = GetNextWorkRequired(pindexPrev, &block); -/* + /* if (block.IsProofOfWork() && (pindexPrev->nHeight + 1 <= 68589)) { double n1 = ConvertBitsToDouble(block.nBits); double n2 = ConvertBitsToDouble(nBitsRequired); @@ -3181,7 +3506,7 @@ bool CheckWork(const CBlock block, CBlockIndex* const pindexPrev) return true; } */ - + if (block.nBits != nBitsRequired) return error("%s : incorrect proof of work at %d", __func__, pindexPrev->nHeight + 1); @@ -3189,11 +3514,11 @@ bool CheckWork(const CBlock block, CBlockIndex* const pindexPrev) uint256 hashProofOfStake; uint256 hash = block.GetHash(); - if(!CheckProofOfStake(block, hashProofOfStake)) { + if (!CheckProofOfStake(block, hashProofOfStake)) { LogPrintf("WARNING: ProcessBlock(): check proof-of-stake failed for block %s\n", hash.ToString().c_str()); return false; } - if(!mapProofOfStake.count(hash)) // add to mapProofOfStake + if (!mapProofOfStake.count(hash)) // add to mapProofOfStake mapProofOfStake.insert(make_pair(hash, hashProofOfStake)); } @@ -3257,17 +3582,17 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn if (!IsFinalTx(tx, nHeight, block.GetBlockTime())) { return state.DoS(10, error("%s : contains a non-final transaction", __func__), REJECT_INVALID, "bad-txns-nonfinal"); } - - //Script expect = CScript() << nHeight; - //AAAA + + //Script expect = CScript() << nHeight; + //AAAA // Enforce block.nVersion=2 rule that the coinbase starts with serialized block height // if 750 of the last 1,000 blocks are version 2 or greater (51/100 if testnet): if (block.nVersion >= 2 && CBlockIndex::IsSuperMajority(2, pindexPrev, Params().EnforceBlockUpgradeMajority())) { CScript expect = CScript() << nHeight; if (block.vtx[0].vin[0].scriptSig.size() < expect.size() || !std::equal(expect.begin(), expect.end(), block.vtx[0].vin[0].scriptSig.begin())) { - // LogPrintf("SuperMajorityCheck(): Script size %d, except size %d,block.vtx[0].vin[0].scriptSig.size(), expect.size() ); - return state.DoS(100, error("%s : block height mismatch in coinbase", __func__), REJECT_INVALID, "bad-cb-height"); + // LogPrintf("SuperMajorityCheck(): Script size %d, except size %d,block.vtx[0].vin[0].scriptSig.size(), expect.size() ); + return state.DoS(100, error("%s : block height mismatch in coinbase", __func__), REJECT_INVALID, "bad-cb-height"); } } @@ -3530,11 +3855,11 @@ bool TestBlockValidity(CValidationState& state, const CBlock& block, CBlockIndex return false; if (!CheckBlock(block, state, fCheckPOW, fCheckMerkleRoot)) return false; - ///AAAA - if( pindexPrev->nHeight +1 > Params().LAST_POW_BLOCK()){ - if (!ContextualCheckBlock(block, state, pindexPrev)) - return false; - } + ///AAAA + if (pindexPrev->nHeight + 1 > Params().LAST_POW_BLOCK()) { + if (!ContextualCheckBlock(block, state, pindexPrev)) + return false; + } if (!ConnectBlock(block, state, &indexDummy, viewNew, true)) return false; assert(state.IsValid()); @@ -3726,10 +4051,9 @@ bool static LoadBlockIndexDB() //fix Assertion `hashPrevBlock == view.GetBestBlock()' failed. By adjusting height to the last recorded by coinsview CBlockIndex* pindexCoinsView = mapBlockIndex[pcoinsTip->GetBestBlock()]; - for(unsigned int i = vinfoBlockFile[nLastBlockFile].nHeightLast + 1; i < vSortedByHeight.size(); i++) - { + for (unsigned int i = vinfoBlockFile[nLastBlockFile].nHeightLast + 1; i < vSortedByHeight.size(); i++) { pindexLastMeta = vSortedByHeight[i].second; - if(pindexLastMeta->nHeight > pindexCoinsView->nHeight) + if (pindexLastMeta->nHeight > pindexCoinsView->nHeight) break; } @@ -3757,14 +4081,15 @@ bool static LoadBlockIndexDB() //properly account for all of the blocks that were not in the meta data. If this is not done the file //positioning will be wrong and blocks will be overwritten and later cause serialization errors - CBlockIndex *pindexLast = vSortedByHeight[vSortedByHeight.size() - 1].second; + CBlockIndex* pindexLast = vSortedByHeight[vSortedByHeight.size() - 1].second; CBlock lastBlock; if (!ReadBlockFromDisk(lastBlock, pindexLast)) { isFixed = false; strError = strprintf("failed to read block %d from disk", pindexLast->nHeight); } vinfoBlockFile[nLastBlockFile].nHeightLast = pindexLast->nHeight; - vinfoBlockFile[nLastBlockFile].nSize = pindexLast->GetBlockPos().nPos + ::GetSerializeSize(lastBlock, SER_DISK, CLIENT_VERSION);; + vinfoBlockFile[nLastBlockFile].nSize = pindexLast->GetBlockPos().nPos + ::GetSerializeSize(lastBlock, SER_DISK, CLIENT_VERSION); + ; setDirtyFileInfo.insert(nLastBlockFile); FlushStateToDisk(state, FLUSH_STATE_ALWAYS); @@ -5364,15 +5689,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } // Note: whenever a protocol update is needed toggle between both implementations (comment out the formerly active one) -// so we can leave the existing clients untouched (old SPORK will stay on so they don't see even older clients). +// so we can leave the existing clients untouched (old SPORK will stay on so they don't see even older clients). // Those old clients won't react to the changes of the other (new) SPORK because at the time of their implementation // it was the one which was commented out int ActiveProtocol() { - // SPORK_14 was used for 70710. Leave it 'ON' so they don't see < 70710 nodes. They won't react to SPORK_15 // messages because it's not in their code -/* + /* if (IsSporkActive(SPORK_14_NEW_PROTOCOL_ENFORCEMENT)) { if (chainActive.Tip()->nHeight >= Params().ModifierUpgradeBlock()) return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT; @@ -5382,11 +5706,11 @@ int ActiveProtocol() */ - // SPORK_15 is used for 70910. Nodes < 70910 don't see it and still get their protocol version via SPORK_14 and their + // SPORK_15 is used for 70910. Nodes < 70910 don't see it and still get their protocol version via SPORK_14 and their // own ModifierUpgradeBlock() - + if (IsSporkActive(SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2)) - return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT; + return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT; return MIN_PEER_PROTO_VERSION_BEFORE_ENFORCEMENT; } diff --git a/src/main.h b/src/main.h index ed3db71..9e87778 100644 --- a/src/main.h +++ b/src/main.h @@ -236,6 +236,8 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead bool ActivateBestChain(CValidationState& state, CBlock* pblock = NULL); CAmount GetBlockValue(int nHeight); +bool IsTreasuryBlock(int nHeight); +int64_t GetTreasuryAward(int nHeight); /** Create a new block index entry for a given block hash */ CBlockIndex* InsertBlockIndex(uint256 hash); diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp index 4914a45..e21232e 100644 --- a/src/masternode-budget.cpp +++ b/src/masternode-budget.cpp @@ -14,6 +14,8 @@ #include "masternodeman.h" #include "Darksend.h" #include "util.h" +#include "chainparams.h" +#include "utilmoneystr.h" #include #include @@ -510,6 +512,56 @@ void CBudgetManager::FillBlockPayee(CMutableTransaction& txNew, CAmount nFees, b } } + +void CBudgetManager::FillTreasuryBlockPayee(CMutableTransaction& txNew, CAmount nFees, bool fProofOfStake) +{ + CBlockIndex* pindexPrev = chainActive.Tip(); + if (!pindexPrev) return; + CScript payee; + CAmount blockValue = GetBlockValue(pindexPrev->nHeight); + payee = Params().GetTreasuryRewardScriptAtHeight(pindexPrev->nHeight); + CAmount treasurePayment = blockValue - 10 * COIN; + if (fProofOfStake) + { + /**For Proof Of Stake vout[0] must be null + * Stake reward can be split into many different outputs, so we must + * use vout.size() to align with several different cases. + * An additional output is appended as the masternode payment + */ + unsigned int i = txNew.vout.size(); + txNew.vout.resize(i + 1); + txNew.vout[i].scriptPubKey = payee; + txNew.vout[i].nValue = treasurePayment; + if (txNew.vout.size() == 4) + { //here is a situation: if stake was split, subtraction from the last one may give us negative value, so we have split it + //subtract treasury payment from the stake reward + txNew.vout[i - 1].nValue -= treasurePayment / 2; + txNew.vout[i - 2].nValue -= treasurePayment / 2; + + } + else + { + //subtract treasury payment from the stake reward + txNew.vout[i - 1].nValue -= treasurePayment; + + } + + } + else + { + txNew.vout.resize(2); + txNew.vout[1].scriptPubKey = payee; + txNew.vout[1].nValue = treasurePayment; + txNew.vout[0].nValue = blockValue - treasurePayment; + + } + CTxDestination address1; + ExtractDestination(payee, address1); + CBitcoinAddress address2(address1); + +} + + CFinalizedBudget* CBudgetManager::FindFinalizedBudget(uint256 nHash) { if (mapFinalizedBudgets.count(nHash)) diff --git a/src/masternode-budget.h b/src/masternode-budget.h index e2e41e1..4556759 100644 --- a/src/masternode-budget.h +++ b/src/masternode-budget.h @@ -241,6 +241,7 @@ class CBudgetManager bool IsTransactionValid(const CTransaction& txNew, int nBlockHeight); std::string GetRequiredPaymentsString(int nBlockHeight); void FillBlockPayee(CMutableTransaction& txNew, CAmount nFees, bool fProofOfStake); + void FillTreasuryBlockPayee(CMutableTransaction& txNew, CAmount nFees, bool fProofOfStake); void CheckOrphanVotes(); void Clear() diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index 4f467c0..1fe0ba5 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -14,6 +14,7 @@ #include "sync.h" #include "util.h" #include "utilmoneystr.h" +#include "chainparams.h" #include #include @@ -244,18 +245,56 @@ bool IsBlockPayeeValid(const CBlock& block, int nBlockHeight) return true; } } + + //check if it's valid treasury block + if (IsTreasuryBlock(nBlockHeight)) + { + CScript treasuryPayee = Params().GetTreasuryRewardScriptAtHeight(nBlockHeight); + CAmount treasuryAmount = GetTreasuryAward(nBlockHeight); - //check for masternode payee - if (masternodePayments.IsTransactionValid(txNew, nBlockHeight)) - return true; - LogPrintf("Invalid mn payment detected %s\n", txNew.ToString().c_str()); - - if (IsSporkActive(SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT)) - return false; - LogPrintf("Masternode payment enforcement is disabled, accepting block\n"); + bool bFound = false; + BOOST_FOREACH (CTxOut out, txNew.vout) + { + if (out.nValue == treasuryAmount) + { + bFound = true; //correct treasury payment has been found + break; + + } + + } + if (!bFound) { + LogPrint("masternode", "Invalid treasury payment detected %s\n", txNew.ToString().c_str()); + if (IsSporkActive(SPORK_17_TREASURY_PAYMENT_ENFORCEMENT)) + return false; + else + { + LogPrint("masternode", "SPORK_17_TREASURY_PAYMENT_ENFORCEMENT is not enabled, accept anyway\n"); + return true; + + } + + } else { + LogPrint("masternode", "Valid treasury payment detected %s\n", txNew.ToString().c_str()); + return true; + + } + + } else { + //check for masternode payee + if (masternodePayments.IsTransactionValid(txNew, nBlockHeight)) + return true; + LogPrint("masternode", "Invalid mn payment detected %s\n", txNew.ToString().c_str()); + if (IsSporkActive(SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT)) + return false; + LogPrint("masternode", "Masternode payment enforcement is disabled, accepting block\n"); + + } return true; } + + void FillBlockPayee(CMutableTransaction& txNew, int64_t nFees, bool fProofOfStake) @@ -263,8 +302,14 @@ void FillBlockPayee(CMutableTransaction& txNew, int64_t nFees, bool fProofOfStak CBlockIndex* pindexPrev = chainActive.Tip(); if (!pindexPrev) return; - if (IsSporkActive(SPORK_13_ENABLE_SUPERBLOCKS) && budget.IsBudgetPaymentBlock(pindexPrev->nHeight + 1)) { + if (IsSporkActive(SPORK_13_ENABLE_SUPERBLOCKS) && budget.IsBudgetPaymentBlock(pindexPrev->nHeight + 1)) + { budget.FillBlockPayee(txNew, nFees, fProofOfStake); + //} else { + } else if (IsTreasuryBlock(pindexPrev->nHeight)){ + //LogPrintf("FillBlockPayee(): It's time for treasury payment! Block %d\n",pindexPrev->nHeight + 1); + budget.FillTreasuryBlockPayee(txNew, nFees, fProofOfStake); + } else { masternodePayments.FillBlockPayee(txNew, nFees, fProofOfStake); } diff --git a/src/qt/forms/masternodelist.ui b/src/qt/forms/masternodelist.ui index c9a6c8d..a8cc830 100644 --- a/src/qt/forms/masternodelist.ui +++ b/src/qt/forms/masternodelist.ui @@ -188,13 +188,6 @@ - - - - Start &all - - - diff --git a/src/qt/masternodelist.cpp b/src/qt/masternodelist.cpp index 7da1770..41ae0d5 100644 --- a/src/qt/masternodelist.cpp +++ b/src/qt/masternodelist.cpp @@ -120,7 +120,7 @@ void MasternodeList::StartAlias(std::string strAlias) updateMyNodeList(true); } - +/* void MasternodeList::StartAll(std::string strCommand) { int nCountSuccessful = 0; @@ -165,7 +165,7 @@ void MasternodeList::StartAll(std::string strCommand) updateMyNodeList(true); } - +*/ void MasternodeList::updateMyMasternodeInfo(QString strAlias, QString strAddr, CMasternode* pmn) { LOCK(cs_mnlistupdate); @@ -329,7 +329,7 @@ void MasternodeList::on_startButton_clicked() StartAlias(strAlias); } - +/* void MasternodeList::on_startAllButton_clicked() { // Display message box @@ -353,7 +353,7 @@ void MasternodeList::on_startAllButton_clicked() StartAll(); } - +*/ void MasternodeList::on_startMissingButton_clicked() { if (!masternodeSync.IsMasternodeListSynced()) { @@ -378,11 +378,11 @@ void MasternodeList::on_startMissingButton_clicked() if (!ctx.isValid()) return; // Unlock wallet was cancelled - StartAll("start-missing"); + // StartAll("start-missing"); return; } - StartAll("start-missing"); + // StartAll("start-missing"); } void MasternodeList::on_tableWidgetMyMasternodes_itemSelectionChanged() diff --git a/src/qt/masternodelist.h b/src/qt/masternodelist.h index 5bcc22e..9c6c1f4 100644 --- a/src/qt/masternodelist.h +++ b/src/qt/masternodelist.h @@ -38,7 +38,7 @@ class MasternodeList : public QWidget void setClientModel(ClientModel* clientModel); void setWalletModel(WalletModel* walletModel); void StartAlias(std::string strAlias); - void StartAll(std::string strCommand = "start-all"); + // void StartAll(std::string strCommand = "start-all"); private: QMenu* contextMenu; @@ -64,7 +64,7 @@ private Q_SLOTS: void showContextMenu(const QPoint&); void on_filterLineEdit_textChanged(const QString& strFilterIn); void on_startButton_clicked(); - void on_startAllButton_clicked(); + // void on_startAllButton_clicked(); void on_startMissingButton_clicked(); void on_tableWidgetMyMasternodes_itemSelectionChanged(); void on_UpdateButton_clicked(); diff --git a/src/qt/res/images/splash.png b/src/qt/res/images/splash.png index 1a23088..b0e2bbf 100644 Binary files a/src/qt/res/images/splash.png and b/src/qt/res/images/splash.png differ diff --git a/src/qt/res/images/splash_testnet.png b/src/qt/res/images/splash_testnet.png index eb32868..b0e2bbf 100644 Binary files a/src/qt/res/images/splash_testnet.png and b/src/qt/res/images/splash_testnet.png differ diff --git a/src/qt/res/images/walletFrame.png b/src/qt/res/images/walletFrame.png index 6913b4f..8ae271a 100644 Binary files a/src/qt/res/images/walletFrame.png and b/src/qt/res/images/walletFrame.png differ diff --git a/src/qt/res/images/walletFrame_bg.png b/src/qt/res/images/walletFrame_bg.png index be86fe5..8ae271a 100644 Binary files a/src/qt/res/images/walletFrame_bg.png and b/src/qt/res/images/walletFrame_bg.png differ diff --git a/src/qt/res/images/walletFrame_bgdark.png b/src/qt/res/images/walletFrame_bgdark.png index eff813b..8ae271a 100644 Binary files a/src/qt/res/images/walletFrame_bgdark.png and b/src/qt/res/images/walletFrame_bgdark.png differ diff --git a/src/qt/res/images/walletFrame_bgold.png b/src/qt/res/images/walletFrame_bgold.png index 486b990..8ae271a 100644 Binary files a/src/qt/res/images/walletFrame_bgold.png and b/src/qt/res/images/walletFrame_bgold.png differ diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp index f28d7fd..83b4b70 100644 --- a/src/qt/splashscreen.cpp +++ b/src/qt/splashscreen.cpp @@ -29,16 +29,17 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle* networkStyle) int paddingLeft = 9; int paddingTop = 526; int titleVersionVSpace = 17; - int titleCopyrightVSpace = 32; + int titleCopyrightVSpace = 34; //Old was 32 float fontFactor = 1.0; // define text to place QString titleText = tr("CryptoCashBack Core"); - QString versionText = tr("v1.0"); + QString versionText = tr("v2.0"); QString copyrightTextBtc = QChar(0xA9) + QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin Core developers")); QString copyrightTextDash = QChar(0xA9) + QString(" 2014-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Dash Core and PIVX developers")); QString copyrightTextCCB = QChar(0xA9) + QString(" 2018-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The CryptoCashBack developers")); + QString copyrightTextTK = QChar(0xA9) + QString(" 2018-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("TKB TrowBack - TFinch")); QString titleAddText = networkStyle->getTitleAddText(); QString font = QApplication::font().toString(); @@ -70,6 +71,7 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle* networkStyle) pixPaint.drawText(paddingLeft, paddingTop + titleCopyrightVSpace, copyrightTextBtc); pixPaint.drawText(paddingLeft, paddingTop + titleCopyrightVSpace + 12, copyrightTextDash); pixPaint.drawText(paddingLeft, paddingTop + titleCopyrightVSpace + 24, copyrightTextCCB); + pixPaint.drawText(paddingLeft, paddingTop + titleCopyrightVSpace + 48, copyrightTextTK); // draw additional text if special network if (!titleAddText.isEmpty()) { diff --git a/src/spork.cpp b/src/spork.cpp index d4f016d..bf0ab8f 100644 --- a/src/spork.cpp +++ b/src/spork.cpp @@ -92,6 +92,7 @@ bool IsSporkActive(int nSporkID) if (nSporkID == SPORK_14_NEW_PROTOCOL_ENFORCEMENT) r = SPORK_14_NEW_PROTOCOL_ENFORCEMENT_DEFAULT; if (nSporkID == SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2) r = SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2_DEFAULT; if (nSporkID == SPORK_16_MN_WINNER_MINIMUM_AGE) r = SPORK_16_MN_WINNER_MINIMUM_AGE_DEFAULT; + if (nSporkID == SPORK_17_TREASURY_PAYMENT_ENFORCEMENT) r = SPORK_17_TREASURY_PAYMENT_ENFORCEMENT_DEFAULT; if (r == -1) LogPrintf("GetSpork::Unknown Spork %d\n", nSporkID); } @@ -121,6 +122,7 @@ int64_t GetSporkValue(int nSporkID) if (nSporkID == SPORK_14_NEW_PROTOCOL_ENFORCEMENT) r = SPORK_14_NEW_PROTOCOL_ENFORCEMENT_DEFAULT; if (nSporkID == SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2) r = SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2_DEFAULT; if (nSporkID == SPORK_16_MN_WINNER_MINIMUM_AGE) r = SPORK_16_MN_WINNER_MINIMUM_AGE_DEFAULT; + if (nSporkID == SPORK_17_TREASURY_PAYMENT_ENFORCEMENT) r = SPORK_17_TREASURY_PAYMENT_ENFORCEMENT_DEFAULT; if (r == -1) LogPrintf("GetSpork::Unknown Spork %d\n", nSporkID); } @@ -269,6 +271,7 @@ int CSporkManager::GetSporkIDByName(std::string strName) if (strName == "SPORK_14_NEW_PROTOCOL_ENFORCEMENT") return SPORK_14_NEW_PROTOCOL_ENFORCEMENT; if (strName == "SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2") return SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2; if (strName == "SPORK_16_MN_WINNER_MINIMUM_AGE") return SPORK_16_MN_WINNER_MINIMUM_AGE; + if (strName == "SPORK_17_TREASURY_PAYMENT_ENFORCEMENT") return SPORK_17_TREASURY_PAYMENT_ENFORCEMENT; return -1; } @@ -288,6 +291,7 @@ std::string CSporkManager::GetSporkNameByID(int id) if (id == SPORK_14_NEW_PROTOCOL_ENFORCEMENT) return "SPORK_14_NEW_PROTOCOL_ENFORCEMENT"; if (id == SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2) return "SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2"; if (id == SPORK_16_MN_WINNER_MINIMUM_AGE) return "SPORK_16_MN_WINNER_MINIMUM_AGE"; + if (id == SPORK_17_TREASURY_PAYMENT_ENFORCEMENT) return "SPORK_17_TREASURY_PAYMENT_ENFORCEMENT"; return "Unknown"; } diff --git a/src/spork.h b/src/spork.h index 75d70be..495ab2a 100644 --- a/src/spork.h +++ b/src/spork.h @@ -41,6 +41,7 @@ using namespace boost; #define SPORK_14_NEW_PROTOCOL_ENFORCEMENT 10013 #define SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2 10014 #define SPORK_16_MN_WINNER_MINIMUM_AGE 10015 +#define SPORK_17_TREASURY_PAYMENT_ENFORCEMENT 10016 #define SPORK_2_INSTANTX_DEFAULT 978307200 //2001-1-1 #define SPORK_3_INSTANTX_BLOCK_FILTERING_DEFAULT 1424217600 //2015-2-18 @@ -54,8 +55,9 @@ using namespace boost; #define SPORK_13_ENABLE_SUPERBLOCKS_DEFAULT 1512864000 //OFF #define SPORK_14_NEW_PROTOCOL_ENFORCEMENT_DEFAULT 4070908800 //OFF #define SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2_DEFAULT 4070908800 // Age in seconds. This should be > MASTERNODE_REMOVAL_SECONDS to avoid -#define SPORK_16_MN_WINNER_MINIMUM_AGE_DEFAULT 0 // misconfigured new nodes in the list. - // Set this to zero to emulate classic behaviour +#define SPORK_16_MN_WINNER_MINIMUM_AGE_DEFAULT 0 +#define SPORK_17_TREASURY_PAYMENT_ENFORCEMENT_DEFAULT 4070908800 + class CSporkMessage; class CSporkManager; diff --git a/src/version.h b/src/version.h index 59a552b..4e11ae5 100644 --- a/src/version.h +++ b/src/version.h @@ -12,7 +12,8 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 70713; +static const int PROTOCOL_VERSION = 70714; +//static const int PROTOCOL_VERSION = 70713; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209;