From 9283f6f33a209aba6b7fa606c56a41713b0ba8b6 Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Fri, 9 Dec 2022 06:54:06 +0800 Subject: [PATCH] Add undo in ReversGeneralCoinbaseTx() (#1641) Co-authored-by: Mihailo Milenkovic --- src/validation.cpp | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index a133f56b71..e7616fe88e 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2225,23 +2225,34 @@ void ReverseGeneralCoinbaseTx(CCustomCSView & mnview, int height, const Consensu // Remove Loan and Options balances from Unallocated if ((height < Params().GetConsensus().FortCanningHeight && kv.first == CommunityAccountType::Loan) || - kv.first == CommunityAccountType::Options) + (height < consensus.GrandCentralHeight && kv.first == CommunityAccountType::Options)) { mnview.SubCommunityBalance(CommunityAccountType::Unallocated, subsidy); } else { - if (height >= consensus.GrandCentralHeight && kv.first == CommunityAccountType::CommunityDevFunds) + if (height >= consensus.GrandCentralHeight) { - CDataStructureV0 enabledKey{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::GovernanceEnabled}; + const auto attributes = mnview.GetAttributes(); + assert(attributes); - auto attributes = mnview.GetAttributes(); - if (!attributes) { - return; - } - if (!attributes->GetValue(enabledKey, false)) - { - mnview.SubBalance(consensus.foundationShareScript, {DCT_ID{0}, subsidy}); + if (kv.first == CommunityAccountType::CommunityDevFunds) { + CDataStructureV0 enabledKey{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::GovernanceEnabled}; + + if (!attributes->GetValue(enabledKey, false)) + { + mnview.SubBalance(consensus.foundationShareScript, {DCT_ID{0}, subsidy}); + + continue; + } + } else if (kv.first == CommunityAccountType::Unallocated || kv.first == CommunityAccountType::Options) { + CDataStructureV0 enabledKey{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::EmissionUnusedFund}; + + if (attributes->GetValue(enabledKey, false)) { + mnview.SubBalance(consensus.unusedEmission, {DCT_ID{0}, subsidy}); + } else { + mnview.SubCommunityBalance(CommunityAccountType::Unallocated, subsidy); + } continue; }