From cbbeb307168a1522b2588e944a02e0061006a787 Mon Sep 17 00:00:00 2001 From: jouzo Date: Mon, 30 Jan 2023 18:49:05 +0100 Subject: [PATCH] Revert "Revert "Add undo in ReversGeneralCoinbaseTx() (#1641)"" This reverts commit 152eda8ad4aeb00197480945e917ff67ae586c3a. --- src/validation.cpp | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index e74189971c2..34001b5e4c0 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2223,23 +2223,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; }