mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +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
|
# 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 = 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():
|
def main():
|
||||||
used = check_output(CMD_GREP_ARGS, shell=True)
|
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.
|
// By default assume that the signatures in ancestors of this block are valid.
|
||||||
consensus.defaultAssumeValid = uint256S(GetArg("-con_defaultassumevalid", "0x00"));
|
consensus.defaultAssumeValid = uint256S(GetArg("-con_defaultassumevalid", "0x00"));
|
||||||
consensus.pegin_min_depth = GetArg("-peginconfirmationdepth", DEFAULT_PEGIN_CONFIRMATION_DEPTH);
|
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
|
// bitcoin regtest is the parent chain by default
|
||||||
parentGenesisBlockHash = uint256S(GetArg("-parentgenesisblockhash", "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"));
|
parentGenesisBlockHash = uint256S(GetArg("-parentgenesisblockhash", "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"));
|
||||||
|
|
||||||
|
|
@ -177,7 +178,6 @@ public:
|
||||||
consensus.hashGenesisBlock = genesis.GetHash();
|
consensus.hashGenesisBlock = genesis.GetHash();
|
||||||
|
|
||||||
|
|
||||||
scriptCoinbaseDestination = CScript(); // Allow any coinbase destination
|
|
||||||
|
|
||||||
vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
|
vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
|
||||||
vSeeds.clear(); //!< Regtest mode doesn't have any DNS seeds.
|
vSeeds.clear(); //!< Regtest mode doesn't have any DNS seeds.
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,6 @@ public:
|
||||||
const ChainTxData& TxData() const { return chainTxData; }
|
const ChainTxData& TxData() const { return chainTxData; }
|
||||||
void UpdateBIP9Parameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout);
|
void UpdateBIP9Parameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout);
|
||||||
/** All coinbase outputs (after genesis) must be to this destination */
|
/** All coinbase outputs (after genesis) must be to this destination */
|
||||||
const CScript& CoinbaseDestination() const { return scriptCoinbaseDestination; }
|
|
||||||
bool anyonecanspend_aremine;
|
bool anyonecanspend_aremine;
|
||||||
protected:
|
protected:
|
||||||
CChainParams() = delete;
|
CChainParams() = delete;
|
||||||
|
|
@ -111,7 +110,6 @@ protected:
|
||||||
bool fMineBlocksOnDemand;
|
bool fMineBlocksOnDemand;
|
||||||
CCheckpointData checkpointData;
|
CCheckpointData checkpointData;
|
||||||
ChainTxData chainTxData;
|
ChainTxData chainTxData;
|
||||||
CScript scriptCoinbaseDestination;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ struct Params {
|
||||||
CAsset pegged_asset;
|
CAsset pegged_asset;
|
||||||
uint256 defaultAssumeValid;
|
uint256 defaultAssumeValid;
|
||||||
uint32_t pegin_min_depth;
|
uint32_t pegin_min_depth;
|
||||||
|
CScript mandatory_coinbase_destination;
|
||||||
};
|
};
|
||||||
} // namespace Consensus
|
} // namespace Consensus
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ UniValue generate(const JSONRPCRequest& request)
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
CScript coinbaseDest(Params().CoinbaseDestination());
|
CScript coinbaseDest(Params().GetConsensus().mandatory_coinbase_destination);
|
||||||
if (coinbaseDest == CScript()) {
|
if (coinbaseDest == CScript()) {
|
||||||
coinbaseDest = CScript() << OP_TRUE;
|
coinbaseDest = CScript() << OP_TRUE;
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
|
|
@ -172,7 +172,7 @@ UniValue getnewblockhex(const JSONRPCRequest& request)
|
||||||
+ HelpExampleCli("getnewblockhex", "")
|
+ HelpExampleCli("getnewblockhex", "")
|
||||||
);
|
);
|
||||||
|
|
||||||
CScript feeDestinationScript = Params().CoinbaseDestination();
|
CScript feeDestinationScript = Params().GetConsensus().mandatory_coinbase_destination;
|
||||||
if (feeDestinationScript == CScript()) feeDestinationScript = CScript() << OP_TRUE;
|
if (feeDestinationScript == CScript()) feeDestinationScript = CScript() << OP_TRUE;
|
||||||
std::unique_ptr<CBlockTemplate> pblocktemplate(BlockAssembler(Params()).CreateNewBlock(feeDestinationScript));
|
std::unique_ptr<CBlockTemplate> pblocktemplate(BlockAssembler(Params()).CreateNewBlock(feeDestinationScript));
|
||||||
if (!pblocktemplate.get())
|
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));
|
return error("%s: Consensus::CheckBlock: %s", __func__, FormatStateMessage(state));
|
||||||
|
|
||||||
// Check that all non-zero coinbase outputs pay to the required destination
|
// Check that all non-zero coinbase outputs pay to the required destination
|
||||||
BOOST_FOREACH(const CTxOut& txout, block.vtx[0]->vout) {
|
if (chainparams.GetConsensus().mandatory_coinbase_destination != CScript()) {
|
||||||
if (chainparams.CoinbaseDestination() != CScript() && txout.scriptPubKey != chainparams.CoinbaseDestination() && !(txout.nValue.IsExplicit() && txout.nValue.GetAmount() == 0))
|
BOOST_FOREACH(const CTxOut& txout, block.vtx[0]->vout) {
|
||||||
return state.DoS(100, error("ConnectBlock(): Coinbase outputs didnt match required scriptPubKey"),
|
if (txout.scriptPubKey != chainparams.GetConsensus().mandatory_coinbase_destination && !(txout.nValue.IsExplicit() && txout.nValue.GetAmount() == 0))
|
||||||
REJECT_INVALID, "bad-coinbase-txos");
|
return state.DoS(100, error("ConnectBlock(): Coinbase outputs didnt match required scriptPubKey"),
|
||||||
|
REJECT_INVALID, "bad-coinbase-txos");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fScriptChecks = true;
|
bool fScriptChecks = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue