Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

privatesend.cpp
Go to the documentation of this file.
1 // Copyright (c) 2014-2020 The Dash Core developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
6 
8 #include <consensus/validation.h>
11 #include <messagesigner.h>
12 #include <netmessagemaker.h>
13 #include <script/sign.h>
14 #include <txmempool.h>
15 #include <util.h>
16 #include <utilmoneystr.h>
17 #include <validation.h>
18 
21 
22 #include <string>
23 
25 {
26  for (auto& txdsin : vecTxDSIn) {
27  if (txdsin.prevout == txin.prevout && txdsin.nSequence == txin.nSequence) {
28  if (txdsin.fHasSig) return false;
29 
30  txdsin.scriptSig = txin.scriptSig;
31  txdsin.fHasSig = true;
32 
33  return true;
34  }
35  }
36 
37  return false;
38 }
39 
41 {
42  return SerializeHash(*this);
43 }
44 
46 {
47  if (!fMasternodeMode) return false;
48 
49 
50  uint256 hash = GetSignatureHash();
52  if (!sig.IsValid()) {
53  return false;
54  }
55  sig.GetBuf(vchSig);
56 
57  return true;
58 }
59 
61 {
62  uint256 hash = GetSignatureHash();
63 
64  CBLSSignature sig;
65  sig.SetBuf(vchSig);
66  if (!sig.IsValid() || !sig.VerifyInsecure(blsPubKey, hash)) {
67  LogPrint(BCLog::PRIVATESEND, "CPrivateSendQueue::CheckSignature -- VerifyInsecure() failed\n");
68  return false;
69  }
70 
71  return true;
72 }
73 
75 {
76  connman.ForEachNode([&connman, this](CNode* pnode) {
77  CNetMsgMaker msgMaker(pnode->GetSendVersion());
79  connman.PushMessage(pnode, msgMaker.Make(NetMsgType::DSQUEUE, (*this)));
80  }
81  });
82  return true;
83 }
84 
86 {
88 }
89 
91 {
92  return SerializeHash(*this);
93 }
94 
96 {
97  if (!fMasternodeMode) return false;
98 
99  uint256 hash = GetSignatureHash();
100 
102  if (!sig.IsValid()) {
103  return false;
104  }
105  sig.GetBuf(vchSig);
106 
107  return true;
108 }
109 
111 {
112  uint256 hash = GetSignatureHash();
113 
114  CBLSSignature sig;
115  sig.SetBuf(vchSig);
116  if (!sig.IsValid() || !sig.VerifyInsecure(blsPubKey, hash)) {
117  LogPrint(BCLog::PRIVATESEND, "CPrivateSendBroadcastTx::CheckSignature -- VerifyInsecure() failed\n");
118  return false;
119  }
120 
121  return true;
122 }
123 
125 {
126  // expire confirmed DSTXes after ~1h since confirmation or chainlocked confirmation
127  if (nConfirmedHeight == -1 || pindex->nHeight < nConfirmedHeight) return false; // not mined yet
128  if (pindex->nHeight - nConfirmedHeight > 24) return true; // mined more then an hour ago
129  return llmq::chainLocksHandler->HasChainLock(pindex->nHeight, *pindex->phashBlock);
130 }
131 
133 {
134  // some trivial checks only
135  if (tx->vin.size() != tx->vout.size()) {
136  return false;
137  }
138  if (tx->vin.size() < CPrivateSend::GetMinPoolParticipants()) {
139  return false;
140  }
142  return false;
143  }
144  for (const auto& out : tx->vout) {
145  if (!CPrivateSend::IsDenominatedAmount(out.nValue)) {
146  return false;
147  }
148  if (!out.scriptPubKey.IsPayToPublicKeyHash()) {
149  return false;
150  }
151  }
152  return true;
153 }
154 
156 {
157  // Both sides
160  nSessionID = 0;
161  nSessionDenom = 0;
162  vecEntries.clear();
166 }
167 
169 {
170  LOCK(cs_vecqueue);
171  vecPrivateSendQueue.clear();
172 }
173 
175 {
176  TRY_LOCK(cs_vecqueue, lockDS);
177  if (!lockDS) return; // it's ok to fail here, we run this quite frequently
178 
179  // check mixing queue objects for timeouts
180  auto it = vecPrivateSendQueue.begin();
181  while (it != vecPrivateSendQueue.end()) {
182  if ((*it).IsTimeOutOfBounds()) {
183  LogPrint(BCLog::PRIVATESEND, "CPrivateSendBaseManager::%s -- Removing a queue (%s)\n", __func__, (*it).ToString());
184  it = vecPrivateSendQueue.erase(it);
185  } else {
186  ++it;
187  }
188  }
189 }
190 
192 {
193  TRY_LOCK(cs_vecqueue, lockDS);
194  if (!lockDS) return false; // it's ok to fail here, we run this quite frequently
195 
196  for (auto& dsq : vecPrivateSendQueue) {
197  // only try each queue once
198  if (dsq.fTried || dsq.IsTimeOutOfBounds()) continue;
199  dsq.fTried = true;
200  dsqRet = dsq;
201  return true;
202  }
203 
204  return false;
205 }
206 
208 {
209  switch (nState) {
210  case POOL_STATE_IDLE:
211  return "IDLE";
212  case POOL_STATE_QUEUE:
213  return "QUEUE";
215  return "ACCEPTING_ENTRIES";
216  case POOL_STATE_SIGNING:
217  return "SIGNING";
218  case POOL_STATE_ERROR:
219  return "ERROR";
220  default:
221  return "UNKNOWN";
222  }
223 }
224 
225 bool CPrivateSendBaseSession::IsValidInOuts(const std::vector<CTxIn>& vin, const std::vector<CTxOut>& vout, PoolMessage& nMessageIDRet, bool* fConsumeCollateralRet) const
226 {
227  std::set<CScript> setScripPubKeys;
228  nMessageIDRet = MSG_NOERR;
229  if (fConsumeCollateralRet) *fConsumeCollateralRet = false;
230 
231  if (vin.size() != vout.size()) {
232  LogPrint(BCLog::PRIVATESEND, "CPrivateSendBaseSession::%s -- ERROR: inputs vs outputs size mismatch! %d vs %d\n", __func__, vin.size(), vout.size());
233  nMessageIDRet = ERR_SIZE_MISMATCH;
234  if (fConsumeCollateralRet) *fConsumeCollateralRet = true;
235  return false;
236  }
237 
238  auto checkTxOut = [&](const CTxOut& txout) {
239  int nDenom = CPrivateSend::AmountToDenomination(txout.nValue);
240  if (nDenom != nSessionDenom) {
241  LogPrint(BCLog::PRIVATESEND, "CPrivateSendBaseSession::IsValidInOuts -- ERROR: incompatible denom %d (%s) != nSessionDenom %d (%s)\n",
243  nMessageIDRet = ERR_DENOM;
244  if (fConsumeCollateralRet) *fConsumeCollateralRet = true;
245  return false;
246  }
247  if (!txout.scriptPubKey.IsPayToPublicKeyHash()) {
248  LogPrint(BCLog::PRIVATESEND, "CPrivateSendBaseSession::IsValidInOuts -- ERROR: invalid script! scriptPubKey=%s\n", ScriptToAsmStr(txout.scriptPubKey));
249  nMessageIDRet = ERR_INVALID_SCRIPT;
250  if (fConsumeCollateralRet) *fConsumeCollateralRet = true;
251  return false;
252  }
253  if (!setScripPubKeys.insert(txout.scriptPubKey).second) {
254  LogPrint(BCLog::PRIVATESEND, "CPrivateSendBaseSession::IsValidInOuts -- ERROR: already have this script! scriptPubKey=%s\n", ScriptToAsmStr(txout.scriptPubKey));
255  nMessageIDRet = ERR_ALREADY_HAVE;
256  if (fConsumeCollateralRet) *fConsumeCollateralRet = true;
257  return false;
258  }
259  // IsPayToPublicKeyHash() above already checks for scriptPubKey size,
260  // no need to double check, hence no usage of ERR_NON_STANDARD_PUBKEY
261  return true;
262  };
263 
264  CAmount nFees{0};
265 
266  for (const auto& txout : vout) {
267  if (!checkTxOut(txout)) {
268  return false;
269  }
270  nFees -= txout.nValue;
271  }
272 
273  CCoinsViewMemPool viewMemPool(pcoinsTip.get(), mempool);
274 
275  for (const auto& txin : vin) {
276  LogPrint(BCLog::PRIVATESEND, "CPrivateSendBaseSession::%s -- txin=%s\n", __func__, txin.ToString());
277 
278  if (txin.prevout.IsNull()) {
279  LogPrint(BCLog::PRIVATESEND, "CPrivateSendBaseSession::%s -- ERROR: invalid input!\n", __func__);
280  nMessageIDRet = ERR_INVALID_INPUT;
281  if (fConsumeCollateralRet) *fConsumeCollateralRet = true;
282  return false;
283  }
284 
285  Coin coin;
286  if (!viewMemPool.GetCoin(txin.prevout, coin) || coin.IsSpent() ||
287  (coin.nHeight == MEMPOOL_HEIGHT && !llmq::quorumInstantSendManager->IsLocked(txin.prevout.hash))) {
288  LogPrint(BCLog::PRIVATESEND, "CPrivateSendBaseSession::%s -- ERROR: missing, spent or non-locked mempool input! txin=%s\n", __func__, txin.ToString());
289  nMessageIDRet = ERR_MISSING_TX;
290  return false;
291  }
292 
293  if (!checkTxOut(coin.out)) {
294  return false;
295  }
296 
297  nFees += coin.out.nValue;
298  }
299 
300  // The same size and denom for inputs and outputs ensures their total value is also the same,
301  // no need to double check. If not, we are doing something wrong, bail out.
302  if (nFees != 0) {
303  LogPrint(BCLog::PRIVATESEND, "CPrivateSendBaseSession::%s -- ERROR: non-zero fees! fees: %lld\n", __func__, nFees);
304  nMessageIDRet = ERR_FEES;
305  return false;
306  }
307 
308  return true;
309 }
310 
311 // Definitions for static data members
312 std::vector<CAmount> CPrivateSend::vecStandardDenominations;
313 std::map<uint256, CPrivateSendBroadcastTx> CPrivateSend::mapDSTX;
315 
317 {
318  vecStandardDenominations.clear();
319  /* Denominations
320 
321  A note about convertibility. Within mixing pools, each denomination
322  is convertible to another.
323 
324  For example:
325  1DRK+1000 == (.1DRK+100)*10
326  10DRK+10000 == (1DRK+1000)*10
327  */
328  /* Disabled
329  vecStandardDenominations.push_back( (100 * COIN)+100000 );
330  */
331  vecStandardDenominations.push_back((10 * COIN) + 10000);
332  vecStandardDenominations.push_back((1 * COIN) + 1000);
333  vecStandardDenominations.push_back((.1 * COIN) + 100);
334  vecStandardDenominations.push_back((.01 * COIN) + 10);
335  vecStandardDenominations.push_back((.001 * COIN) + 1);
336 }
337 
338 // check to make sure the collateral provided by the client is valid
340 {
341  if (txCollateral.vout.empty()) return false;
342  if (txCollateral.nLockTime != 0) return false;
343 
344  CAmount nValueIn = 0;
345  CAmount nValueOut = 0;
346 
347  for (const auto& txout : txCollateral.vout) {
348  nValueOut += txout.nValue;
349 
350  if (!txout.scriptPubKey.IsPayToPublicKeyHash() && !txout.scriptPubKey.IsUnspendable()) {
351  LogPrint(BCLog::PRIVATESEND, "CPrivateSend::IsCollateralValid -- Invalid Script, txCollateral=%s", txCollateral.ToString());
352  return false;
353  }
354  }
355 
356  for (const auto& txin : txCollateral.vin) {
357  Coin coin;
358  auto mempoolTx = mempool.get(txin.prevout.hash);
359  if (mempoolTx != nullptr) {
360  if (mempool.isSpent(txin.prevout) || !llmq::quorumInstantSendManager->IsLocked(txin.prevout.hash)) {
361  LogPrint(BCLog::PRIVATESEND, "CPrivateSend::IsCollateralValid -- spent or non-locked mempool input! txin=%s\n", txin.ToString());
362  return false;
363  }
364  nValueIn += mempoolTx->vout[txin.prevout.n].nValue;
365  } else if (GetUTXOCoin(txin.prevout, coin)) {
366  nValueIn += coin.out.nValue;
367  } else {
368  LogPrint(BCLog::PRIVATESEND, "CPrivateSend::IsCollateralValid -- Unknown inputs in collateral transaction, txCollateral=%s", txCollateral.ToString());
369  return false;
370  }
371  }
372 
373  //collateral transactions are required to pay out a small fee to the miners
374  if (nValueIn - nValueOut < GetCollateralAmount()) {
375  LogPrint(BCLog::PRIVATESEND, "CPrivateSend::IsCollateralValid -- did not include enough fees in transaction: fees: %d, txCollateral=%s", nValueOut - nValueIn, txCollateral.ToString());
376  return false;
377  }
378 
379  LogPrint(BCLog::PRIVATESEND, "CPrivateSend::IsCollateralValid -- %s", txCollateral.ToString());
380 
381  {
382  LOCK(cs_main);
383  CValidationState validationState;
384  if (!AcceptToMemoryPool(mempool, validationState, MakeTransactionRef(txCollateral), nullptr /* pfMissingInputs */, false /* bypass_limits */, maxTxFee /* nAbsurdFee */, true /* fDryRun */)) {
385  LogPrint(BCLog::PRIVATESEND, "CPrivateSend::IsCollateralValid -- didn't pass AcceptToMemoryPool()\n");
386  return false;
387  }
388  }
389 
390  return true;
391 }
392 
394 {
395  // collateral input can be anything between 1x and "max" (including both)
396  return (nInputAmount >= GetCollateralAmount() && nInputAmount <= GetMaxCollateralAmount());
397 }
398 
399 /*
400  Return a bitshifted integer representing a denomination in vecStandardDenominations
401  or 0 if none was found
402 */
404 {
405  for (size_t i = 0; i < vecStandardDenominations.size(); ++i) {
406  if (nInputAmount == vecStandardDenominations[i]) {
407  return 1 << i;
408  }
409  }
410  return 0;
411 }
412 
413 /*
414  Returns:
415  - one of standard denominations from vecStandardDenominations based on the provided bitshifted integer
416  - 0 for non-initialized sessions (nDenom = 0)
417  - a value below 0 if an error occured while converting from one to another
418 */
420 {
421  if (nDenom == 0) {
422  // not initialized
423  return 0;
424  }
425 
426  size_t nMaxDenoms = vecStandardDenominations.size();
427 
428  if (nDenom >= (1 << nMaxDenoms) || nDenom < 0) {
429  // out of bounds
430  return -1;
431  }
432 
433  if ((nDenom & (nDenom - 1)) != 0) {
434  // non-denom
435  return -2;
436  }
437 
438  CAmount nDenomAmount{-3};
439 
440  for (size_t i = 0; i < nMaxDenoms; ++i) {
441  if (nDenom & (1 << i)) {
442  nDenomAmount = vecStandardDenominations[i];
443  break;
444  }
445  }
446 
447  return nDenomAmount;
448 }
449 
450 /*
451  Same as DenominationToAmount but returns a string representation
452 */
453 std::string CPrivateSend::DenominationToString(int nDenom)
454 {
455  CAmount nDenomAmount = DenominationToAmount(nDenom);
456 
457  switch (nDenomAmount) {
458  case 0: return "N/A";
459  case -1: return "out-of-bounds";
460  case -2: return "non-denom";
461  case -3: return "to-amount-error";
462  default: return ValueFromAmount(nDenomAmount).getValStr();
463  }
464 
465  // shouldn't happen
466  return "to-string-error";
467 }
468 
470 {
471  return AmountToDenomination(nInputAmount) > 0;
472 }
473 
475 {
476  return DenominationToAmount(nDenom) > 0;
477 }
478 
480 {
481  switch (nMessageID) {
482  case ERR_ALREADY_HAVE:
483  return _("Already have that input.");
484  case ERR_DENOM:
485  return _("No matching denominations found for mixing.");
486  case ERR_ENTRIES_FULL:
487  return _("Entries are full.");
488  case ERR_EXISTING_TX:
489  return _("Not compatible with existing transactions.");
490  case ERR_FEES:
491  return _("Transaction fees are too high.");
493  return _("Collateral not valid.");
494  case ERR_INVALID_INPUT:
495  return _("Input is not valid.");
496  case ERR_INVALID_SCRIPT:
497  return _("Invalid script detected.");
498  case ERR_INVALID_TX:
499  return _("Transaction not valid.");
500  case ERR_MAXIMUM:
501  return _("Entry exceeds maximum size.");
502  case ERR_MN_LIST:
503  return _("Not in the Masternode list.");
504  case ERR_MODE:
505  return _("Incompatible mode.");
506  case ERR_QUEUE_FULL:
507  return _("Masternode queue is full.");
508  case ERR_RECENT:
509  return _("Last PrivateSend was too recent.");
510  case ERR_SESSION:
511  return _("Session not complete!");
512  case ERR_MISSING_TX:
513  return _("Missing input transaction information.");
514  case ERR_VERSION:
515  return _("Incompatible version.");
516  case MSG_NOERR:
517  return _("No errors detected.");
518  case MSG_SUCCESS:
519  return _("Transaction created successfully.");
520  case MSG_ENTRIES_ADDED:
521  return _("Your entries added successfully.");
522  case ERR_SIZE_MISMATCH:
523  return _("Inputs vs outputs size mismatch.");
525  case ERR_NOT_A_MN:
526  default:
527  return _("Unknown response.");
528  }
529 }
530 
532 {
533  LOCK(cs_mapdstx);
534  mapDSTX.insert(std::make_pair(dstx.tx->GetHash(), dstx));
535 }
536 
538 {
539  LOCK(cs_mapdstx);
540  auto it = mapDSTX.find(hash);
541  return (it == mapDSTX.end()) ? CPrivateSendBroadcastTx() : it->second;
542 }
543 
545 {
546  LOCK(cs_mapdstx);
547  auto it = mapDSTX.begin();
548  while (it != mapDSTX.end()) {
549  if (it->second.IsExpired(pindex)) {
550  mapDSTX.erase(it++);
551  } else {
552  ++it;
553  }
554  }
555  LogPrint(BCLog::PRIVATESEND, "CPrivateSend::CheckDSTXes -- mapDSTX.size()=%llu\n", mapDSTX.size());
556 }
557 
559 {
560  if (pindex && masternodeSync.IsBlockchainSynced()) {
561  CheckDSTXes(pindex);
562  }
563 }
564 
566 {
567  if (pindex && masternodeSync.IsBlockchainSynced()) {
568  CheckDSTXes(pindex);
569  }
570 }
571 
573 {
575 
576  auto it = mapDSTX.find(tx->GetHash());
577  if (it == mapDSTX.end()) {
578  return;
579  }
580 
581  it->second.SetConfirmedHeight(nHeight);
582  LogPrint(BCLog::PRIVATESEND, "CPrivateSend::%s -- txid=%s, nHeight=%d\n", __func__, tx->GetHash().ToString(), nHeight);
583 }
584 
586 {
587  LOCK(cs_mapdstx);
589 }
590 
591 void CPrivateSend::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex, const std::vector<CTransactionRef>& vtxConflicted)
592 {
593  LOCK(cs_mapdstx);
594  for (const auto& tx : vtxConflicted) {
596  }
597 
598  for (const auto& tx : pblock->vtx) {
599  UpdateDSTXConfirmedHeight(tx, pindex->nHeight);
600  }
601 }
602 
603 void CPrivateSend::BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexDisconnected)
604 {
605  LOCK(cs_mapdstx);
606  for (const auto& tx : pblock->vtx) {
608  }
609 }
CAmount nValue
Definition: transaction.h:147
static void UpdatedBlockTip(const CBlockIndex *pindex)
CTxMemPool mempool
std::vector< unsigned char > vchSig
Definition: privatesend.h:222
bool IsSpent() const
Definition: coins.h:75
CMasternodeSync masternodeSync
int GetSendVersion() const
Definition: net.cpp:887
static void CheckDSTXes(const CBlockIndex *pindex)
static bool IsDenominatedAmount(CAmount nInputAmount)
uint256 GetSignatureHash() const
Definition: privatesend.cpp:90
#define TRY_LOCK(cs, name)
Definition: sync.h:180
bool CheckSignature(const CBLSPublicKey &blsPubKey) const
Check if we have a valid Masternode address.
Definition: privatesend.cpp:60
static CAmount GetCollateralAmount()
Definition: privatesend.h:460
A UTXO entry.
Definition: coins.h:29
std::vector< CPrivateSendEntry > vecEntries
Definition: privatesend.h:364
static void BlockConnected(const std::shared_ptr< const CBlock > &pblock, const CBlockIndex *pindex, const std::vector< CTransactionRef > &vtxConflicted)
void SetBuf(const void *buf, size_t size)
Definition: bls.h:99
CAmount maxTxFee
Absolute maximum transaction fee (in duffs) used by wallet and mempool (rejects high fee in sendrawtr...
Definition: validation.cpp:247
bool isSpent(const COutPoint &outpoint)
Definition: txmempool.cpp:344
bool HasChainLock(int nHeight, const uint256 &blockHash)
std::vector< CTxIn > vin
Definition: transaction.h:293
static const CAmount COIN
Definition: amount.h:14
std::vector< CTxDSIn > vecTxDSIn
Definition: privatesend.h:176
A currently in progress mixing merge and denomination information.
Definition: privatesend.h:215
static int GetMaxPoolParticipants()
Definition: privatesend.h:452
CCriticalSection cs_main
Definition: validation.cpp:213
CTxOut out
unspent transaction output
Definition: coins.h:33
UniValue ValueFromAmount(const CAmount &amount)
Definition: core_write.cpp:25
void PushMessage(CNode *pnode, CSerializedNetMsg &&msg)
Definition: net.cpp:3733
PoolMessage
Definition: privatesend.h:33
bool Relay(CConnman &connman)
Definition: privatesend.cpp:74
bool VerifyInsecure(const CBLSPublicKey &pubKey, const uint256 &hash) const
Definition: bls.cpp:335
static CCriticalSection cs_mapdstx
Definition: privatesend.h:430
static int AmountToDenomination(CAmount nInputAmount)
CMutableTransaction finalMutableTransaction
Definition: privatesend.h:371
static void NotifyChainLock(const CBlockIndex *pindex)
static const int PRIVATESEND_QUEUE_TIMEOUT
Definition: privatesend.h:24
bool IsBlockchainSynced()
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:345
const std::string & getValStr() const
Definition: univalue.h:66
const std::vector< CTxIn > vin
Definition: transaction.h:215
void ForEachNode(const Condition &cond, Callable &&func)
Definition: net.h:288
static void BlockDisconnected(const std::shared_ptr< const CBlock > &pblock, const CBlockIndex *pindexDisconnected)
CInstantSendManager * quorumInstantSendManager
std::unique_ptr< CCoinsViewCache > pcoinsTip
Global variable that points to the active CCoinsView (protected by cs_main)
Definition: validation.cpp:300
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
static std::vector< CAmount > vecStandardDenominations
Definition: privatesend.h:427
void GetBuf(void *buf, size_t size) const
Definition: bls.h:122
uint32_t nHeight
at which height this containing transaction was included in the active block chain ...
Definition: coins.h:39
uint256 SerializeHash(const T &obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
Compute the 256-bit hash of an object&#39;s serialization.
Definition: hash.h:254
static void UpdateDSTXConfirmedHeight(const CTransactionRef &tx, int nHeight)
static CTransactionRef MakeTransactionRef()
Definition: transaction.h:346
int64_t GetTime()
Return system time (or mocked time, if set)
Definition: utiltime.cpp:22
static const uint32_t MEMPOOL_HEIGHT
Fake height value used in Coin to signify they are only in the memory pool (since 0...
Definition: txmempool.h:38
bool fMasternodeMode
Definition: util.cpp:93
bool GetUTXOCoin(const COutPoint &outpoint, Coin &coin)
Definition: validation.cpp:439
CChainLocksHandler * chainLocksHandler
static int GetMinPoolParticipants()
Get the minimum/maximum number of participants for the pool.
Definition: privatesend.h:449
static void InitStandardDenominations()
CActiveMasternodeInfo activeMasternodeInfo
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode=false)
Create the assembly string representation of a CScript object.
Definition: core_write.cpp:86
static bool IsCollateralValid(const CTransaction &txCollateral)
If the collateral is valid given by a client.
bool GetQueueItemAndTry(CPrivateSendQueue &dsqRet)
An input of a transaction.
Definition: transaction.h:70
static CPrivateSendBroadcastTx GetDSTX(const uint256 &hash)
#define LOCK(cs)
Definition: sync.h:178
uint256 GetSignatureHash() const
Definition: privatesend.cpp:40
CCriticalSection cs_vecqueue
Definition: privatesend.h:400
bool IsLocked(const uint256 &txHash)
const std::vector< CTxOut > vout
Definition: transaction.h:216
std::vector< CPrivateSendQueue > vecPrivateSendQueue
Definition: privatesend.h:403
Definition: net.h:136
static void TransactionAddedToMempool(const CTransactionRef &tx)
std::vector< unsigned char > vchSig
Definition: privatesend.h:301
An output of a transaction.
Definition: transaction.h:144
static void AddDSTX(const CPrivateSendBroadcastTx &dstx)
bool IsExpired(const CBlockIndex *pindex)
std::vector< CTxOut > vout
Definition: transaction.h:294
bool IsTimeOutOfBounds() const
Check if a queue is too old or too far into the future.
Definition: privatesend.cpp:85
CCriticalSection cs_privatesend
Definition: privatesend.h:362
CScript scriptSig
Definition: transaction.h:74
#define LogPrint(category,...)
Definition: util.h:214
Capture information about block/transaction validation.
Definition: validation.h:22
256-bit opaque blob.
Definition: uint256.h:123
std::string GetStateString() const
static bool IsValidDenomination(int nDenom)
Helper class to store mixing transaction (tx) information.
Definition: privatesend.h:291
const char * DSQUEUE
Definition: protocol.cpp:54
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: chain.h:170
uint32_t nSequence
Definition: transaction.h:75
bool AcceptToMemoryPool(CTxMemPool &pool, CValidationState &state, const CTransactionRef &tx, bool *pfMissingInputs, bool bypass_limits, const CAmount nAbsurdFee, bool fDryRun)
(try to) add transaction to memory pool
Definition: validation.cpp:890
int64_t GetAdjustedTime()
Definition: timedata.cpp:35
std::string ToString() const
static const int MIN_PRIVATESEND_PEER_PROTO_VERSION
minimum peer version accepted by mixing pool
Definition: privatesend.h:28
bool Sign()
Sign this mixing transaction.
Definition: privatesend.cpp:45
static std::string GetMessageByID(PoolMessage nMessageID)
static std::map< uint256, CPrivateSendBroadcastTx > mapDSTX
Definition: privatesend.h:428
static CAmount GetMaxCollateralAmount()
Definition: privatesend.h:461
bool IsValidInOuts(const std::vector< CTxIn > &vin, const std::vector< CTxOut > &vout, PoolMessage &nMessageIDRet, bool *fConsumeCollateralRet) const
std::atomic< int > nVersion
Definition: net.h:838
bool CheckSignature(const CBLSPublicKey &blsPubKey) const
static bool IsCollateralAmount(CAmount nInputAmount)
CTransactionRef get(const uint256 &hash) const
Definition: txmempool.cpp:1211
bool AddScriptSig(const CTxIn &txin)
Definition: privatesend.cpp:24
std::atomic< bool > fSendDSQueue
Definition: net.h:935
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:198
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition: chain.h:183
Information about a peer.
Definition: net.h:800
AssertLockHeld(g_cs_orphans)
CTransactionRef tx
Definition: privatesend.h:299
COutPoint prevout
Definition: transaction.h:73
static CAmount DenominationToAmount(int nDenom)
CCoinsView that brings transactions from a memorypool into view.
Definition: txmempool.h:739
std::unique_ptr< CBLSSecretKey > blsKeyOperator
bool IsValid() const
Definition: bls.h:94
static std::string DenominationToString(int nDenom)
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result...
Definition: util.h:92
Wrapped mutex: supports recursive locking, but no waiting TODO: We should move away from using the re...
Definition: sync.h:94
const uint32_t nLockTime
Definition: transaction.h:219
static const size_t PRIVATESEND_ENTRY_MAX_SIZE
Definition: privatesend.h:30
const uint256 * phashBlock
pointer to the hash of the block, if any. Memory is owned by this CBlockIndex
Definition: chain.h:174
Released under the MIT license