Skip to content
Open
Changes from 1 commit
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: 6 additions & 25 deletions src/budget/budgetmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1625,40 +1625,21 @@ bool CheckCollateral(const uint256& nTxCollateralHash, const uint256& nExpectedH
return false;
}

if (txCollateral->vout.size() < 1) return false;
if (txCollateral->vout.empty()) return false;
if (txCollateral->nLockTime != 0) return false;

CScript findScript;
findScript << OP_RETURN << ToByteVector(nExpectedHash);
CScript findScript = CScript() << OP_RETURN << ToByteVector(nExpectedHash);
Comment thread
furszy marked this conversation as resolved.
CAmount expectedAmount = fBudgetFinalization ? BUDGET_FEE_TX : PROPOSAL_FEE_TX;

bool foundOpReturn = false;
for (const CTxOut &o : txCollateral->vout) {
if (!o.scriptPubKey.IsPayToPublicKeyHash() && !o.scriptPubKey.IsUnspendable()) {
strError = strprintf("Invalid Script %s", txCollateral->ToString());
return false;
}
if (fBudgetFinalization) {
// Collateral for budget finalization
// Note: there are still old valid budgets out there, but the check for the new 5 PIV finalization collateral
// will also cover the old 50 PIV finalization collateral.
LogPrint(BCLog::MNBUDGET, "Final Budget: o.scriptPubKey(%s) == findScript(%s) ?\n", HexStr(o.scriptPubKey), HexStr(findScript));
if (o.scriptPubKey == findScript) {
LogPrint(BCLog::MNBUDGET, "Final Budget: o.nValue(%ld) >= BUDGET_FEE_TX(%ld) ?\n", o.nValue, BUDGET_FEE_TX);
if(o.nValue >= BUDGET_FEE_TX) {
foundOpReturn = true;
break;
}
}
} else {
// Collateral for normal budget proposal
LogPrint(BCLog::MNBUDGET, "Normal Budget: o.scriptPubKey(%s) == findScript(%s) ?\n", HexStr(o.scriptPubKey), HexStr(findScript));
if (o.scriptPubKey == findScript) {
LogPrint(BCLog::MNBUDGET, "Normal Budget: o.nValue(%ld) >= PROPOSAL_FEE_TX(%ld) ?\n", o.nValue, PROPOSAL_FEE_TX);
if(o.nValue >= PROPOSAL_FEE_TX) {
foundOpReturn = true;
break;
}
}
if (o.scriptPubKey == findScript && o.nValue == expectedAmount) {
foundOpReturn = true;
break;
}
}

Expand Down