diff --git a/src/privatesend-server.cpp b/src/privatesend-server.cpp index 9b03e95bbd..761ec9e1f0 100644 --- a/src/privatesend-server.cpp +++ b/src/privatesend-server.cpp @@ -18,6 +18,8 @@ #include "utilmoneystr.h" #include "validation.h" +#include "llmq/quorums_instantsend.h" + CPrivateSendServer privateSendServer; void CPrivateSendServer::ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman) @@ -217,7 +219,15 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, const std::string& strComm LogPrint("privatesend", "DSVIN -- txin=%s\n", txin.ToString()); Coin coin; - if (GetUTXOCoin(txin.prevout, coin)) { + auto mempoolTx = mempool.get(txin.prevout.hash); + if (mempoolTx != nullptr) { + if (mempool.isSpent(txin.prevout) || !llmq::quorumInstantSendManager->IsLocked(txin.prevout.hash)) { + LogPrintf("DSVIN -- spent or non-locked mempool input! txin=%s\n", txin.ToString()); + PushStatus(pfrom, STATUS_REJECTED, ERR_MISSING_TX, connman); + return; + } + nValueIn += mempoolTx->vout[txin.prevout.n].nValue; + } else if (GetUTXOCoin(txin.prevout, coin)) { nValueIn += coin.out.nValue; } else { LogPrintf("DSVIN -- missing input! txin=%s\n", txin.ToString()); diff --git a/src/privatesend.cpp b/src/privatesend.cpp index e7b2e9efbb..f96f0dfba0 100644 --- a/src/privatesend.cpp +++ b/src/privatesend.cpp @@ -16,6 +16,8 @@ #include "utilmoneystr.h" #include "validation.h" +#include "llmq/quorums_instantsend.h" + #include bool CPrivateSendEntry::AddScriptSig(const CTxIn& txin) @@ -238,11 +240,19 @@ bool CPrivateSend::IsCollateralValid(const CTransaction& txCollateral) for (const auto& txin : txCollateral.vin) { Coin coin; - if (!GetUTXOCoin(txin.prevout, coin)) { + auto mempoolTx = mempool.get(txin.prevout.hash); + if (mempoolTx != nullptr) { + if (mempool.isSpent(txin.prevout) || !llmq::quorumInstantSendManager->IsLocked(txin.prevout.hash)) { + LogPrint("privatesend", "CPrivateSend::IsCollateralValid -- spent or non-locked mempool input! txin=%s\n", txin.ToString()); + return false; + } + nValueIn += mempoolTx->vout[txin.prevout.n].nValue; + } else if (GetUTXOCoin(txin.prevout, coin)) { + nValueIn += coin.out.nValue; + } else { LogPrint("privatesend", "CPrivateSend::IsCollateralValid -- Unknown inputs in collateral transaction, txCollateral=%s", txCollateral.ToString()); return false; } - nValueIn += coin.out.nValue; } //collateral transactions are required to pay out a small fee to the miners