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

getblock RPC #2291

Merged
merged 17 commits into from
Aug 7, 2023
10 changes: 5 additions & 5 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2054,8 +2054,8 @@ Res ApplyGeneralCoinbaseTx(CCustomCSView & mnview, CTransaction const & tx, int
if (cbValues.size() != 1 || cbValues.begin()->first != DCT_ID{0})
return Res::ErrDbg("bad-cb-wrong-tokens", "coinbase should pay only Defi coins");

auto finalCheckAndReturn = [&]() {
if (cbValues.at(DCT_ID{0}) > blockReward + nFees)
auto finalCheckAndReturn = [&](const CAmount reward) {
prasannavl marked this conversation as resolved.
Show resolved Hide resolved
if (cbValues.at(DCT_ID{0}) > reward + nFees)
return Res::ErrDbg("bad-cb-amount", "coinbase pays too much (actual=%d vs limit=%d)", cbValues.at(DCT_ID{0}), blockReward + nFees);
return Res::Ok();
};
Expand Down Expand Up @@ -2120,7 +2120,7 @@ Res ApplyGeneralCoinbaseTx(CCustomCSView & mnview, CTransaction const & tx, int
nonUtxoTotal += subsidy;
}
blockReward -= nonUtxoTotal;
return finalCheckAndReturn();
return finalCheckAndReturn(blockReward);
};

auto handleCurrentTokenRewards = [&finalCheckAndReturn, &logAccountChange, &isGovernanceEnabled, &isUnusedEmissionFundEnabled](const CTransaction& tx, CAmount blockReward, CCustomCSView& view, const Consensus::Params& consensus, int height) {
Expand Down Expand Up @@ -2186,13 +2186,13 @@ Res ApplyGeneralCoinbaseTx(CCustomCSView & mnview, CTransaction const & tx, int
}

blockReward -= nonUtxoTotal;
return finalCheckAndReturn();
return finalCheckAndReturn(blockReward);
};

// Actual logic starts here

if (height < consensus.AMKHeight) {
return finalCheckAndReturn();
return finalCheckAndReturn(blockReward);
}

if (auto r = tryVerifyUtxoRewards(tx, blockReward, height, consensus); !r) {
Expand Down