Skip to content

Commit 4968454

Browse files
committed
Enforce correct coinstake payment
1 parent 559e4f1 commit 4968454

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/validation.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "validation.h"
1212

1313
#include "addrman.h"
14+
#include "amount.h"
1415
#include "blocksignature.h"
1516
#include "budget/budgetmanager.h"
1617
#include "chainparams.h"
@@ -1567,6 +1568,15 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
15671568
CAmount txValueOut = tx.GetValueOut();
15681569
if (!tx.IsCoinBase()) {
15691570
CAmount txValueIn = view.GetValueIn(tx);
1571+
// Check that CoinStake pays the expected amount
1572+
if (tx.IsCoinStake() && isV6UpgradeEnforced) {
1573+
CAmount stakeMint = txValueOut - txValueIn;
1574+
CAmount nExpectedStakeMint = GetBlockValue(pindex->nHeight) - GetMasternodePayment(pindex->nHeight);
1575+
if (stakeMint != nExpectedStakeMint) {
1576+
return state.DoS(100, error("%s: coinstake pays too much (actual=%s vs limit=%s)", __func__, FormatMoney(stakeMint), FormatMoney(nExpectedStakeMint)),
1577+
REJECT_INVALID, "bad-blk-stake-amount");
1578+
}
1579+
}
15701580
if (!tx.IsCoinStake())
15711581
nFees += txValueIn - txValueOut;
15721582
nValueIn += txValueIn;

0 commit comments

Comments
 (0)