Merge #329: parameterize the mandatory coinbase

d77df82 parameterize the mandatory coinbase (Gregory Sanders)
This commit is contained in:
Gregory Sanders 2018-04-03 11:24:36 -07:00
commit e7c77f41ec
No known key found for this signature in database
GPG key ID: F3F68E2D86A48FDB
6 changed files with 11 additions and 10 deletions

View file

@ -23,7 +23,7 @@ REGEX_DOC = re.compile(r'HelpMessageOpt\(\"(\-[^\"=]+?)(?:=|\")')
# list unsupported, deprecated and duplicate args as they need no documentation
SET_DOC_OPTIONAL = set(['-rpcssl', '-benchmark', '-h', '-help', '-socks', '-tor', '-debugnet', '-whitelistalwaysrelay', '-prematurewitness', '-walletprematurewitness', '-promiscuousmempoolflags', '-blockminsize'])
SET_DOC_OPTIONAL.update(['-con_fpowallowmindifficultyblocks', '-con_fpownoretargeting', '-con_nsubsidyhalvinginterval', '-con_bip34height', '-con_bip65height', '-con_bip66height', '-con_npowtargettimespan', '-con_npowtargetspacing', '-con_nrulechangeactivationthreshold', '-con_nminerconfirmationwindow', '-con_powlimit', '-con_parentpowlimit', '-con_bip34hash', '-con_nminimumchainwork', '-con_defaultassumevalid', '-parentgenesisblockhash', '-ndefaultport', '-npruneafterheight', '-fdefaultconsistencychecks', '-frequirestandard', '-fmineblocksondemand', '-mainchainrpccookiefile', '-testnet', '-ct_bits', '-ct_exponent', '-anyonecanspendaremine', '-fminingrequirespeers', '-fmineblocksondemand'])
SET_DOC_OPTIONAL.update(['-con_fpowallowmindifficultyblocks', '-con_fpownoretargeting', '-con_nsubsidyhalvinginterval', '-con_bip34height', '-con_bip65height', '-con_bip66height', '-con_npowtargettimespan', '-con_npowtargetspacing', '-con_nrulechangeactivationthreshold', '-con_nminerconfirmationwindow', '-con_powlimit', '-con_parentpowlimit', '-con_bip34hash', '-con_nminimumchainwork', '-con_defaultassumevalid', '-parentgenesisblockhash', '-ndefaultport', '-npruneafterheight', '-fdefaultconsistencychecks', '-frequirestandard', '-fmineblocksondemand', '-mainchainrpccookiefile', '-testnet', '-ct_bits', '-ct_exponent', '-anyonecanspendaremine', '-fminingrequirespeers', '-fmineblocksondemand', '-con_mandatorycoinbase'])
def main():
used = check_output(CMD_GREP_ARGS, shell=True)

View file

@ -130,6 +130,7 @@ protected:
// By default assume that the signatures in ancestors of this block are valid.
consensus.defaultAssumeValid = uint256S(GetArg("-con_defaultassumevalid", "0x00"));
consensus.pegin_min_depth = GetArg("-peginconfirmationdepth", DEFAULT_PEGIN_CONFIRMATION_DEPTH);
consensus.mandatory_coinbase_destination = StrHexToScriptWithDefault(GetArg("-con_mandatorycoinbase", ""), CScript()); // Blank script allows any coinbase destination
// bitcoin regtest is the parent chain by default
parentGenesisBlockHash = uint256S(GetArg("-parentgenesisblockhash", "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"));
@ -177,7 +178,6 @@ public:
consensus.hashGenesisBlock = genesis.GetHash();
scriptCoinbaseDestination = CScript(); // Allow any coinbase destination
vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
vSeeds.clear(); //!< Regtest mode doesn't have any DNS seeds.

View file

@ -89,7 +89,6 @@ public:
const ChainTxData& TxData() const { return chainTxData; }
void UpdateBIP9Parameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout);
/** All coinbase outputs (after genesis) must be to this destination */
const CScript& CoinbaseDestination() const { return scriptCoinbaseDestination; }
bool anyonecanspend_aremine;
protected:
CChainParams() = delete;
@ -111,7 +110,6 @@ protected:
bool fMineBlocksOnDemand;
CCheckpointData checkpointData;
ChainTxData chainTxData;
CScript scriptCoinbaseDestination;
};
/**

View file

@ -70,6 +70,7 @@ struct Params {
CAsset pegged_asset;
uint256 defaultAssumeValid;
uint32_t pegin_min_depth;
CScript mandatory_coinbase_destination;
};
} // namespace Consensus

View file

@ -120,7 +120,7 @@ UniValue generate(const JSONRPCRequest& request)
LOCK(cs_main);
CScript coinbaseDest(Params().CoinbaseDestination());
CScript coinbaseDest(Params().GetConsensus().mandatory_coinbase_destination);
if (coinbaseDest == CScript()) {
coinbaseDest = CScript() << OP_TRUE;
#ifdef ENABLE_WALLET
@ -172,7 +172,7 @@ UniValue getnewblockhex(const JSONRPCRequest& request)
+ HelpExampleCli("getnewblockhex", "")
);
CScript feeDestinationScript = Params().CoinbaseDestination();
CScript feeDestinationScript = Params().GetConsensus().mandatory_coinbase_destination;
if (feeDestinationScript == CScript()) feeDestinationScript = CScript() << OP_TRUE;
std::unique_ptr<CBlockTemplate> pblocktemplate(BlockAssembler(Params()).CreateNewBlock(feeDestinationScript));
if (!pblocktemplate.get())

View file

@ -2580,10 +2580,12 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
return error("%s: Consensus::CheckBlock: %s", __func__, FormatStateMessage(state));
// Check that all non-zero coinbase outputs pay to the required destination
BOOST_FOREACH(const CTxOut& txout, block.vtx[0]->vout) {
if (chainparams.CoinbaseDestination() != CScript() && txout.scriptPubKey != chainparams.CoinbaseDestination() && !(txout.nValue.IsExplicit() && txout.nValue.GetAmount() == 0))
return state.DoS(100, error("ConnectBlock(): Coinbase outputs didnt match required scriptPubKey"),
REJECT_INVALID, "bad-coinbase-txos");
if (chainparams.GetConsensus().mandatory_coinbase_destination != CScript()) {
BOOST_FOREACH(const CTxOut& txout, block.vtx[0]->vout) {
if (txout.scriptPubKey != chainparams.GetConsensus().mandatory_coinbase_destination && !(txout.nValue.IsExplicit() && txout.nValue.GetAmount() == 0))
return state.DoS(100, error("ConnectBlock(): Coinbase outputs didnt match required scriptPubKey"),
REJECT_INVALID, "bad-coinbase-txos");
}
}
bool fScriptChecks = true;