Skip to content

Commit

Permalink
Accept non-spent LLMQ IS locked outpoints from mempool in PS mixing (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
UdjinM6 committed Apr 29, 2019
1 parent 2652030 commit 7f419ae
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/privatesend-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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());
Expand Down
14 changes: 12 additions & 2 deletions src/privatesend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "utilmoneystr.h"
#include "validation.h"

#include "llmq/quorums_instantsend.h"

#include <string>

bool CPrivateSendEntry::AddScriptSig(const CTxIn& txin)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7f419ae

Please sign in to comment.