From af085cd5282e0565021f4ea926ad3077a86a72c9 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 17 Aug 2022 16:45:04 +0300 Subject: [PATCH] fix: Allow triggers with p2sh after DIP0024 (#4973) --- src/governance/classes.cpp | 22 +++++++++++----------- src/governance/governance.cpp | 4 +++- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/governance/classes.cpp b/src/governance/classes.cpp index a682c0c096..938c4e145f 100644 --- a/src/governance/classes.cpp +++ b/src/governance/classes.cpp @@ -527,6 +527,9 @@ void CSuperblock::ParsePaymentSchedule(const std::string& strPaymentAddresses, c AMOUNTS = [AMOUNT1|2|3|4|5|6] */ + // TODO: script addresses limit here and cs_main lock in + // CGovernanceManager::InitOnLoad()once DIP0024 is active + bool fAllowScript = (VersionBitsTipState(Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0024) == ThresholdState::ACTIVE); for (int i = 0; i < (int)vecParsed1.size(); i++) { CTxDestination dest = DecodeDestination(vecParsed1[i]); if (!IsValidDestination(dest)) { @@ -535,18 +538,15 @@ void CSuperblock::ParsePaymentSchedule(const std::string& strPaymentAddresses, c LogPrintf("%s\n", ostr.str()); throw std::runtime_error(ostr.str()); } - /* - TODO - - There might be an issue with multisig in the coinbase on mainnet, we will add support for it in a future release. - - Post 12.3+ (test multisig coinbase transaction) - */ - const CScriptID *scriptID = boost::get(&dest); - if (scriptID) { - std::ostringstream ostr; - ostr << "CSuperblock::ParsePaymentSchedule -- Script addresses are not supported yet : " << vecParsed1[i]; - LogPrintf("%s\n", ostr.str()); - throw std::runtime_error(ostr.str()); + if (!fAllowScript) { + const CScriptID *scriptID = boost::get(&dest); + if (scriptID) { + std::ostringstream ostr; + ostr << "CSuperblock::ParsePaymentSchedule -- Script addresses are not supported yet : " << vecParsed1[i]; + LogPrintf("%s\n", ostr.str()); + throw std::runtime_error(ostr.str()); + } } CAmount nAmount = ParsePaymentAmount(vecParsed2[i]); diff --git a/src/governance/governance.cpp b/src/governance/governance.cpp index 15659b9bdb..b60c205345 100644 --- a/src/governance/governance.cpp +++ b/src/governance/governance.cpp @@ -1098,7 +1098,9 @@ void CGovernanceManager::AddCachedTriggers() void CGovernanceManager::InitOnLoad() { - LOCK(cs); + // TODO: drop cs_main here and script addresses limit in + // CSuperblock::ParsePaymentSchedule() once DIP0024 is active + LOCK2(cs_main, cs); int64_t nStart = GetTimeMillis(); LogPrintf("Preparing masternode indexes and governance triggers...\n"); RebuildIndexes();