PRCYCoin  2.0.0.7rc1
P2P Digital Currency
swifttx.cpp
Go to the documentation of this file.
1 // Copyright (c) 2014-2016 The Dash developers
2 // Copyright (c) 2015-2018 The PIVX developers
3 // Copyright (c) 2018-2020 The DAPS Project developers
4 // Distributed under the MIT/X11 software license, see the accompanying
5 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 
7 #include "swifttx.h"
8 
9 #include "activemasternode.h"
10 #include "base58.h"
11 #include "key.h"
12 #include "masternode-sync.h"
13 #include "masternodeman.h"
14 #include "messagesigner.h"
15 #include "net.h"
16 #include "protocol.h"
17 #include "sync.h"
18 #include "util.h"
19 #include "validationinterface.h"
20 
21 #include <boost/foreach.hpp>
22 
23 
24 std::map<uint256, CTransaction> mapTxLockReq;
25 std::map<uint256, CTransaction> mapTxLockReqRejected;
26 std::map<uint256, CConsensusVote> mapTxLockVote;
27 std::map<uint256, CTransactionLock> mapTxLocks;
28 std::map<COutPoint, uint256> mapLockedInputs;
29 std::map<uint256, int64_t> mapUnknownVotes; //track votes with no tx for DOS
31 
32 //txlock - Locks transaction
33 //
34 //step 1.) Broadcast intention to lock transaction inputs, "txlreg", CTransaction
35 //step 2.) Top SWIFTTX_SIGNATURES_TOTAL masternodes, open connect to top 1 masternode.
36 // Send "txvote", CTransaction, Signature, Approve
37 //step 3.) Top 1 masternode, waits for SWIFTTX_SIGNATURES_REQUIRED messages. Upon success, sends "txlock'
38 
39 void ProcessMessageSwiftTX(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
40 {
41  if (fLiteMode) return; //disable all masternode related functionality
42  if (!masternodeSync.IsBlockchainSynced()) return;
43 
44  if (strCommand == NetMsgType::IX) {
45  CDataStream vMsg(vRecv);
46  CTransaction tx;
47  vRecv >> tx;
48 
49  CInv inv(MSG_TXLOCK_REQUEST, tx.GetHash());
50  pfrom->AddInventoryKnown(inv);
52 
53  if (mapTxLockReq.count(tx.GetHash()) || mapTxLockReqRejected.count(tx.GetHash())) {
54  return;
55  }
56 
57  if (!IsIXTXValid(tx)) {
58  return;
59  }
60 
61  for (const CTxOut &o : tx.vout) {
62  // IX supports normal scripts and unspendable scripts (used in DS collateral and Budget collateral).
63  // TODO: Look into other script types that are normal and can be included
65  LogPrintf("ProcessMessageSwiftTX::ix - Invalid Script %s\n", tx.ToString().c_str());
66  return;
67  }
68  }
69 
70  int nBlockHeight = CreateNewLock(tx);
71 
72  bool fMissingInputs = false;
73  CValidationState state;
74 
75  bool fAccepted = false;
76  {
77  LOCK(cs_main);
78  fAccepted = AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs);
79  }
80  if (fAccepted) {
81  RelayInv(inv);
82 
83  DoConsensusVote(tx, nBlockHeight);
84 
85  mapTxLockReq.insert(std::make_pair(tx.GetHash(), tx));
86 
87  LogPrintf("ProcessMessageSwiftTX::ix - Transaction Lock Request: %s %s : accepted %s\n",
88  pfrom->addr.ToString().c_str(), pfrom->cleanSubVer.c_str(),
89  tx.GetHash().ToString().c_str());
90 
93  }
94 
95  return;
96 
97  } else {
98  mapTxLockReqRejected.insert(std::make_pair(tx.GetHash(), tx));
99 
100  // can we get the conflicting transaction as proof?
101 
102  LogPrintf("ProcessMessageSwiftTX::ix - Transaction Lock Request: %s %s : rejected %s\n",
103  pfrom->addr.ToString().c_str(), pfrom->cleanSubVer.c_str(),
104  tx.GetHash().ToString().c_str());
105 
106  for (const CTxIn& in : tx.vin) {
107  if (!mapLockedInputs.count(in.prevout)) {
108  mapLockedInputs.insert(std::make_pair(in.prevout, tx.GetHash()));
109  }
110  }
111 
112  // resolve conflicts
113  std::map<uint256, CTransactionLock>::iterator i = mapTxLocks.find(tx.GetHash());
114  if (i != mapTxLocks.end()) {
115  //we only care if we have a complete tx lock
116  if ((*i).second.CountSignatures() >= SWIFTTX_SIGNATURES_REQUIRED) {
117  if (!CheckForConflictingLocks(tx)) {
118  LogPrintf("ProcessMessageSwiftTX::ix - Found Existing Complete IX Lock\n");
119 
120  //reprocess the last 15 blocks
121  mapTxLockReq.insert(std::make_pair(tx.GetHash(), tx));
122  }
123  }
124  }
125 
126  return;
127  }
128  } else if (strCommand == NetMsgType::IXLOCKVOTE) // SwiftX Lock Consensus Votes
129  {
130  CConsensusVote ctx;
131  vRecv >> ctx;
132 
133  CInv inv(MSG_TXLOCK_VOTE, ctx.GetHash());
134  pfrom->AddInventoryKnown(inv);
135 
136  if (mapTxLockVote.count(ctx.GetHash())) {
137  return;
138  }
139 
140  mapTxLockVote.insert(std::make_pair(ctx.GetHash(), ctx));
141 
142  if (ProcessConsensusVote(pfrom, ctx)) {
143  //Spam/Dos protection
144  /*
145  Masternodes will sometimes propagate votes before the transaction is known to the client.
146  This tracks those messages and allows it at the same rate of the rest of the network, if
147  a peer violates it, it will simply be ignored
148  */
149  if (!mapTxLockReq.count(ctx.txHash) && !mapTxLockReqRejected.count(ctx.txHash)) {
150  if (!mapUnknownVotes.count(ctx.vinMasternode.prevout.hash)) {
151  mapUnknownVotes[ctx.vinMasternode.prevout.hash] = GetTime() + (60 * 10);
152  }
153 
154  if (mapUnknownVotes[ctx.vinMasternode.prevout.hash] > GetTime() &&
155  mapUnknownVotes[ctx.vinMasternode.prevout.hash] - GetAverageVoteTime() > 60 * 10) {
156  LogPrintf("ProcessMessageSwiftTX::ix - masternode is spamming transaction votes: %s %s\n",
157  ctx.vinMasternode.ToString().c_str(),
158  ctx.txHash.ToString().c_str());
159  return;
160  } else {
161  mapUnknownVotes[ctx.vinMasternode.prevout.hash] = GetTime() + (60 * 10);
162  }
163  }
164  RelayInv(inv);
165  }
166 
167  if (mapTxLockReq.count(ctx.txHash) && GetTransactionLockSignatures(ctx.txHash) == SWIFTTX_SIGNATURES_REQUIRED) {
169  }
170 
171  return;
172  }
173 }
174 
175 bool IsIXTXValid(const CTransaction& txCollateral)
176 {
177  if (txCollateral.vout.size() < 1) return false;
178  if (txCollateral.nLockTime != 0) return false;
179 
180  CAmount nValueIn = 0;
181  CAmount nValueOut = 0;
182  bool missingTx = false;
183 
184  for (const CTxOut &o : txCollateral.vout)
185  nValueOut += o.nValue;
186 
187  for (const CTxIn &i : txCollateral.vin) {
188  CTransaction tx2;
189  uint256 hash;
190  if (GetTransaction(i.prevout.hash, tx2, hash, true)) {
191  if (tx2.vout.size() > i.prevout.n) {
192  nValueIn += tx2.vout[i.prevout.n].nValue;
193  }
194  } else {
195  missingTx = true;
196  }
197  }
198 
199  if (missingTx) {
200  LogPrint(BCLog::MASTERNODE, "IsIXTXValid - Unknown inputs in IX transaction - %s\n", txCollateral.ToString().c_str());
201  /*
202  This happens sometimes for an unknown reason, so we'll return that it's a valid transaction.
203  If someone submits an invalid transaction it will be rejected by the network anyway and this isn't
204  very common, but we don't want to block IX just because the client can't figure out the fee.
205  */
206  return true;
207  }
208 
209  if (nValueIn - nValueOut < COIN * 0.01) {
210  LogPrint(BCLog::MASTERNODE, "IsIXTXValid - did not include enough fees in transaction %d\n%s\n", nValueOut - nValueIn, txCollateral.ToString().c_str());
211  return false;
212  }
213 
214  return true;
215 }
216 
218 {
219  int64_t nTxAge = 0;
220  BOOST_REVERSE_FOREACH (CTxIn i, tx.vin) {
221  nTxAge = GetInputAge(i);
222  if (nTxAge < 5) //1 less than the "send IX" gui requires, incase of a block propagating the network at the time
223  {
224  LogPrintf("CreateNewLock - Transaction not found / too new: %d / %s\n", nTxAge, tx.GetHash().ToString().c_str());
225  return 0;
226  }
227  }
228 
229  /*
230  Use a blockheight newer than the input.
231  This prevents attackers from using transaction mallibility to predict which masternodes
232  they'll use.
233  */
234  int nBlockHeight = (chainActive.Tip()->nHeight - nTxAge) + 4;
235 
236  if (!mapTxLocks.count(tx.GetHash())) {
237  LogPrintf("CreateNewLock - New Transaction Lock %s !\n", tx.GetHash().ToString().c_str());
238 
239  CTransactionLock newLock;
240  newLock.nBlockHeight = nBlockHeight;
241  newLock.nExpiration = GetTime() + (60 * 60); //locks expire after 60 minutes (24 confirmations)
242  newLock.nTimeout = GetTime() + (60 * 5);
243  newLock.txHash = tx.GetHash();
244  mapTxLocks.insert(std::make_pair(tx.GetHash(), newLock));
245  } else {
246  mapTxLocks[tx.GetHash()].nBlockHeight = nBlockHeight;
247  LogPrint(BCLog::MASTERNODE, "CreateNewLock - Transaction Lock Exists %s !\n", tx.GetHash().ToString().c_str());
248  }
249 
250 
251  return nBlockHeight;
252 }
253 
254 // check if we need to vote on this transaction
255 void DoConsensusVote(CTransaction& tx, int64_t nBlockHeight)
256 {
257  if (!fMasterNode) return;
258 
259  int n = mnodeman.GetMasternodeRank(activeMasternode.vin, nBlockHeight, MIN_SWIFTTX_PROTO_VERSION);
260 
261  if (n == -1) {
262  LogPrint(BCLog::MASTERNODE, "SwiftX::DoConsensusVote - Unknown Masternode\n");
263  return;
264  }
265 
266  if (n > SWIFTTX_SIGNATURES_TOTAL) {
267  LogPrint(BCLog::MASTERNODE, "SwiftX::DoConsensusVote - Masternode not in the top %d (%d)\n", SWIFTTX_SIGNATURES_TOTAL, n);
268  return;
269  }
270  /*
271  nBlockHeight calculated from the transaction is the authoritive source
272  */
273 
274  LogPrint(BCLog::MASTERNODE, "SwiftX::DoConsensusVote - In the top %d (%d)\n", SWIFTTX_SIGNATURES_TOTAL, n);
275 
276  CConsensusVote ctx;
278  ctx.txHash = tx.GetHash();
279  ctx.nBlockHeight = nBlockHeight;
280  if (!ctx.Sign()) {
281  LogPrintf("SwiftX::DoConsensusVote - Failed to sign consensus vote\n");
282  return;
283  }
284  if (!ctx.SignatureValid()) {
285  LogPrintf("SwiftX::DoConsensusVote - Signature invalid\n");
286  return;
287  }
288 
289  mapTxLockVote[ctx.GetHash()] = ctx;
290 
291  CInv inv(MSG_TXLOCK_VOTE, ctx.GetHash());
292  RelayInv(inv);
293 }
294 
295 //received a consensus vote
297 {
298  int n = mnodeman.GetMasternodeRank(ctx.vinMasternode, ctx.nBlockHeight, MIN_SWIFTTX_PROTO_VERSION);
299 
301  if (pmn != NULL)
302  LogPrint(BCLog::MASTERNODE, "SwiftX::ProcessConsensusVote - Masternode ADDR %s %d\n", pmn->addr.ToString().c_str(), n);
303 
304  if (n == -1) {
305  //can be caused by past versions trying to vote with an invalid protocol
306  LogPrint(BCLog::MASTERNODE, "SwiftX::ProcessConsensusVote - Unknown Masternode\n");
307  mnodeman.AskForMN(pnode, ctx.vinMasternode);
308  return false;
309  }
310 
311  if (n > SWIFTTX_SIGNATURES_TOTAL) {
312  LogPrint(BCLog::MASTERNODE, "SwiftX::ProcessConsensusVote - Masternode not in the top %d (%d) - %s\n", SWIFTTX_SIGNATURES_TOTAL, n, ctx.GetHash().ToString().c_str());
313  return false;
314  }
315 
316  if (!ctx.SignatureValid()) {
317  LogPrintf("SwiftX::ProcessConsensusVote - Signature invalid\n");
318  // don't ban, it could just be a non-synced masternode
319  mnodeman.AskForMN(pnode, ctx.vinMasternode);
320  return false;
321  }
322 
323  if (!mapTxLocks.count(ctx.txHash)) {
324  LogPrintf("SwiftX::ProcessConsensusVote - New Transaction Lock %s !\n", ctx.txHash.ToString().c_str());
325 
326  CTransactionLock newLock;
327  newLock.nBlockHeight = 0;
328  newLock.nExpiration = GetTime() + (60 * 60);
329  newLock.nTimeout = GetTime() + (60 * 5);
330  newLock.txHash = ctx.txHash;
331  mapTxLocks.insert(std::make_pair(ctx.txHash, newLock));
332  } else
333  LogPrint(BCLog::MASTERNODE, "SwiftX::ProcessConsensusVote - Transaction Lock Exists %s !\n", ctx.txHash.ToString().c_str());
334 
335  //compile consessus vote
336  std::map<uint256, CTransactionLock>::iterator i = mapTxLocks.find(ctx.txHash);
337  if (i != mapTxLocks.end()) {
338  (*i).second.AddSignature(ctx);
339 
340 #ifdef ENABLE_WALLET
341  if (pwalletMain) {
342  //when we get back signatures, we'll count them as requests. Otherwise the client will think it didn't propagate.
343  if (pwalletMain->mapRequestCount.count(ctx.txHash))
345  }
346 #endif
347 
348  LogPrint(BCLog::MASTERNODE, "SwiftX::ProcessConsensusVote - Transaction Lock Votes %d - %s !\n", (*i).second.CountSignatures(), ctx.GetHash().ToString().c_str());
349 
350  if ((*i).second.CountSignatures() >= SWIFTTX_SIGNATURES_REQUIRED) {
351  LogPrint(BCLog::MASTERNODE, "SwiftX::ProcessConsensusVote - Transaction Lock Is Complete %s !\n", (*i).second.GetHash().ToString().c_str());
352 
353  CTransaction& tx = mapTxLockReq[ctx.txHash];
354  if (!CheckForConflictingLocks(tx)) {
355 #ifdef ENABLE_WALLET
356  if (pwalletMain) {
357  if (pwalletMain->UpdatedTransaction((*i).second.txHash)) {
359  }
360  }
361 #endif
362 
363  if (mapTxLockReq.count(ctx.txHash)) {
364  for (const CTxIn& in : tx.vin) {
365  if (!mapLockedInputs.count(in.prevout)) {
366  mapLockedInputs.insert(std::make_pair(in.prevout, ctx.txHash));
367  }
368  }
369  }
370 
371  // resolve conflicts
372 
373  //if this tx lock was rejected, we need to remove the conflicting blocks
374  if (mapTxLockReqRejected.count((*i).second.txHash)) {
375  //reprocess the last 15 blocks
376  }
377  }
378  }
379  return true;
380  }
381 
382 
383  return false;
384 }
385 
387 {
388  /*
389  It's possible (very unlikely though) to get 2 conflicting transaction locks approved by the network.
390  In that case, they will cancel each other out.
391 
392  Blocks could have been rejected during this time, which is OK. After they cancel out, the client will
393  rescan the blocks and find they're acceptable and then take the chain with the most work.
394  */
395  for (const CTxIn& in : tx.vin) {
396  if (mapLockedInputs.count(in.prevout)) {
397  if (mapLockedInputs[in.prevout] != tx.GetHash()) {
398  LogPrintf("SwiftX::CheckForConflictingLocks - found two complete conflicting locks - removing both. %s %s", tx.GetHash().ToString().c_str(), mapLockedInputs[in.prevout].ToString().c_str());
399  if (mapTxLocks.count(tx.GetHash())) mapTxLocks[tx.GetHash()].nExpiration = GetTime();
400  if (mapTxLocks.count(mapLockedInputs[in.prevout])) mapTxLocks[mapLockedInputs[in.prevout]].nExpiration = GetTime();
401  return true;
402  }
403  }
404  }
405 
406  return false;
407 }
408 
410 {
411  std::map<uint256, int64_t>::iterator it = mapUnknownVotes.begin();
412  int64_t total = 0;
413  int64_t count = 0;
414 
415  while (it != mapUnknownVotes.end()) {
416  total += it->second;
417  count++;
418  it++;
419  }
420 
421  return total / count;
422 }
423 
425 {
426  if (chainActive.Tip() == NULL) return;
427 
428  std::map<uint256, CTransactionLock>::iterator it = mapTxLocks.begin();
429 
430  while (it != mapTxLocks.end()) {
431  if (GetTime() > it->second.nExpiration) { //keep them for an hour
432  LogPrintf("Removing old transaction lock %s\n", it->second.txHash.ToString().c_str());
433 
434  if (mapTxLockReq.count(it->second.txHash)) {
435  CTransaction& tx = mapTxLockReq[it->second.txHash];
436 
437  for (const CTxIn& in : tx.vin)
438  mapLockedInputs.erase(in.prevout);
439 
440  mapTxLockReq.erase(it->second.txHash);
441  mapTxLockReqRejected.erase(it->second.txHash);
442 
443  for (CConsensusVote& v : it->second.vecConsensusVotes)
444  mapTxLockVote.erase(v.GetHash());
445  }
446 
447  mapTxLocks.erase(it++);
448  } else {
449  it++;
450  }
451  }
452 }
453 
455 {
457 
458  std::map<uint256, CTransactionLock>::iterator it = mapTxLocks.find(txHash);
459  if(it != mapTxLocks.end()) return it->second.CountSignatures();
460 
461  return -1;
462 }
463 
465 {
467 }
468 
469 
471 {
472  std::string strError = "";
473  std::string strMessage = Hash(txHash.begin(), txHash.end(), BEGIN(nBlockHeight), END(nBlockHeight)).ToString();
474 
476 
477  if (pmn == NULL) {
478  LogPrintf("SwiftX::CConsensusVote::SignatureValid() - Unknown Masternode\n");
479  return false;
480  }
481 
482  if (!CMessageSigner::VerifyMessage(pmn->pubKeyMasternode, vchMasterNodeSignature, strMessage, strError)) {
483  LogPrintf("SwiftX::CConsensusVote::SignatureValid() - Verify message failed, error: %s\n", strError);
484  return false;
485  }
486 
487  return true;
488 }
489 
491 {
492  std::string strError = "";
493 
494  CKey key2;
495  CPubKey pubkey2;
496  std::string strMessage = Hash(txHash.begin(), txHash.end(), BEGIN(nBlockHeight), END(nBlockHeight)).GetHex();
497 
499  return error("%s : Invalid masternodeprivkey", __func__);
500  }
501 
502  if (!CMessageSigner::SignMessage(strMessage, vchMasterNodeSignature, key2)) {
503  return error("%s : Sign message failed", __func__);
504  }
505 
506  if (!CMessageSigner::VerifyMessage(pubkey2, vchMasterNodeSignature, strMessage, strError)) {
507  return error("%s : Verify message failed, error: %s", __func__, strError);
508  }
509 
510  return true;
511 }
512 
513 
515 {
516  for (CConsensusVote vote : vecConsensusVotes) {
517  int n = mnodeman.GetMasternodeRank(vote.vinMasternode, vote.nBlockHeight, MIN_SWIFTTX_PROTO_VERSION);
518 
519  if (n == -1) {
520  LogPrintf("CTransactionLock::SignaturesValid() - Unknown Masternode\n");
521  return false;
522  }
523 
524  if (n > SWIFTTX_SIGNATURES_TOTAL) {
525  LogPrintf("CTransactionLock::SignaturesValid() - Masternode not in the top %s\n", SWIFTTX_SIGNATURES_TOTAL);
526  return false;
527  }
528 
529  if (!vote.SignatureValid()) {
530  LogPrintf("CTransactionLock::SignaturesValid() - Signature not valid\n");
531  return false;
532  }
533  }
534 
535  return true;
536 }
537 
539 {
540  vecConsensusVotes.push_back(cv);
541 }
542 
544 {
545  /*
546  Only count signatures where the BlockHeight matches the transaction's blockheight.
547  The votes have no proof it's the correct blockheight
548  */
549 
550  if (nBlockHeight == 0) return -1;
551 
552  int n = 0;
554  if (v.nBlockHeight == nBlockHeight) {
555  n++;
556  }
557  }
558  return n;
559 }
CTxIn
An input of a transaction.
Definition: transaction.h:83
base_uint::end
unsigned char * end()
Definition: arith_uint256.h:245
CMasternodeMan::AskForMN
void AskForMN(CNode *pnode, CTxIn &vin)
Ask (source) node for mnb.
Definition: masternodeman.cpp:223
CConsensusVote::SignatureValid
bool SignatureValid()
Definition: swifttx.cpp:470
MSG_TXLOCK_VOTE
@ MSG_TXLOCK_VOTE
Definition: protocol.h:394
CScript::IsNormalPaymentScript
bool IsNormalPaymentScript() const
Definition: script.cpp:211
CTransactionLock
Definition: swifttx.h:92
GetTime
int64_t GetTime()
For unit testing.
Definition: utiltime.cpp:19
CConsensusVote::Sign
bool Sign()
Definition: swifttx.cpp:490
activeMasternode
CActiveMasternode activeMasternode
Keep track of the active Masternode.
Definition: masternodeman.cpp:24
CMasternodeMan::GetMasternodeRank
int GetMasternodeRank(const CTxIn &vin, int64_t nBlockHeight, int minProtocol=0, bool fOnlyActive=true)
Definition: masternodeman.cpp:564
BEGIN
#define BEGIN(a)
Utilities for converting data from/to strings.
Definition: utilstrencodings.h:17
base_uint::begin
unsigned char * begin()
Definition: arith_uint256.h:240
sync.h
chainActive
CChain chainActive
The currently-connected chain of blocks.
Definition: main.cpp:70
CConsensusVote::GetHash
uint256 GetHash() const
Definition: swifttx.cpp:464
COutPoint::hash
uint256 hash
Definition: transaction.h:39
CTransactionLock::vecConsensusVotes
std::vector< CConsensusVote > vecConsensusVotes
Definition: swifttx.h:97
CNode::AddInventoryKnown
void AddInventoryKnown(const CInv &inv)
Definition: net.h:486
CMasternodeMan::Find
CMasternode * Find(const CScript &payee)
Find an entry.
Definition: masternodeman.cpp:440
CActiveMasternode::vin
CTxIn vin
Definition: activemasternode.h:44
CMasternodeSync::IsBlockchainSynced
bool IsBlockchainSynced()
Definition: masternode-sync.cpp:32
CWallet::mapRequestCount
std::map< uint256, int > mapRequestCount
Definition: wallet.h:352
CConsensusVote::txHash
uint256 txHash
Definition: swifttx.h:71
CBlockIndex::nHeight
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition: chain.h:181
CNode
Information about a peer.
Definition: net.h:306
validationinterface.h
CTransaction::nLockTime
const uint32_t nLockTime
Definition: transaction.h:287
ProcessConsensusVote
bool ProcessConsensusVote(CNode *pnode, CConsensusVote &ctx)
Definition: swifttx.cpp:296
CNode::addr
CAddress addr
Definition: net.h:332
NetMsgType::IX
const char * IX
The ix message transmits a single SwiftX transaction.
Definition: protocol.cpp:48
masternode-sync.h
fLargeWorkInvalidChainFound
bool fLargeWorkInvalidChainFound
Definition: main.cpp:2517
mapTxLockReq
std::map< uint256, CTransaction > mapTxLockReq
Definition: swifttx.cpp:24
DoConsensusVote
void DoConsensusVote(CTransaction &tx, int64_t nBlockHeight)
Definition: swifttx.cpp:255
CInv
inv message data
Definition: protocol.h:358
masternodeman.h
CMessageSigner::VerifyMessage
static bool VerifyMessage(const CPubKey &pubkey, const std::vector< unsigned char > &vchSig, const std::string &strMessage, std::string &strErrorRet)
Verify the message signature, returns true if succcessful.
Definition: messagesigner.cpp:34
nCompleteTXLocks
int nCompleteTXLocks
Definition: swifttx.cpp:30
fMasterNode
bool fMasterNode
Definition: util.cpp:97
CConsensusVote::vinMasternode
CTxIn vinMasternode
Definition: swifttx.h:70
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:269
CMessageSigner::SignMessage
static bool SignMessage(const std::string &strMessage, std::vector< unsigned char > &vchSigRet, const CKey &key)
Sign the message, returns true if successful.
Definition: messagesigner.cpp:25
GetMainSignals
CMainSignals & GetMainSignals()
Definition: validationinterface.cpp:10
SWIFTTX_SIGNATURES_TOTAL
#define SWIFTTX_SIGNATURES_TOTAL
Definition: swifttx.h:27
masternodeSync
CMasternodeSync masternodeSync
Definition: masternode-sync.cpp:19
AcceptToMemoryPool
bool AcceptToMemoryPool(CTxMemPool &pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, bool *pfMissingInputs, bool fRejectInsaneFee, bool ignoreFees)
(try to) add transaction to memory pool
Definition: main.cpp:1579
CTxOut::nValue
CAmount nValue
Definition: transaction.h:167
strMasterNodePrivKey
std::string strMasterNodePrivKey
Definition: util.cpp:98
cs_main
RecursiveMutex cs_main
Global state.
Definition: main.cpp:65
fLargeWorkForkFound
bool fLargeWorkForkFound
Definition: main.cpp:2516
protocol.h
mnodeman
CMasternodeMan mnodeman
Masternode manager.
Definition: masternodeman.cpp:22
CService::ToString
std::string ToString() const
Definition: netaddress.cpp:568
SWIFTTX_SIGNATURES_REQUIRED
#define SWIFTTX_SIGNATURES_REQUIRED
Definition: swifttx.h:26
CTransactionLock::txHash
uint256 txHash
Definition: swifttx.h:96
CTxOut
An output of a transaction.
Definition: transaction.h:164
GetTransaction
bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, bool fAllowSlow, CBlockIndex *blockIndex)
Return transaction in tx, and if it was found inside a block, its hash is placed in hashBlock.
Definition: main.cpp:2010
CTransaction::vout
std::vector< CTxOut > vout
Definition: transaction.h:286
NetMsgType::IXLOCKVOTE
const char * IXLOCKVOTE
The ixlockvote message is used to reach consensus for SwiftX transaction locks.
Definition: protocol.cpp:49
CTxOut::scriptPubKey
CScript scriptPubKey
Definition: transaction.h:168
fLiteMode
bool fLiteMode
Definition: util.cpp:100
CreateNewLock
int64_t CreateNewLock(CTransaction tx)
Definition: swifttx.cpp:217
CMainSignals::Inventory
boost::signals2::signal< void(const uint256 &)> Inventory
Notifies listeners about an inventory item being seen on the network.
Definition: validationinterface.h:63
CTransactionLock::nTimeout
int nTimeout
Definition: swifttx.h:99
RelayInv
void RelayInv(CInv &inv)
Definition: net.cpp:2077
CAmount
int64_t CAmount
Amount in PRCY (Can be negative)
Definition: amount.h:17
LogPrintf
#define LogPrintf(...)
Definition: logging.h:147
MSG_TXLOCK_REQUEST
@ MSG_TXLOCK_REQUEST
Definition: protocol.h:393
mempool
CTxMemPool mempool(::minRelayTxFee)
GetInputAge
int GetInputAge(CTxIn &vin)
Definition: main.cpp:1373
mapUnknownVotes
std::map< uint256, int64_t > mapUnknownVotes
Definition: swifttx.cpp:29
ProcessMessageSwiftTX
void ProcessMessageSwiftTX(CNode *pfrom, std::string &strCommand, CDataStream &vRecv)
Definition: swifttx.cpp:39
uint256
256-bit unsigned big integer.
Definition: uint256.h:38
LogPrint
#define LogPrint(category,...)
Definition: logging.h:162
CConsensusVote
Definition: swifttx.h:67
CConsensusVote::nBlockHeight
int nBlockHeight
Definition: swifttx.h:72
mapTxLockVote
std::map< uint256, CConsensusVote > mapTxLockVote
Definition: swifttx.cpp:26
CMasternode::pubKeyMasternode
CPubKey pubKeyMasternode
Definition: masternode.h:130
mapLockedInputs
std::map< COutPoint, uint256 > mapLockedInputs
Definition: swifttx.cpp:28
GetAverageVoteTime
int64_t GetAverageVoteTime()
Definition: swifttx.cpp:409
CTransactionLock::nExpiration
int nExpiration
Definition: swifttx.h:98
CMessageSigner::GetKeysFromSecret
static bool GetKeysFromSecret(const std::string &strSecret, CKey &keyRet, CPubKey &pubkeyRet)
Set the private/public key values, returns true if successful.
Definition: messagesigner.cpp:13
CTransactionLock::AddSignature
void AddSignature(CConsensusVote &cv)
Definition: swifttx.cpp:538
activemasternode.h
CMasternode::addr
CService addr
Definition: masternode.h:128
CTransactionLock::nBlockHeight
int nBlockHeight
Definition: swifttx.h:95
messagesigner.h
key.h
CMasternode
Definition: masternode.h:107
CPubKey
An encapsulated public key.
Definition: pubkey.h:37
CTransaction::ToString
std::string ToString() const
Definition: transaction.cpp:217
CInv::hash
uint256 hash
Definition: protocol.h:384
CKey
An encapsulated private key.
Definition: key.h:39
END
#define END(a)
Definition: utilstrencodings.h:18
BCLog::MASTERNODE
@ MASTERNODE
Definition: logging.h:62
COutPoint::n
uint32_t n
Definition: transaction.h:40
CTransaction::vin
std::vector< CTxIn > vin
Definition: transaction.h:285
swifttx.h
LOCK
#define LOCK(cs)
Definition: sync.h:182
CTxIn::prevout
COutPoint prevout
Definition: transaction.h:86
CMainSignals::NotifyTransactionLock
boost::signals2::signal< void(const CTransaction &)> NotifyTransactionLock
Notifies listeners of an updated transaction lock without new data.
Definition: validationinterface.h:57
CDataStream
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:34
base58.h
CWallet::UpdatedTransaction
bool UpdatedTransaction(const uint256 &hashTx)
Definition: wallet.cpp:5043
CTransaction::GetHash
const uint256 & GetHash() const
Definition: transaction.h:342
COutPoint::GetHash
uint256 GetHash()
Definition: transaction.cpp:31
CChain::Tip
CBlockIndex * Tip(bool fProofOfStake=false) const
Returns the index entry for the tip of this chain, or NULL if none.
Definition: chain.h:596
CScript::IsUnspendable
bool IsUnspendable() const
Returns whether the script is guaranteed to fail at execution, regardless of the initial stack.
Definition: script.h:628
Hash
std::string Hash(std::string input)
Compute the 256-bit hash of a std::string.
Definition: hash.h:122
mapTxLockReqRejected
std::map< uint256, CTransaction > mapTxLockReqRejected
Definition: swifttx.cpp:25
net.h
CleanTransactionLocksList
void CleanTransactionLocksList()
Definition: swifttx.cpp:424
CConsensusVote::vchMasterNodeSignature
std::vector< unsigned char > vchMasterNodeSignature
Definition: swifttx.h:73
pwalletMain
CWallet * pwalletMain
Definition: wallet.cpp:49
GetTransactionLockSignatures
int GetTransactionLockSignatures(uint256 txHash)
Definition: swifttx.cpp:454
CValidationState
Capture information about block/transaction validation.
Definition: validation.h:23
util.h
CTransactionLock::SignaturesValid
bool SignaturesValid()
Definition: swifttx.cpp:514
CTransactionLock::CountSignatures
int CountSignatures()
Definition: swifttx.cpp:543
CheckForConflictingLocks
bool CheckForConflictingLocks(CTransaction &tx)
Definition: swifttx.cpp:386
CNode::cleanSubVer
std::string cleanSubVer
Definition: net.h:340
error
bool error(const char *fmt, const Args &... args)
Definition: util.h:61
mapTxLocks
std::map< uint256, CTransactionLock > mapTxLocks
Definition: swifttx.cpp:27
IsIXTXValid
bool IsIXTXValid(const CTransaction &txCollateral)
Definition: swifttx.cpp:175
base_uint::ToString
std::string ToString() const
Definition: arith_uint256.cpp:199