diff --git a/contrib/devtools/check-doc.py b/contrib/devtools/check-doc.py index 4c27a8ec60..698833e73d 100755 --- a/contrib/devtools/check-doc.py +++ b/contrib/devtools/check-doc.py @@ -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) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 1faa19e2e1..baf57eb6fe 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -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. diff --git a/src/chainparams.h b/src/chainparams.h index 493b380b14..fd3536ea37 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -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; }; /** diff --git a/src/consensus/params.h b/src/consensus/params.h index cf9ab42ec3..f8681d9a47 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -70,6 +70,7 @@ struct Params { CAsset pegged_asset; uint256 defaultAssumeValid; uint32_t pegin_min_depth; + CScript mandatory_coinbase_destination; }; } // namespace Consensus diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 2fa8ebc59b..cd6ea0a401 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -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 pblocktemplate(BlockAssembler(Params()).CreateNewBlock(feeDestinationScript)); if (!pblocktemplate.get()) diff --git a/src/validation.cpp b/src/validation.cpp index bc999ed11d..4958b0db41 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -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;