Skip to content

Commit

Permalink
remove founders reward
Browse files Browse the repository at this point in the history
  • Loading branch information
Skellers21 committed Feb 7, 2019
1 parent d26ec8c commit 697aba1
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 43 deletions.
3 changes: 1 addition & 2 deletions src/Makefile.gtest.include
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ zcash_gtest_SOURCES = \
gtest/utils.cpp \
gtest/test_checktransaction.cpp \
gtest/json_test_vectors.cpp \
gtest/json_test_vectors.h \
gtest/test_foundersreward.cpp
gtest/json_test_vectors.h
# These tests are order-dependent, because they
# depend on global state (see #1539)
if ENABLE_WALLET
Expand Down
26 changes: 2 additions & 24 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in

/**
* Check a transaction contextually against a set of consensus rules valid at a given block height.
*
*
* Notes:
* 1. AcceptToMemoryPool calls CheckTransaction and this function.
* 2. ProcessNewBlock calls AcceptBlock, which calls CheckBlock (which calls CheckTransaction)
Expand Down Expand Up @@ -955,7 +955,7 @@ bool ContextualCheckTransaction(
return state.DoS(dosLevel, error("ContextualCheckTransaction: overwinter is active"),
REJECT_INVALID, "tx-overwinter-active");
}

// Check that all transactions are unexpired
if (IsExpiredTx(tx, nHeight)) {
// Don't increase banscore if the transaction only just expired
Expand Down Expand Up @@ -3614,28 +3614,6 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
}
}

// Coinbase transaction must include an output sending 20% of
// the block reward to a founders reward script, until the last founders
// reward block is reached, with exception of the genesis block.
// The last founders reward block is defined as the block just before the
// first subsidy halving block, which occurs at halving_interval + slow_start_shift
if ((nHeight > 0) && (nHeight <= consensusParams.GetLastFoundersRewardBlockHeight())) {
bool found = false;

BOOST_FOREACH(const CTxOut& output, block.vtx[0].vout) {
if (output.scriptPubKey == Params().GetFoundersRewardScriptAtHeight(nHeight)) {
if (output.nValue == (GetBlockSubsidy(nHeight, consensusParams) / 5)) {
found = true;
break;
}
}
}

if (!found) {
return state.DoS(100, error("%s: founders reward missing", __func__), REJECT_INVALID, "cb-no-founders-reward");
}
}

return true;
}

Expand Down
4 changes: 1 addition & 3 deletions src/metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,7 @@ int printMetrics(size_t cols, bool mining)
chainActive.Contains(mapBlockIndex[hash])) {
int height = mapBlockIndex[hash]->nHeight;
CAmount subsidy = GetBlockSubsidy(height, consensusParams);
if ((height > 0) && (height <= consensusParams.GetLastFoundersRewardBlockHeight())) {
subsidy -= subsidy/5;
}

if (std::max(0, COINBASE_MATURITY - (tipHeight - height)) > 0) {
immature += subsidy;
} else {
Expand Down
10 changes: 0 additions & 10 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,16 +360,6 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
// Set to 0 so expiry height does not apply to coinbase txs
txNew.nExpiryHeight = 0;

if ((nHeight > 0) && (nHeight <= chainparams.GetConsensus().GetLastFoundersRewardBlockHeight())) {
// Founders reward is 20% of the block subsidy
auto vFoundersReward = txNew.vout[0].nValue / 5;
// Take some reward away from us
txNew.vout[0].nValue -= vFoundersReward;

// And give it to the founders
txNew.vout.push_back(CTxOut(vFoundersReward, chainparams.GetFoundersRewardScriptAtHeight(nHeight)));
}

// Add fees
txNew.vout[0].nValue += nFees;
txNew.vin[0].scriptSig = CScript() << nHeight << OP_0;
Expand Down
4 changes: 0 additions & 4 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,10 +901,6 @@ UniValue getblocksubsidy(const UniValue& params, bool fHelp)

CAmount nReward = GetBlockSubsidy(nHeight, Params().GetConsensus());
CAmount nFoundersReward = 0;
if ((nHeight > 0) && (nHeight <= Params().GetConsensus().GetLastFoundersRewardBlockHeight())) {
nFoundersReward = nReward/5;
nReward -= nFoundersReward;
}
UniValue result(UniValue::VOBJ);
result.push_back(Pair("miner", ValueFromAmount(nReward)));
result.push_back(Pair("founders", ValueFromAmount(nFoundersReward)));
Expand Down

1 comment on commit 697aba1

@0xmatt1
Copy link

@0xmatt1 0xmatt1 commented on 697aba1 Mar 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree and I'm glad you did it in the same style

Please sign in to comment.