 |
PRCYCoin
2.0.0.7rc1
P2P Digital Currency
|
Go to the documentation of this file.
21 #include <boost/foreach.hpp>
61 for (
const CTxOut &o : tx.vout) {
65 LogPrintf(
"ProcessMessageSwiftTX::ix - Invalid Script %s\n", tx.ToString().c_str());
72 bool fMissingInputs =
false;
75 bool fAccepted =
false;
87 LogPrintf(
"ProcessMessageSwiftTX::ix - Transaction Lock Request: %s %s : accepted %s\n",
89 tx.GetHash().ToString().c_str());
102 LogPrintf(
"ProcessMessageSwiftTX::ix - Transaction Lock Request: %s %s : rejected %s\n",
104 tx.GetHash().ToString().c_str());
106 for (
const CTxIn& in : tx.vin) {
113 std::map<uint256, CTransactionLock>::iterator i =
mapTxLocks.find(tx.GetHash());
118 LogPrintf(
"ProcessMessageSwiftTX::ix - Found Existing Complete IX Lock\n");
156 LogPrintf(
"ProcessMessageSwiftTX::ix - masternode is spamming transaction votes: %s %s\n",
157 ctx.vinMasternode.ToString().c_str(),
158 ctx.txHash.ToString().c_str());
177 if (txCollateral.
vout.size() < 1)
return false;
178 if (txCollateral.
nLockTime != 0)
return false;
182 bool missingTx =
false;
187 for (
const CTxIn &i : txCollateral.
vin) {
209 if (nValueIn - nValueOut < COIN * 0.01) {
220 BOOST_REVERSE_FOREACH (
CTxIn i, tx.
vin) {
281 LogPrintf(
"SwiftX::DoConsensusVote - Failed to sign consensus vote\n");
285 LogPrintf(
"SwiftX::DoConsensusVote - Signature invalid\n");
317 LogPrintf(
"SwiftX::ProcessConsensusVote - Signature invalid\n");
336 std::map<uint256, CTransactionLock>::iterator i =
mapTxLocks.find(ctx.
txHash);
338 (*i).second.AddSignature(ctx);
351 LogPrint(
BCLog::MASTERNODE,
"SwiftX::ProcessConsensusVote - Transaction Lock Is Complete %s !\n", (*i).second.GetHash().ToString().c_str());
421 return total / count;
428 std::map<uint256, CTransactionLock>::iterator it =
mapTxLocks.begin();
431 if (
GetTime() > it->second.nExpiration) {
432 LogPrintf(
"Removing old transaction lock %s\n", it->second.txHash.ToString().c_str());
458 std::map<uint256, CTransactionLock>::iterator it =
mapTxLocks.find(txHash);
459 if(it !=
mapTxLocks.end())
return it->second.CountSignatures();
472 std::string strError =
"";
478 LogPrintf(
"SwiftX::CConsensusVote::SignatureValid() - Unknown Masternode\n");
483 LogPrintf(
"SwiftX::CConsensusVote::SignatureValid() - Verify message failed, error: %s\n", strError);
492 std::string strError =
"";
499 return error(
"%s : Invalid masternodeprivkey", __func__);
503 return error(
"%s : Sign message failed", __func__);
507 return error(
"%s : Verify message failed, error: %s", __func__, strError);
520 LogPrintf(
"CTransactionLock::SignaturesValid() - Unknown Masternode\n");
529 if (!vote.SignatureValid()) {
530 LogPrintf(
"CTransactionLock::SignaturesValid() - Signature not valid\n");
An input of a transaction.
void AskForMN(CNode *pnode, CTxIn &vin)
Ask (source) node for mnb.
bool IsNormalPaymentScript() const
int64_t GetTime()
For unit testing.
CActiveMasternode activeMasternode
Keep track of the active Masternode.
int GetMasternodeRank(const CTxIn &vin, int64_t nBlockHeight, int minProtocol=0, bool fOnlyActive=true)
#define BEGIN(a)
Utilities for converting data from/to strings.
CChain chainActive
The currently-connected chain of blocks.
std::vector< CConsensusVote > vecConsensusVotes
void AddInventoryKnown(const CInv &inv)
CMasternode * Find(const CScript &payee)
Find an entry.
bool IsBlockchainSynced()
std::map< uint256, int > mapRequestCount
int nHeight
height of the entry in the chain. The genesis block has height 0
Information about a peer.
bool ProcessConsensusVote(CNode *pnode, CConsensusVote &ctx)
const char * IX
The ix message transmits a single SwiftX transaction.
bool fLargeWorkInvalidChainFound
std::map< uint256, CTransaction > mapTxLockReq
void DoConsensusVote(CTransaction &tx, int64_t nBlockHeight)
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.
The basic transaction that is broadcasted on the network and contained in blocks.
static bool SignMessage(const std::string &strMessage, std::vector< unsigned char > &vchSigRet, const CKey &key)
Sign the message, returns true if successful.
CMainSignals & GetMainSignals()
#define SWIFTTX_SIGNATURES_TOTAL
CMasternodeSync masternodeSync
bool AcceptToMemoryPool(CTxMemPool &pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, bool *pfMissingInputs, bool fRejectInsaneFee, bool ignoreFees)
(try to) add transaction to memory pool
std::string strMasterNodePrivKey
RecursiveMutex cs_main
Global state.
CMasternodeMan mnodeman
Masternode manager.
std::string ToString() const
#define SWIFTTX_SIGNATURES_REQUIRED
An output of a transaction.
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.
std::vector< CTxOut > vout
const char * IXLOCKVOTE
The ixlockvote message is used to reach consensus for SwiftX transaction locks.
int64_t CreateNewLock(CTransaction tx)
boost::signals2::signal< void(const uint256 &)> Inventory
Notifies listeners about an inventory item being seen on the network.
int64_t CAmount
Amount in PRCY (Can be negative)
CTxMemPool mempool(::minRelayTxFee)
int GetInputAge(CTxIn &vin)
std::map< uint256, int64_t > mapUnknownVotes
void ProcessMessageSwiftTX(CNode *pfrom, std::string &strCommand, CDataStream &vRecv)
256-bit unsigned big integer.
#define LogPrint(category,...)
std::map< uint256, CConsensusVote > mapTxLockVote
std::map< COutPoint, uint256 > mapLockedInputs
int64_t GetAverageVoteTime()
static bool GetKeysFromSecret(const std::string &strSecret, CKey &keyRet, CPubKey &pubkeyRet)
Set the private/public key values, returns true if successful.
void AddSignature(CConsensusVote &cv)
An encapsulated public key.
std::string ToString() const
An encapsulated private key.
boost::signals2::signal< void(const CTransaction &)> NotifyTransactionLock
Notifies listeners of an updated transaction lock without new data.
Double ended buffer combining vector and stream-like interfaces.
bool UpdatedTransaction(const uint256 &hashTx)
const uint256 & GetHash() const
CBlockIndex * Tip(bool fProofOfStake=false) const
Returns the index entry for the tip of this chain, or NULL if none.
bool IsUnspendable() const
Returns whether the script is guaranteed to fail at execution, regardless of the initial stack.
std::string Hash(std::string input)
Compute the 256-bit hash of a std::string.
std::map< uint256, CTransaction > mapTxLockReqRejected
void CleanTransactionLocksList()
std::vector< unsigned char > vchMasterNodeSignature
int GetTransactionLockSignatures(uint256 txHash)
Capture information about block/transaction validation.
bool CheckForConflictingLocks(CTransaction &tx)
bool error(const char *fmt, const Args &... args)
std::map< uint256, CTransactionLock > mapTxLocks
bool IsIXTXValid(const CTransaction &txCollateral)
std::string ToString() const