Merge pull request #5832 from therealyingtong/miner-latest-height
Use height of latest network upgrade in -mineraddress validation.
This commit is contained in:
commit
5f60f33daf
|
@ -25,6 +25,15 @@ namespace Consensus {
|
|||
return NetworkUpgradeState(nHeight, *this, idx) == UPGRADE_ACTIVE;
|
||||
}
|
||||
|
||||
int Params::HeightOfLatestSettledUpgrade() const {
|
||||
for (auto idxInt = Consensus::MAX_NETWORK_UPGRADES - 1; idxInt > Consensus::BASE_SPROUT; idxInt--) {
|
||||
if (vUpgrades[idxInt].hashActivationBlock.has_value()) {
|
||||
return vUpgrades[idxInt].nActivationHeight;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Params::FeatureRequired(const Consensus::ConsensusFeature feature) const {
|
||||
return vRequiredFeatures.count(feature) > 0;
|
||||
}
|
||||
|
|
|
@ -237,6 +237,12 @@ struct Params {
|
|||
*/
|
||||
bool NetworkUpgradeActive(int nHeight, Consensus::UpgradeIndex idx) const;
|
||||
|
||||
/**
|
||||
* Returns the activation height of the latest settled upgrade, as defined
|
||||
* in <https://zips.z.cash/protocol/protocol.pdf#blockchain>.
|
||||
*/
|
||||
int HeightOfLatestSettledUpgrade() const;
|
||||
|
||||
bool FutureTimestampSoftForkActive(int nHeight) const;
|
||||
|
||||
bool FeatureActive(int nHeight, Consensus::ConsensusFeature feature) const;
|
||||
|
|
|
@ -1099,9 +1099,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||
#ifdef ENABLE_MINING
|
||||
if (mapArgs.count("-mineraddress")) {
|
||||
auto addr = keyIO.DecodePaymentAddress(mapArgs["-mineraddress"]);
|
||||
if (!(addr.has_value() && std::visit(ExtractMinerAddress(chainparams.GetConsensus(), 0), addr.value()).has_value())) {
|
||||
auto consensus = chainparams.GetConsensus();
|
||||
int height = consensus.HeightOfLatestSettledUpgrade();
|
||||
if (!(addr.has_value() && std::visit(ExtractMinerAddress(consensus, height), addr.value()).has_value())) {
|
||||
return InitError(strprintf(
|
||||
_("Invalid address for -mineraddress=<addr>: '%s' (must be a Sapling or transparent P2PKH address)"),
|
||||
_("Invalid address for -mineraddress=<addr>: '%s' (must be a Sapling or transparent P2PKH address, or a Unified Address containing a valid receiver for the most recent settled network upgrade.)"),
|
||||
mapArgs["-mineraddress"]));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue