mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
parameterize the mandatory coinbase
This commit is contained in:
parent
146808c163
commit
d77df82196
6 changed files with 11 additions and 10 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ struct Params {
|
|||
CAsset pegged_asset;
|
||||
uint256 defaultAssumeValid;
|
||||
uint32_t pegin_min_depth;
|
||||
CScript mandatory_coinbase_destination;
|
||||
};
|
||||
} // namespace Consensus
|
||||
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue