mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
add consensus.mandatory_coinbase_destination
This commit is contained in:
parent
de842cb58f
commit
edb053276b
4 changed files with 22 additions and 0 deletions
|
|
@ -420,6 +420,11 @@ class CCustomParams : public CRegTestParams {
|
||||||
consensus.nMinimumChainWork = uint256S(args.GetArg("-con_nminimumchainwork", "0x0"));
|
consensus.nMinimumChainWork = uint256S(args.GetArg("-con_nminimumchainwork", "0x0"));
|
||||||
consensus.defaultAssumeValid = uint256S(args.GetArg("-con_defaultassumevalid", "0x00"));
|
consensus.defaultAssumeValid = uint256S(args.GetArg("-con_defaultassumevalid", "0x00"));
|
||||||
|
|
||||||
|
// All non-zero coinbase outputs must go to this scriptPubKey
|
||||||
|
std::vector<unsigned char> man_bytes = ParseHex(gArgs.GetArg("-con_mandatorycoinbase", ""));
|
||||||
|
consensus.mandatory_coinbase_destination = CScript(man_bytes.begin(), man_bytes.end()); // Blank script allows any coinbase destination
|
||||||
|
|
||||||
|
|
||||||
nPruneAfterHeight = (uint64_t)args.GetArg("-npruneafterheight", nPruneAfterHeight);
|
nPruneAfterHeight = (uint64_t)args.GetArg("-npruneafterheight", nPruneAfterHeight);
|
||||||
fDefaultConsistencyChecks = args.GetBoolArg("-fdefaultconsistencychecks", fDefaultConsistencyChecks);
|
fDefaultConsistencyChecks = args.GetBoolArg("-fdefaultconsistencychecks", fDefaultConsistencyChecks);
|
||||||
fMineBlocksOnDemand = args.GetBoolArg("-fmineblocksondemand", fMineBlocksOnDemand);
|
fMineBlocksOnDemand = args.GetBoolArg("-fmineblocksondemand", fMineBlocksOnDemand);
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ void SetupChainParamsBaseOptions()
|
||||||
"This is intended for regression testing tools and app development.", true, OptionsCategory::CHAINPARAMS);
|
"This is intended for regression testing tools and app development.", true, OptionsCategory::CHAINPARAMS);
|
||||||
gArgs.AddArg("-testnet", "Use the test chain", false, OptionsCategory::CHAINPARAMS);
|
gArgs.AddArg("-testnet", "Use the test chain", false, OptionsCategory::CHAINPARAMS);
|
||||||
gArgs.AddArg("-vbparams=deployment:start:end", "Use given start/end times for specified version bits deployment (regtest or custom only)", true, OptionsCategory::CHAINPARAMS);
|
gArgs.AddArg("-vbparams=deployment:start:end", "Use given start/end times for specified version bits deployment (regtest or custom only)", true, OptionsCategory::CHAINPARAMS);
|
||||||
|
gArgs.AddArg("-con_mandatorycoinbase", "All non-zero valued coinbase outputs must go to this scriptPubKey, if set.", false, OptionsCategory::CHAINPARAMS);
|
||||||
gArgs.AddArg("-seednode=<ip>", "Use specified node as seed node. This option can be specified multiple times to connect to multiple nodes. (custom only)", true, OptionsCategory::CHAINPARAMS);
|
gArgs.AddArg("-seednode=<ip>", "Use specified node as seed node. This option can be specified multiple times to connect to multiple nodes. (custom only)", true, OptionsCategory::CHAINPARAMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <script/script.h> // mandatory_coinbase_destination
|
||||||
|
|
||||||
namespace Consensus {
|
namespace Consensus {
|
||||||
|
|
||||||
enum DeploymentPos
|
enum DeploymentPos
|
||||||
|
|
@ -75,6 +77,9 @@ struct Params {
|
||||||
int64_t DifficultyAdjustmentInterval() const { return nPowTargetTimespan / nPowTargetSpacing; }
|
int64_t DifficultyAdjustmentInterval() const { return nPowTargetTimespan / nPowTargetSpacing; }
|
||||||
uint256 nMinimumChainWork;
|
uint256 nMinimumChainWork;
|
||||||
uint256 defaultAssumeValid;
|
uint256 defaultAssumeValid;
|
||||||
|
|
||||||
|
// Elements-specific chainparams
|
||||||
|
CScript mandatory_coinbase_destination;
|
||||||
};
|
};
|
||||||
} // namespace Consensus
|
} // namespace Consensus
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1850,6 +1850,17 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
|
||||||
|
|
||||||
nBlocksTotal++;
|
nBlocksTotal++;
|
||||||
|
|
||||||
|
// Check that all non-zero coinbase outputs pay to the required destination
|
||||||
|
const CScript& mandatory_coinbase_destination = chainparams.GetConsensus().mandatory_coinbase_destination;
|
||||||
|
if (mandatory_coinbase_destination != CScript()) {
|
||||||
|
for (auto& txout : block.vtx[0]->vout) {
|
||||||
|
if (txout.scriptPubKey != mandatory_coinbase_destination && txout.nValue != 0) {
|
||||||
|
return state.DoS(100, error("ConnectBlock(): Coinbase outputs didnt match required scriptPubKey"),
|
||||||
|
REJECT_INVALID, "bad-coinbase-txos");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool fScriptChecks = true;
|
bool fScriptChecks = true;
|
||||||
if (!hashAssumeValid.IsNull()) {
|
if (!hashAssumeValid.IsNull()) {
|
||||||
// We've been configured with the hash of a block which has been externally verified to have a valid history.
|
// We've been configured with the hash of a block which has been externally verified to have a valid history.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue