Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add undo in ReversGeneralCoinbaseTx() #1641

Merged
merged 2 commits into from
Dec 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down