Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contrib/devtools/check-doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# 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)
Expand Down
2 changes: 1 addition & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class CCustomParams : public CChainParams {
// 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"));

Expand Down Expand Up @@ -177,7 +178,6 @@ class CCustomParams : public CChainParams {
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.
Expand Down
2 changes: 0 additions & 2 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class CChainParams
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;
Expand All @@ -111,7 +110,6 @@ class CChainParams
bool fMineBlocksOnDemand;
CCheckpointData checkpointData;
ChainTxData chainTxData;
CScript scriptCoinbaseDestination;
};

/**
Expand Down
1 change: 1 addition & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct Params {
CAsset pegged_asset;
uint256 defaultAssumeValid;
uint32_t pegin_min_depth;
CScript mandatory_coinbase_destination;
};
} // namespace Consensus

Expand Down
4 changes: 2 additions & 2 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down
10 changes: 6 additions & 4 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Copy link
Contributor

Choose a reason for hiding this comment

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

Mhmm, so if outputs are confidential or 0 it is allowed that they're sent anywhere? why?
Also shouldn't we validate that all coinbase outputs are explicit regardless of mandatory_coinbase_destination?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By consensus they can't be confidential(the check is later in VerifyCoinbaseAnounts), and you need to allow 0-value outputs for commitments, such as segwit.

return state.DoS(100, error("ConnectBlock(): Coinbase outputs didnt match required scriptPubKey"),
REJECT_INVALID, "bad-coinbase-txos");
}
}

bool fScriptChecks = true;
Expand Down