From 942da1450a0b5010f23f2160e69b100b4af59df1 Mon Sep 17 00:00:00 2001 From: projectmemetic Date: Fri, 24 Aug 2018 21:17:56 -0400 Subject: [PATCH 1/4] Support Kekdaq priv key version byte --- src/base58.cpp | 15 ++++++++++++++- src/base58.h | 4 +++- src/chainparams.cpp | 2 ++ src/chainparams.h | 2 +- src/rpcclient.cpp | 2 +- src/rpcdump.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ src/rpcserver.cpp | 2 ++ src/rpcserver.h | 3 ++- 8 files changed, 66 insertions(+), 5 deletions(-) diff --git a/src/base58.cpp b/src/base58.cpp index 2837396e..16cd39a3 100644 --- a/src/base58.cpp +++ b/src/base58.cpp @@ -211,6 +211,12 @@ bool CBase58Data::SetString(const std::string& str) { return SetString(str.c_str()); } +std::string CBase58Data::ToKekdaqString() const { + std::vector vch = Params().Base58Prefix(CChainParams::KEKDAQ_SECRET_KEY); + vch.insert(vch.end(), vchData.begin(), vchData.end()); + return EncodeBase58Check(vch); +} + std::string CBase58Data::ToString() const { std::vector vch = vchVersion; vch.insert(vch.end(), vchData.begin(), vchData.end()); @@ -296,6 +302,13 @@ void CBitcoinSecret::SetKey(const CKey& vchSecret) { vchData.push_back(1); } +void CBitcoinSecret::SetKekdaqKey(const CKey& vchSecret) { + assert(vchSecret.IsValid()); + SetData(Params().Base58Prefix(CChainParams::KEKDAQ_SECRET_KEY), vchSecret.begin(), vchSecret.size()); + if (vchSecret.IsCompressed()) + vchData.push_back(1); +} + CKey CBitcoinSecret::GetKey() { CKey ret; ret.Set(&vchData[0], &vchData[32], vchData.size() > 32 && vchData[32] == 1); @@ -304,7 +317,7 @@ CKey CBitcoinSecret::GetKey() { bool CBitcoinSecret::IsValid() const { bool fExpectedFormat = vchData.size() == 32 || (vchData.size() == 33 && vchData[32] == 1); - bool fCorrectVersion = vchVersion == Params().Base58Prefix(CChainParams::SECRET_KEY); + bool fCorrectVersion = vchVersion == Params().Base58Prefix(CChainParams::SECRET_KEY) || vchVersion == Params().Base58Prefix(CChainParams::KEKDAQ_SECRET_KEY); return fExpectedFormat && fCorrectVersion; } diff --git a/src/base58.h b/src/base58.h index 12897909..78918ff2 100644 --- a/src/base58.h +++ b/src/base58.h @@ -83,6 +83,7 @@ class CBase58Data bool SetString(const char* psz, unsigned int nVersionBytes = 1); bool SetString(const std::string& str); std::string ToString() const; + std::string ToKekdaqString() const; int CompareTo(const CBase58Data& b58) const; bool operator==(const CBase58Data& b58) const { return CompareTo(b58) == 0; } @@ -122,11 +123,12 @@ class CBitcoinSecret : public CBase58Data { public: void SetKey(const CKey& vchSecret); + void SetKekdaqKey(const CKey& vchSecret); CKey GetKey(); bool IsValid() const; bool SetString(const char* pszSecret); bool SetString(const std::string& strSecret); - + CBitcoinSecret(const CKey& vchSecret) { SetKey(vchSecret); } CBitcoinSecret() {} }; diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 6b772c8c..aa004e1d 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -106,6 +106,7 @@ class CMainParams : public CChainParams { base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,55); // pepecoin addresses start with P base58Prefixes[SCRIPT_ADDRESS] = std::vector(1,85); base58Prefixes[SECRET_KEY] = std::vector(1,153); + base58Prefixes[KEKDAQ_SECRET_KEY] = std::vector(1,99); base58Prefixes[STEALTH_ADDRESS] = std::vector(1,40); base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x88)(0xB2)(0x1E).convert_to_container >();; base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x88)(0xAD)(0xE4).convert_to_container >();; @@ -169,6 +170,7 @@ class CTestNetParams : public CMainParams { base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,55); base58Prefixes[SCRIPT_ADDRESS] = std::vector(1,196); base58Prefixes[SECRET_KEY] = std::vector(1,239); + base58Prefixes[KEKDAQ_SECRET_KEY] = std::vector(1,63); base58Prefixes[STEALTH_ADDRESS] = std::vector(1,40); base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container >();; base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x35)(0x83)(0x94).convert_to_container >();; diff --git a/src/chainparams.h b/src/chainparams.h index 3fe78f07..0857f99f 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -50,7 +50,7 @@ class CChainParams STEALTH_ADDRESS, EXT_PUBLIC_KEY, EXT_SECRET_KEY, - + KEKDAQ_SECRET_KEY, MAX_BASE58_TYPES }; diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index 3ceb7f13..e18f038a 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -161,7 +161,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "signrawtransaction", 1 }, { "signrawtransaction", 2 }, { "keypoolrefill", 0 }, - { "importprivkey", 2 }, + { "importprivkey", 2 }, { "importaddress", 2 }, { "checkkernel", 0 }, { "checkkernel", 1 }, diff --git a/src/rpcdump.cpp b/src/rpcdump.cpp index a53818e2..a0ee07d2 100644 --- a/src/rpcdump.cpp +++ b/src/rpcdump.cpp @@ -339,6 +339,47 @@ Value dumpprivkey(const Array& params, bool fHelp) return CBitcoinSecret(vchSecret).ToString(); } +Value dumpkekdaqprivkey(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "dumpkekdaqprivkey \n" + "Reveals the kekdaq format private key corresponding to ."); + + EnsureWalletIsUnlocked(); + + string strAddress = params[0].get_str(); + CBitcoinAddress address; + if (!address.SetString(strAddress)) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid PepeCoin address"); + if (fWalletUnlockStakingOnly) + throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Wallet is unlocked for staking only."); + CKeyID keyID; + if (!address.GetKeyID(keyID)) + throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key"); + CKey vchSecret; + if (!pwalletMain->GetKey(keyID, vchSecret)) + throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known"); + return CBitcoinSecret(vchSecret).ToKekdaqString(); +} + +Value checkprivkey(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 1) + throw runtime_error( + "checkprivkey \n" + "Check a private key for validity."); + + string strSecret = params[0].get_str(); + + CBitcoinSecret vchSecret; + bool fGood = vchSecret.SetString(strSecret); + + if (!fGood) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key"); + + return Value::null; +} + Value dumpwallet(const Array& params, bool fHelp) { if (fHelp || params.size() != 1) diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index ed6b5cac..d8b21e14 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -296,6 +296,8 @@ static const CRPCCommand vRPCCommands[] = { "submitblock", &submitblock, false, false, false }, { "listsinceblock", &listsinceblock, false, false, true }, { "dumpprivkey", &dumpprivkey, false, false, true }, + { "dumpkekdaqprivkey", &dumpkekdaqprivkey, false, false, true }, + { "checkprivkey", &checkprivkey, false, false, true }, { "dumpwallet", &dumpwallet, true, false, true }, { "importprivkey", &importprivkey, false, false, true }, { "importwallet", &importwallet, false, false, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index ac282f77..d4922726 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -109,8 +109,9 @@ extern json_spirit::Value dumpwallet(const json_spirit::Array& params, bool fHel extern json_spirit::Value importwallet(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value importaddress(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value dumpprivkey(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp +extern json_spirit::Value dumpkekdaqprivkey(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp extern json_spirit::Value importprivkey(const json_spirit::Array& params, bool fHelp); - +extern json_spirit::Value checkprivkey(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp extern json_spirit::Value sendalert(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getmininginfo(const json_spirit::Array& params, bool fHelp); From 2d2d91e17cb0f6bcf77a99843881681ef8de6fb6 Mon Sep 17 00:00:00 2001 From: projectmemetic Date: Mon, 22 Oct 2018 18:02:31 -0400 Subject: [PATCH 2/4] Hardfork to staking only --- src/main.cpp | 50 +++++++++++++++++-- src/main.h | 3 ++ src/rpcmining.cpp | 9 ++-- src/wallet.cpp | 120 +++++++++++++++++++++++++++++++++++++++++----- 4 files changed, 163 insertions(+), 19 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e5d1e2a9..d79433e5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1611,6 +1611,16 @@ int64_t nSubsidy = 20 * COIN; if (nHeight >= PEPE_JACKOLANTERN_FORK_HEIGHT) nSubsidy = 1 * COIN; // Minimum 1 PEPE stake return for optimal KEKDAQ functionality. + if (nHeight >= PEPE_STAKEONLY_HEIGHT) + { + // adopt the proof-of-work reward schedule when swap over to stake only + // this will pick up the current pow reward of 3.25 at fork height with halving + nSubsidy = 15 * COIN; + nSubsidy >>= ((nHeight - PEPE_REBRAND_HEIGHT) / 525600); // block reward halves once a year + + if(nSubsidy < 1 * COIN) // minimum 1 PEPE stake return + nSubsidy = 1 * COIN; + } if(nHeight+1 == PEPE_REBRAND_PF_HEIGHT) nSubsidy += (3 * PEPE_DEV_GRANT); @@ -1622,6 +1632,8 @@ int64_t nSubsidy = 20 * COIN; nSubsidy += (3 * PEPE_DEV_GRANT); if(nHeight+1 == PEPE_KEKDAQ2_SWAP_HEIGHT) nSubsidy += (3 * DEVFEE_OFF_SWAP_FINAL); + if(nHeight+1 == PEPE_STAKEONLY_HEIGHT) + nSubsidy += (4 * PEPE_SO_SWAP_GRANT); return nSubsidy + nFees; } @@ -3046,7 +3058,7 @@ bool CBlock::AcceptBlock() CBlockIndex* pindexPrev = (*mi).second; int nHeight = pindexPrev->nHeight+1; - if (IsProofOfWork() && nHeight > STOP_POW_BLOCK && nHeight < RESTART_POW_BLOCK ) + if (IsProofOfWork() && ((nHeight > STOP_POW_BLOCK && nHeight < RESTART_POW_BLOCK) || nHeight >= PEPE_STAKEONLY_HEIGHT)) return DoS(100, error("AcceptBlock() : reject proof-of-work at height %d", nHeight)); if (IsProofOfStake() && nHeight < Params().POSStartBlock() ) @@ -3148,9 +3160,14 @@ bool CBlock::CheckDevRewards(CTransaction tx, int64_t nHeight, int64_t nReward, if (nHeight == PEPE_STAKE_CONF_HEIGHT) nDevReward = PEPE_DEV_GRANT; if (nHeight == PEPE_KEKDAQ2_SWAP_HEIGHT) - nDevReward = DEVFEE_OFF_SWAP_FINAL; + nDevReward = DEVFEE_OFF_SWAP_FINAL; + if (nHeight == PEPE_STAKEONLY_HEIGHT) + nDevReward = PEPE_SO_SWAP_GRANT; int64_t nTotalDevRewards = 3 * nDevReward; + if(nHeight >= PEPE_STAKEONLY_HEIGHT) + nTotalDevRewards = 4 * nDevReward; + int64_t nFoundDevRewards = 0; CBitcoinAddress addrDevOne; @@ -3162,10 +3179,14 @@ bool CBlock::CheckDevRewards(CTransaction tx, int64_t nHeight, int64_t nReward, CBitcoinAddress addrDevThree; addrDevThree.SetString(DecodeBase64(PEPE_REBRAND_DEV_3)); CScript payeeDevThree = GetScriptForDestination(addrDevThree.Get()); + CBitcoinAddress addrDevFour; + addrDevFour.SetString(DecodeBase64(PEPE_DEV_4)); + CScript payeeDevFour = GetScriptForDestination(addrDevFour.Get()); bool bFoundDevOne = false; bool bFoundDevTwo = false; bool bFoundDevThree = false; + bool bFoundDevFour = false; for(unsigned int i=0; i= nDevReward) + { + bFoundDevFour = true; + nFoundDevRewards += nDevReward; + } + } } } } - if((bFoundDevOne && bFoundDevTwo && bFoundDevThree) && (nFoundDevRewards >= nTotalDevRewards)) - return true; + if(nHeight >= PEPE_STAKEONLY_HEIGHT) + { + if((bFoundDevOne && bFoundDevTwo && bFoundDevThree && bFoundDevFour) && (nFoundDevRewards >= nTotalDevRewards)) + return true; + else + return false; + } else - return false; + { + if((bFoundDevOne && bFoundDevTwo && bFoundDevThree) && (nFoundDevRewards >= nTotalDevRewards)) + return true; + else + return false; + } } uint256 CBlockIndex::GetBlockTrust() const diff --git a/src/main.h b/src/main.h index 5f2ba7de..b828eafa 100644 --- a/src/main.h +++ b/src/main.h @@ -76,6 +76,7 @@ static const int64_t PEPE_REBRAND_HEIGHT_TESTNET = 100; static const std::string PEPE_REBRAND_DEV_1 = "UE5hSlMzbVBNY1FjNmdZc0xKMUg4endHSDZIMVh4VG40OA=="; static const std::string PEPE_REBRAND_DEV_2 = "UFJyeFZQWGNUQjN2TGNjZlBVRlRNVzJ6NTd3Skd3ZEd1ag=="; static const std::string PEPE_REBRAND_DEV_3 = "UExSY1ZHVmNZdkE2NmJNWGVQd2hSUTJleFdNdlBvVm83MQ=="; +static const std::string PEPE_DEV_4 = "UFUxWm05N3R6NmRyQ0FuQmZNYjVFd2s3R0NSa3FYV2dZeA=="; static const int64_t PEPE_REBRAND_PF_HEIGHT = 600000; static const int64_t PEPE_KEKDAQ_MID_HEIGHT = 733333; static const int64_t PEPE_KEKDAQ_MID_FIX_HEIGHT = 738500; @@ -87,8 +88,10 @@ static const int64_t PEPE_DEV_GRANT = 333333 * COIN; static const int64_t PEPE_DEV_GRANT_MID = 333333 * COIN; static const int64_t PEPE_DEV_GRANT_FINAL = 111111 * COIN; static const int64_t DEVFEE_OFF_SWAP_FINAL = 777777 * COIN; +static const int64_t PEPE_SO_SWAP_GRANT = 888888 * COIN; static const int64_t PEPE_STAKE_CONF_HEIGHT = 1021111; static const int64_t PEPE_STAKE_CONF_TWEAK = 1177777; +static const int64_t PEPE_STAKEONLY_HEIGHT = 1700000; /** The maximum allowed size for a serialized block, in bytes (network rule) */ static const unsigned int MAX_BLOCK_SIZE = 20000000; diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 5eaefdf6..a2ae104b 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -265,7 +265,8 @@ Value getworkex(const Array& params, bool fHelp) if (IsInitialBlockDownload()) throw JSONRPCError(-10, "PepeCoin is downloading blocks..."); - if (pindexBest->nHeight >= Params().LastPOWBlock() && pindexBest->nHeight < Params().RestartPOWBlock()) + if (pindexBest->nHeight >= Params().LastPOWBlock() && + (pindexBest->nHeight < Params().RestartPOWBlock() || pindexBest->nHeight >= PEPE_STAKEONLY_HEIGHT)) throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks"); typedef map > mapNewBlock_t; @@ -399,7 +400,8 @@ Value getwork(const Array& params, bool fHelp) if (IsInitialBlockDownload()) throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "PepeCoin is downloading blocks..."); - if (pindexBest->nHeight >= Params().LastPOWBlock() && pindexBest->nHeight < Params().RestartPOWBlock()) + if (pindexBest->nHeight >= Params().LastPOWBlock() && + (pindexBest->nHeight < Params().RestartPOWBlock() || pindexBest->nHeight >= PEPE_STAKEONLY_HEIGHT)) throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks"); typedef map > mapNewBlock_t; @@ -551,7 +553,8 @@ Value getblocktemplate(const Array& params, bool fHelp) //if (IsInitialBlockDownload()) // throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "PepeCoin is downloading blocks..."); - if (pindexBest->nHeight >= Params().LastPOWBlock() && pindexBest->nHeight < Params().RestartPOWBlock()) + if (pindexBest->nHeight >= Params().LastPOWBlock() && + (pindexBest->nHeight < Params().RestartPOWBlock() || pindexBest->nHeight >= PEPE_STAKEONLY_HEIGHT)) throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks"); // Update block diff --git a/src/wallet.cpp b/src/wallet.cpp index 4facd21d..34fc9ef7 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -3880,6 +3880,8 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int { // add tx outputs for 3 dev reward splits int payments = txNew.vout.size() + 3; + if(pindexPrev->nHeight+1 >= PEPE_STAKEONLY_HEIGHT) + payments = txNew.vout.size() + 4; txNew.vout.resize(payments); CBitcoinAddress addrDevOne; @@ -3891,13 +3893,21 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int CBitcoinAddress addrDevThree; addrDevThree.SetString(DecodeBase64(PEPE_REBRAND_DEV_3)); CScript payeeDevThree = GetScriptForDestination(addrDevThree.Get()); + CBitcoinAddress addrDevFour; + addrDevFour.SetString(DecodeBase64(PEPE_DEV_4)); + CScript payeeDevFour = GetScriptForDestination(addrDevFour.Get()); txNew.vout[payments-1].scriptPubKey = payeeDevOne; txNew.vout[payments-1].nValue = 0; txNew.vout[payments-2].scriptPubKey = payeeDevTwo; txNew.vout[payments-2].nValue = 0; txNew.vout[payments-3].scriptPubKey = payeeDevThree; - txNew.vout[payments-3].nValue = 0; + txNew.vout[payments-3].nValue = 0; + if(pindexPrev->nHeight+1 >= PEPE_STAKEONLY_HEIGHT) + { + txNew.vout[payments-4].scriptPubKey = payeeDevFour; + txNew.vout[payments-4].nValue = 0; + } int64_t devPayment = 0.02 * nReward; // 2% of stake reward per dev payment @@ -3913,11 +3923,33 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int if (pindexPrev->nHeight == PEPE_STAKE_CONF_HEIGHT) devPayment = PEPE_DEV_GRANT; if (pindexPrev->nHeight+1 == PEPE_KEKDAQ2_SWAP_HEIGHT) - devPayment = DEVFEE_OFF_SWAP_FINAL; + devPayment = DEVFEE_OFF_SWAP_FINAL; + if (pindexPrev->nHeight+1 == PEPE_STAKEONLY_HEIGHT) + devPayment = PEPE_SO_SWAP_GRANT; // Set output amount - if(txNew.vout.size() == 6) // 2 stake outputs, stake was split, plus 3 dev payments + if(txNew.vout.size() == 7 && pindexPrev->nHeight+1 >= PEPE_STAKEONLY_HEIGHT) // 2 stake outputs, stake was split, plus 4 dev payments + { + txNew.vout[payments-1].nValue = devPayment; + txNew.vout[payments-2].nValue = devPayment; + txNew.vout[payments-3].nValue = devPayment; + txNew.vout[payments-4].nValue = devPayment; + blockValue -= (4 * devPayment); + txNew.vout[1].nValue = (blockValue / 2 / CENT) * CENT; + txNew.vout[2].nValue = blockValue - txNew.vout[1].nValue; + } + else if(txNew.vout.size() == 6 && pindexPrev->nHeight+1 >= PEPE_STAKEONLY_HEIGHT) // 2 stake outputs, stake was split, plus 4 dev payments + { + txNew.vout[payments-1].nValue = devPayment; + txNew.vout[payments-2].nValue = devPayment; + txNew.vout[payments-3].nValue = devPayment; + txNew.vout[payments-4].nValue = devPayment; + blockValue -= (4 * devPayment); + txNew.vout[1].nValue = (blockValue / 2 / CENT) * CENT; + txNew.vout[2].nValue = blockValue - txNew.vout[1].nValue; + } + else if(txNew.vout.size() == 6) // 2 stake outputs, stake was split, plus 3 dev payments { txNew.vout[payments-1].nValue = devPayment; txNew.vout[payments-2].nValue = devPayment; @@ -3977,10 +4009,20 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int if(hasPayment){ payments = txNew.vout.size() + 4; + if(pindexPrev->nHeight+1 >= PEPE_STAKEONLY_HEIGHT) + payments = txNew.vout.size() + 5; txNew.vout.resize(payments); - txNew.vout[payments-4].scriptPubKey = payee; - txNew.vout[payments-4].nValue = 0; + if(pindexPrev->nHeight+1 >= PEPE_STAKEONLY_HEIGHT) + { + txNew.vout[payments-5].scriptPubKey = payee; + txNew.vout[payments-5].nValue = 0; + } + else + { + txNew.vout[payments-4].scriptPubKey = payee; + txNew.vout[payments-4].nValue = 0; + } CTxDestination address1; ExtractDestination(payee, address1); @@ -3992,6 +4034,8 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int { // add tx outputs for 3 dev reward splits int payments = txNew.vout.size() + 3; + if(pindexPrev->nHeight+1 >= PEPE_STAKEONLY_HEIGHT) + payments = txNew.vout.size() + 4; txNew.vout.resize(payments); } @@ -4004,13 +4048,21 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int CBitcoinAddress addrDevThree; addrDevThree.SetString(DecodeBase64(PEPE_REBRAND_DEV_3)); CScript payeeDevThree = GetScriptForDestination(addrDevThree.Get()); + CBitcoinAddress addrDevFour; + addrDevFour.SetString(DecodeBase64(PEPE_DEV_4)); + CScript payeeDevFour = GetScriptForDestination(addrDevFour.Get()); txNew.vout[payments-1].scriptPubKey = payeeDevOne; txNew.vout[payments-1].nValue = 0; txNew.vout[payments-2].scriptPubKey = payeeDevTwo; txNew.vout[payments-2].nValue = 0; txNew.vout[payments-3].scriptPubKey = payeeDevThree; - txNew.vout[payments-3].nValue = 0; + txNew.vout[payments-3].nValue = 0; + if(pindexPrev->nHeight+1 > PEPE_STAKEONLY_HEIGHT) + { + txNew.vout[payments-4].scriptPubKey = payeeDevFour; + txNew.vout[payments-4].nValue = 0; + } int64_t devPayment = 0.02 * nReward; // 2% of stake reward per dev payment @@ -4025,12 +4077,58 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int if (pindexPrev->nHeight+1 == PEPE_STAKE_CONF_HEIGHT) devPayment = PEPE_DEV_GRANT; if (pindexPrev->nHeight+1 == PEPE_KEKDAQ2_SWAP_HEIGHT) - devPayment = DEVFEE_OFF_SWAP_FINAL; + devPayment = DEVFEE_OFF_SWAP_FINAL; + if (pindexPrev->nHeight+1 == PEPE_STAKEONLY_HEIGHT) + devPayment = PEPE_SO_SWAP_GRANT; int64_t masternodePayment = (nReward - (3 * devPayment)) * 0.375; //37.5% //GetMasternodePayment(pindexPrev->nHeight+1, nReward); + if (pindexPrev->nHeight+1 == PEPE_STAKEONLY_HEIGHT) + masternodePayment = (nReward - (4 * devPayment)) * 0.375; // Set output amount - if(!hasPayment && txNew.vout.size() == 6) // 2 stake outputs, stake was split, plus 3 dev payments + if(!hasPayment && txNew.vout.size() == 7 && pindexPrev->nHeight+1 >= PEPE_STAKEONLY_HEIGHT) // 2 stake outputs, stake was split, plus 3 dev payments + { + txNew.vout[payments-1].nValue = devPayment; + txNew.vout[payments-2].nValue = devPayment; + txNew.vout[payments-3].nValue = devPayment; + txNew.vout[payments-4].nValue = devPayment; + blockValue -= (4 * devPayment); + txNew.vout[1].nValue = (blockValue / 2 / CENT) * CENT; + txNew.vout[2].nValue = blockValue - txNew.vout[1].nValue; + } + else if(!hasPayment && txNew.vout.size() == 6 && pindexPrev->nHeight+1 >= PEPE_STAKEONLY_HEIGHT) // only 1 stake output, was not split, plus 4 dev payments + { + txNew.vout[payments-1].nValue = devPayment; + txNew.vout[payments-2].nValue = devPayment; + txNew.vout[payments-3].nValue = devPayment; + txNew.vout[payments-4].nValue = devPayment; + blockValue -= (4 * devPayment); + txNew.vout[1].nValue = blockValue; + } + else if(hasPayment && txNew.vout.size() == 8 && pindexPrev->nHeight+1 >= PEPE_STAKEONLY_HEIGHT) // 2 stake outputs, stake was split, mn payment plus 4 dev payments + { + txNew.vout[payments-1].nValue = devPayment; + txNew.vout[payments-2].nValue = devPayment; + txNew.vout[payments-3].nValue = devPayment; + txNew.vout[payments-4].nValue = devPayment; + blockValue -= (4 * devPayment); + txNew.vout[payments-5].nValue = masternodePayment; + blockValue -= masternodePayment; + txNew.vout[1].nValue = (blockValue / 2 / CENT) * CENT; + txNew.vout[2].nValue = blockValue - txNew.vout[1].nValue; + } + else if(hasPayment && txNew.vout.size() == 7 && pindexPrev->nHeight+1 >= PEPE_STAKEONLY_HEIGHT) // only 1 stake output, was not split, mn payment plus 4 dev payments + { + txNew.vout[payments-1].nValue = devPayment; + txNew.vout[payments-2].nValue = devPayment; + txNew.vout[payments-3].nValue = devPayment; + txNew.vout[payments-4].nValue = devPayment; + blockValue -= (4 * devPayment); + txNew.vout[payments-5].nValue = masternodePayment; + blockValue -= masternodePayment; + txNew.vout[1].nValue = blockValue; + } + else if(!hasPayment && txNew.vout.size() == 6 && pindexPrev->nHeight+1 < PEPE_STAKEONLY_HEIGHT) // 2 stake outputs, stake was split, plus 3 dev payments { txNew.vout[payments-1].nValue = devPayment; txNew.vout[payments-2].nValue = devPayment; @@ -4039,7 +4137,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int txNew.vout[1].nValue = (blockValue / 2 / CENT) * CENT; txNew.vout[2].nValue = blockValue - txNew.vout[1].nValue; } - else if(!hasPayment && txNew.vout.size() == 5) // only 1 stake output, was not split, plus 3 dev payments + else if(!hasPayment && txNew.vout.size() == 5 && pindexPrev->nHeight+1 < PEPE_STAKEONLY_HEIGHT) // only 1 stake output, was not split, plus 3 dev payments { txNew.vout[payments-1].nValue = devPayment; txNew.vout[payments-2].nValue = devPayment; @@ -4047,7 +4145,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int blockValue -= (3 * devPayment); txNew.vout[1].nValue = blockValue; } - else if(hasPayment && txNew.vout.size() == 7) // 2 stake outputs, stake was split, mn payment plus 3 dev payments + else if(hasPayment && txNew.vout.size() == 7 && pindexPrev->nHeight+1 < PEPE_STAKEONLY_HEIGHT) // 2 stake outputs, stake was split, mn payment plus 3 dev payments { txNew.vout[payments-1].nValue = devPayment; txNew.vout[payments-2].nValue = devPayment; @@ -4058,7 +4156,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int txNew.vout[1].nValue = (blockValue / 2 / CENT) * CENT; txNew.vout[2].nValue = blockValue - txNew.vout[1].nValue; } - else if(hasPayment && txNew.vout.size() == 6) // only 1 stake output, was not split, mn payment plus 3 dev payments + else if(hasPayment && txNew.vout.size() == 6 && pindexPrev->nHeight+1 < PEPE_STAKEONLY_HEIGHT) // only 1 stake output, was not split, mn payment plus 3 dev payments { txNew.vout[payments-1].nValue = devPayment; txNew.vout[payments-2].nValue = devPayment; From a97a2a8075692d697919c31f3496a7de6396830d Mon Sep 17 00:00:00 2001 From: projectmemetic Date: Mon, 22 Oct 2018 18:31:33 -0400 Subject: [PATCH 3/4] Version 2.8 Protocol version 61415 --- src/clientversion.h | 2 +- src/version.cpp | 4 ++-- src/version.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/clientversion.h b/src/clientversion.h index 835bd9c9..0fd61f3e 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -7,7 +7,7 @@ // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 2 -#define CLIENT_VERSION_MINOR 7 +#define CLIENT_VERSION_MINOR 8 #define CLIENT_VERSION_REVISION 0 #define CLIENT_VERSION_BUILD 0 diff --git a/src/version.cpp b/src/version.cpp index daa33622..dfacd628 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -8,7 +8,7 @@ // Name of client reported in the 'version' message. Report the same name // for both bitcoind and bitcoin-qt, to make it harder for attackers to // target servers or GUI users specifically. -const std::string CLIENT_NAME("PepeCoin-Memetic-2.7.0.0"); +const std::string CLIENT_NAME("PepeCoin-Memetic-2.8.0.0"); // Client version number #define CLIENT_VERSION_SUFFIX "-Stage" @@ -37,7 +37,7 @@ const std::string CLIENT_NAME("PepeCoin-Memetic-2.7.0.0"); // git will put "#define GIT_ARCHIVE 1" on the next line inside archives. #define GIT_ARCHIVE 1 #ifdef GIT_ARCHIVE -# define GIT_COMMIT_ID "61414" +# define GIT_COMMIT_ID "61415" #endif #define BUILD_DESC_FROM_COMMIT(maj,min,rev,build,commit) \ diff --git a/src/version.h b/src/version.h index c793ecaf..4d9fa753 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 = 61414; +static const int PROTOCOL_VERSION = 61415; // intial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; From 02ae4349de361a49f26af541a10efb086681e095 Mon Sep 17 00:00:00 2001 From: projectmemetic Date: Mon, 22 Oct 2018 21:01:56 -0400 Subject: [PATCH 4/4] Reset POS reward start at hardfork --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index d79433e5..71b07078 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1616,7 +1616,7 @@ int64_t nSubsidy = 20 * COIN; // adopt the proof-of-work reward schedule when swap over to stake only // this will pick up the current pow reward of 3.25 at fork height with halving nSubsidy = 15 * COIN; - nSubsidy >>= ((nHeight - PEPE_REBRAND_HEIGHT) / 525600); // block reward halves once a year + nSubsidy >>= ((nHeight - PEPE_STAKEONLY_HEIGHT) / 525600); // block reward halves once a year if(nSubsidy < 1 * COIN) // minimum 1 PEPE stake return nSubsidy = 1 * COIN;