Skip to content

Commit

Permalink
CMasternode::IsInputAssociatedWithPubkey use coins cache instead of d…
Browse files Browse the repository at this point in the history
…isk lookup.
  • Loading branch information
furszy committed Oct 1, 2021
1 parent 100f81f commit 0c0e4c0
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,16 @@ bool CMasternode::IsValidNetAddr() const

bool CMasternode::IsInputAssociatedWithPubkey() const
{
CScript payee;
payee = GetScriptForDestination(pubKeyCollateralAddress.GetID());

CTransactionRef txVin;
uint256 hash;
if(GetTransaction(vin.prevout.hash, txVin, hash, true)) {
for (const CTxOut& out : txVin->vout) {
if (out.nValue == Params().GetConsensus().nMNCollateralAmt &&
out.scriptPubKey == payee)
return true;
}
CScript payee = GetScriptForDestination(pubKeyCollateralAddress.GetID());
const Coin& collateralUtxo = pcoinsTip->AccessCoin(vin.prevout);
if (collateralUtxo.IsSpent()) {
LogPrint(BCLog::MASTERNODE,"%s mnb - vin %s spent\n", __func__, vin.prevout.ToString());
return false;
}

if (collateralUtxo.out.nValue == Params().GetConsensus().nMNCollateralAmt &&
collateralUtxo.out.scriptPubKey == payee) {
return true;
}

return false;
Expand Down

0 comments on commit 0c0e4c0

Please sign in to comment.