PRCYCoin  2.0.0.7rc1
P2P Digital Currency
main.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2014 The Bitcoin developers
3 // Copyright (c) 2014-2015 The Dash developers
4 // Copyright (c) 2015-2018 The PIVX developers
5 // Copyright (c) 2018-2020 The DAPS Project developers
6 // Distributed under the MIT software license, see the accompanying
7 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
8 
9 #ifndef BITCOIN_MAIN_H
10 #define BITCOIN_MAIN_H
11 
12 #if defined(HAVE_CONFIG_H)
13 #include "config/prcycoin-config.h"
14 #endif
15 
16 #include "amount.h"
17 #include "chain.h"
18 #include "chainparams.h"
19 #include "coins.h"
20 #include "consensus/validation.h"
21 #include "net.h"
22 #include "poa.h"
23 #include "primitives/block.h"
24 #include "primitives/transaction.h"
25 #include "script/script.h"
26 #include "script/sigcache.h"
27 #include "script/standard.h"
28 #include "sync.h"
29 #include "tinyformat.h"
30 #include "txmempool.h"
31 #include "uint256.h"
32 #include "undo.h"
33 #include "bignum.h"
34 
35 #include <algorithm>
36 #include <exception>
37 #include <map>
38 #include <set>
39 #include <stdint.h>
40 #include <string>
41 #include <utility>
42 #include <vector>
43 
44 #include <boost/unordered_map.hpp>
45 
46 #include "secp256k1_bulletproofs.h"
47 #include "secp256k1_commitment.h"
48 #include "secp256k1_generator.h"
49 #include "secp256k1.h"
51 
52 class CBlockIndex;
53 class CBlockTreeDB;
54 class CBloomFilter;
55 class CInv;
56 class CScriptCheck;
58 class CValidationState;
59 
60 struct CBlockTemplate;
61 struct CNodeStateStats;
62 
64 static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 750000;
65 static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0;
67 static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 50000;
69 static const unsigned int MAX_STANDARD_TX_SIZE = 150000;
71 static const unsigned int MAX_P2SH_SIGOPS = 15;
73 static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100;
75 static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB
77 static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000; // 16 MiB
79 static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000; // 1 MiB
81 static const int COINBASE_MATURITY = 100;
83 static const int MAX_SCRIPTCHECK_THREADS = 16;
85 static const int DEFAULT_SCRIPTCHECK_THREADS = 0;
87 static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 16;
89 static const unsigned int BLOCK_STALLING_TIMEOUT = 2;
92 static const unsigned int MAX_HEADERS_RESULTS = 2000;
97 static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024;
99 static const unsigned int DATABASE_WRITE_INTERVAL = 60 * 60;
101 static const unsigned int DATABASE_FLUSH_INTERVAL = 24 * 60 * 60;
103 static const unsigned int MAX_REJECT_MESSAGE_LENGTH = 111;
105 static const unsigned int AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL = 24 * 24 * 60;
107 static const unsigned int AVG_ADDRESS_BROADCAST_INTERVAL = 30;
110 static const unsigned int AVG_INVENTORY_BROADCAST_INTERVAL = 5;
111 
113  static const bool DEFAULT_PEERBLOOMFILTERS = true;
114 
116  static const bool DEFAULT_BLOCK_SPAM_FILTER = true;
118  static const unsigned int DEFAULT_BLOCK_SPAM_FILTER_MAX_SIZE = COINBASE_MATURITY;
120  static const unsigned int DEFAULT_BLOCK_SPAM_FILTER_MAX_AVG = 10;
121 
123 static const int64_t DEFAULT_MAX_TIP_AGE = 24 * 60 * 60;
124 
125 //static const std::string FOUNDATION_WALLET = "PandirQr3T895NCsDrSKdCD4TJ324z3VDB8Amcj6wx2kKdB7LztTDefdvP4QTMdgGA72W7SHzQeFzLTo2sikmmbd19E5C8UZbbi";
126 
127 struct BlockHasher {
128  size_t operator()(const uint256& hash) const { return hash.GetCheapHash(); }
129 };
130 
131 extern CScript COINBASE_FLAGS;
132 extern RecursiveMutex cs_main;
133 extern CTxMemPool mempool;
134 typedef boost::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
135 extern BlockMap mapBlockIndex;
136 extern uint64_t nLastBlockTx;
137 extern uint64_t nLastBlockSize;
138 extern const std::string strMessageMagic;
139 extern int64_t nTimeBestReceived;
140 
141 // Best block section
143 extern std::condition_variable g_best_block_cv;
144 extern uint256 g_best_block;
145 
146 extern std::atomic<bool> fImporting;
147 extern std::atomic<bool> fReindex;
148 extern int nScriptCheckThreads;
149 extern bool fTxIndex;
150 extern bool fIsBareMultisigStd;
151 extern bool fCheckBlockIndex;
152 extern size_t nCoinCacheUsage;
153 extern CFeeRate minRelayTxFee;
154 extern int64_t nMaxTipAge;
155 extern bool fVerifyingBlocks;
156 extern bool fGeneratePrcycoins;
157 
158 extern bool fLargeWorkForkFound;
159 extern bool fLargeWorkInvalidChainFound;
160 
161 extern int64_t nLastCoinStakeSearchInterval;
162 //extern int64_t nConsolidationTime;
163 extern int64_t nLastCoinStakeSearchTime;
164 
165 extern int MIN_RING_SIZE;
166 extern int MAX_RING_SIZE;
167 extern const int MAX_TX_INPUTS;
168 extern const int MIN_TX_INPUTS_FOR_SWEEPING;
169 
170 extern std::map<uint256, int64_t> mapRejectedBlocks;
171 extern std::map<unsigned int, unsigned int> mapHashedBlocks;
172 extern std::map<COutPoint, COutPoint> mapInvalidOutPoints;
173 
176 
178 static const uint64_t nMinDiskSpace = 52428800;
179 
181 void RegisterNodeSignals(CNodeSignals& nodeSignals);
183 void UnregisterNodeSignals(CNodeSignals& nodeSignals);
184 
189 bool VerifyRingSignatureWithTxFee(const CTransaction& tx, CBlockIndex* pindex);
190 void DestroyContext();
191 bool VerifyDerivedAddress(const CTxOut& out, std::string stealth);
192 bool ReVerifyPoSBlock(CBlockIndex* pindex);
193 
205 bool ProcessNewBlock(CValidationState& state, CNode* pfrom, CBlock* pblock, CDiskBlockPos* dbp = NULL);
207 bool CheckDiskSpace(uint64_t nAdditionalBytes = 0);
209 FILE* OpenBlockFile(const CDiskBlockPos& pos, bool fReadOnly = false);
211 FILE* OpenUndoFile(const CDiskBlockPos& pos, bool fReadOnly = false);
213 fs::path GetBlockPosFilename(const CDiskBlockPos& pos, const char* prefix);
215 bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos* dbp = NULL);
217 bool InitBlockIndex();
219 bool LoadBlockIndex(std::string& strError);
221 void UnloadBlockIndex();
223 int ActiveProtocol();
225 bool ProcessMessages(CNode* pfrom);
226 bool VerifyZeroBlindCommitment(const CTxOut& out);
232 bool SendMessages(CNode* pto);
234 void ThreadScriptCheck();
235 
239 std::string GetWarnings(std::string strFor);
241 bool GetTransaction(const uint256& hash, CTransaction& tx, uint256& hashBlock, bool fAllowSlow = false, CBlockIndex* blockIndex = nullptr);
244 bool CheckHaveInputs(const CCoinsViewCache& view, const CTransaction& tx);
245 
246 // ***TODO***
247 double ConvertBitsToDouble(unsigned int nBits);
248 int64_t GetMasternodePayment(int nHeight, int64_t blockValue, int nMasternodeCount = 0);
249 unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader* pblock, bool fProofOfStake);
250 
251 bool ActivateBestChain(CValidationState& state, CBlock* pblock = NULL, bool fAlreadyChecked = false);
252 CAmount GetBlockValue(int nHeight);
253 
255 void SetRingSize(int nHeight);
256 
260 bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats);
262 void Misbehaving(NodeId nodeid, int howmuch) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
264 void FlushStateToDisk();
265 
266 
268 
269 
271 bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState& state, const CTransaction& tx, bool fLimitFree, bool* pfMissingInputs, bool fRejectInsaneFee = false, bool ignoreFees = false);
272 
273 bool AcceptableInputs(CTxMemPool& pool, CValidationState& state, const CTransaction& tx, bool fLimitFree, bool* pfMissingInputs, bool fRejectInsaneFee = false, bool isDSTX = false);
274 
275 bool IsSpentKeyImage(const std::string& kiHex, const uint256& againsHash);
276 bool CheckKeyImageSpendInMainChain(const std::string& kiHex, int& confirmations);
277 
278 double GetPriority(const CTransaction& tx, int nHeight);
279 
281 uint256 GetTxInSignatureHash(const CTxIn& txin);
282 bool VerifyShnorrKeyImageTx(const CTransaction& tx);
283 bool VerifyShnorrKeyImageTxIn(const CTxIn& txin, uint256 sigHash);
284 
285 int GetInputAge(CTxIn& vin);
286 int GetIXConfirmations(uint256 nTXHash);
287 
292  std::vector<int> vHeightInFlight;
293 };
294 
295 CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree);
296 
314 bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs);
315 
321 bool CheckInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& view, bool fScriptChecks, unsigned int flags, bool cacheStore, std::vector<CScriptCheck>* pvChecks = NULL);
322 
324 void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, CTxUndo& txundo, int nHeight);
325 
327 bool IsTransactionInChain(const uint256& txId, int& nHeightTx, CTransaction& tx);
328 bool IsTransactionInChain(const uint256& txId, int& nHeightTx);
329 bool IsBlockHashInChain(const uint256& hashBlock);
330 bool ValidOutPoint(const COutPoint out, int nHeight = 1);
331 bool RecalculatePRCYSupply(int nHeightStart);
332 
340 bool CheckFinalTx(const CTransaction& tx, int flags = -1);
341 
345 bool IsStandardTx(const CTransaction& tx, std::string& reason);
346 
352 {
353 private:
356  unsigned int nIn;
357  unsigned int nFlags;
360 
361 public:
363  CScriptCheck(const CCoins& txFromIn, const CTransaction& txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn) : scriptPubKey(txFromIn.vout[txToIn.vin[nInIn].prevout.n].scriptPubKey),
364  ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), cacheStore(cacheIn), error(SCRIPT_ERR_UNKNOWN_ERROR) {}
365 
366  bool operator()();
367 
368  void swap(CScriptCheck& check)
369  {
371  std::swap(ptxTo, check.ptxTo);
372  std::swap(nIn, check.nIn);
373  std::swap(nFlags, check.nFlags);
374  std::swap(cacheStore, check.cacheStore);
375  std::swap(error, check.error);
376  }
377 
378  ScriptError GetScriptError() const { return error; }
379 };
380 
381 
383 bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos);
384 bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos);
385 bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex);
386 
387 
394 bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& coins, bool* pfClean = NULL);
395 
397 bool DisconnectBlocks(int nBlocks);
398 void ReprocessBlocks(int nBlocks);
399 
401 bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& coins, bool fJustCheck, bool fAlreadyChecked = false);
402 
404 bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool fCheckPOW = true);
405 bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW = true, bool fCheckMerkleRoot = true, bool fCheckSig = true);
406 bool CheckWork(const CBlock block, CBlockIndex* const pindexPrev);
407 
409 bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& state, CBlockIndex* pindexPrev);
410 bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindexPrev);
411 
413 bool TestBlockValidity(CValidationState& state, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckPOW = true, bool fCheckMerkleRoot = true);
414 
416 bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** pindex, CDiskBlockPos* dbp = NULL, bool fAlreadyCheckedBlock = false);
417 bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBlockIndex** ppindex = NULL);
418 
419 
422 {
423 public:
424  CVerifyDB();
425  ~CVerifyDB();
426  bool VerifyDB(CCoinsView* coinsview, int nCheckLevel, int nCheckDepth);
427 };
428 
430 CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator);
431 
433 bool InvalidateBlock(CValidationState& state, CBlockIndex* pindex);
434 
436 bool ReconsiderBlock(CValidationState& state, CBlockIndex* pindex);
437 
439 extern CChain chainActive;
440 
442 extern CCoinsViewCache* pcoinsTip;
443 
445 extern CBlockTreeDB* pblocktree;
446 
447 #endif // BITCOIN_MAIN_H
CVerifyDB::~CVerifyDB
~CVerifyDB()
Definition: main.cpp:5303
CValidationInterface
Definition: validationinterface.h:32
CheckBlockHeader
bool CheckBlockHeader(const CBlockHeader &block, CValidationState &state, bool fCheckPOW=true)
Context-independent validity checks.
Definition: main.cpp:4237
CTxIn
An input of a transaction.
Definition: transaction.h:83
nMaxTipAge
int64_t nMaxTipAge
Definition: main.cpp:89
NodeId
int64_t NodeId
Definition: net.h:92
secp256k1_scratch_space_struct2
Definition: scratch.h:14
block.h
fImporting
std::atomic< bool > fImporting
Definition: main.cpp:80
WriteBlockToDisk
bool WriteBlockToDisk(CBlock &block, CDiskBlockPos &pos)
Functions for disk access for blocks.
Definition: main.cpp:2080
ConnectBlock
bool ConnectBlock(const CBlock &block, CValidationState &state, CBlockIndex *pindex, CCoinsViewCache &coins, bool fJustCheck, bool fAlreadyChecked=false)
Apply the effects of this block (with given index) on the UTXO set represented by coins.
Definition: main.cpp:3085
CNodeStateStats::vHeightInFlight
std::vector< int > vHeightInFlight
Definition: main.h:292
CNodeStateStats::nCommonHeight
int nCommonHeight
Definition: main.h:291
VerifyRingSignatureWithTxFee
bool VerifyRingSignatureWithTxFee(const CTransaction &tx, CBlockIndex *pindex)
Definition: main.cpp:393
GetInputAge
int GetInputAge(CTxIn &vin)
Definition: main.cpp:1373
CScriptCheck::operator()
bool operator()()
Definition: main.cpp:2722
fLargeWorkInvalidChainFound
bool fLargeWorkInvalidChainFound
Definition: main.cpp:2517
fLargeWorkForkFound
bool fLargeWorkForkFound
Definition: main.cpp:2516
FlushStateToDisk
void FlushStateToDisk()
Flush all state, indexes and buffers to disk.
Definition: main.cpp:3467
AcceptBlock
bool AcceptBlock(CBlock &block, CValidationState &state, CBlockIndex **pindex, CDiskBlockPos *dbp=NULL, bool fAlreadyCheckedBlock=false)
Store block on disk.
Definition: main.cpp:4639
CheckBlock
bool CheckBlock(const CBlock &block, CValidationState &state, bool fCheckPOW=true, bool fCheckMerkleRoot=true, bool fCheckSig=true)
Definition: main.cpp:4263
UpdateCoins
void UpdateCoins(const CTransaction &tx, CCoinsViewCache &inputs, CTxUndo &txundo, int nHeight)
Apply the effects of this transaction on the UTXO set represented by view.
Definition: main.cpp:2706
transaction.h
CBlockHeader
Nodes collect new transactions into a block, hash them into a hash tree, and scan through nonce value...
Definition: block.h:52
TestBlockValidity
bool TestBlockValidity(CValidationState &state, const CBlock &block, CBlockIndex *pindexPrev, bool fCheckPOW=true, bool fCheckMerkleRoot=true)
Check a block is completely valid from start to finish (only works on top of our current best block,...
Definition: main.cpp:5088
g_best_block_mutex
Mutex g_best_block_mutex
Definition: main.cpp:75
CTxUndo
Undo information for a CTransaction.
Definition: undo.h:63
CBloomFilter
BloomFilter is a probabilistic filter which SPV clients provide so that we can filter the transaction...
Definition: bloom.h:43
strMessageMagic
const std::string strMessageMagic
Definition: main.cpp:119
sync.h
nTimeBestReceived
int64_t nTimeBestReceived
Definition: main.cpp:72
OpenUndoFile
FILE * OpenUndoFile(const CDiskBlockPos &pos, bool fReadOnly=false)
Open an undo file (rev?????.dat)
Definition: main.cpp:5155
VerifyDerivedAddress
bool VerifyDerivedAddress(const CTxOut &out, std::string stealth)
Definition: main.cpp:2549
CScriptCheck::CScriptCheck
CScriptCheck(const CCoins &txFromIn, const CTransaction &txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn)
Definition: main.h:363
nLastBlockSize
uint64_t nLastBlockSize
Definition: miner.cpp:66
CTxMemPool
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:97
uint256.h
MAX_TX_INPUTS
const int MAX_TX_INPUTS
Definition: main.cpp:93
DestroyContext
void DestroyContext()
Definition: main.cpp:369
pblocktree
CBlockTreeDB * pblocktree
Global variable that points to the active block tree (protected by cs_main)
Definition: main.cpp:1131
mapHashedBlocks
std::map< unsigned int, unsigned int > mapHashedBlocks
Definition: main.cpp:69
InsertBlockIndex
CBlockIndex * InsertBlockIndex(uint256 hash)
Create a new block index entry for a given block hash.
Definition: main.cpp:5165
CNode
Information about a peer.
Definition: net.h:306
CScriptCheck::ptxTo
const CTransaction * ptxTo
Definition: main.h:355
CheckDiskSpace
bool CheckDiskSpace(uint64_t nAdditionalBytes=0)
Check whether enough disk space is available for an incoming block.
Definition: main.cpp:5116
GetPriority
double GetPriority(const CTransaction &tx, int nHeight)
Return priority of tx at height nHeight.
Definition: main.cpp:259
flags
int flags
Definition: prcycoin-tx.cpp:297
ActivateBestChain
bool ActivateBestChain(CValidationState &state, CBlock *pblock=NULL, bool fAlreadyChecked=false)
Make the best chain active, in multiple steps.
Definition: main.cpp:3892
VerifyBulletProofAggregate
bool VerifyBulletProofAggregate(const CTransaction &tx)
Definition: main.cpp:376
ReVerifyPoSBlock
bool ReVerifyPoSBlock(CBlockIndex *pindex)
Definition: main.cpp:621
CNodeStateStats::nSyncHeight
int nSyncHeight
Definition: main.h:290
AnnotatedMixin< std::recursive_mutex >
IsTransactionInChain
bool IsTransactionInChain(const uint256 &txId, int &nHeightTx, CTransaction &tx)
Context-independent validity checks.
Definition: main.cpp:4527
GetMasternodePayment
int64_t GetMasternodePayment(int nHeight, int64_t blockValue, int nMasternodeCount=0)
Definition: main.cpp:2454
cs_main
RecursiveMutex cs_main
Global state.
Definition: main.cpp:65
CNodeStateStats::nMisbehavior
int nMisbehavior
Definition: main.h:289
ContextualCheckBlockHeader
bool ContextualCheckBlockHeader(const CBlockHeader &block, CValidationState &state, CBlockIndex *pindexPrev)
Context-dependent validity checks.
Definition: main.cpp:4458
nLastCoinStakeSearchTime
int64_t nLastCoinStakeSearchTime
ReadBlockFromDisk
bool ReadBlockFromDisk(CBlock &block, const CDiskBlockPos &pos)
Definition: main.cpp:2101
CInv
inv message data
Definition: protocol.h:358
chainparams.h
GetNextWorkRequired
unsigned int GetNextWorkRequired(const CBlockIndex *pindexLast, const CBlockHeader *pblock, bool fProofOfStake)
CVerifyDB::CVerifyDB
CVerifyDB()
Definition: main.cpp:5298
Misbehaving
void Misbehaving(NodeId nodeid, int howmuch) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Increase a node's misbehavior score.
Definition: main.cpp:2645
CFeeRate
Fee rate in PRCY per kilobyte: CAmount / kB.
Definition: amount.h:39
ProcessNewBlock
bool ProcessNewBlock(CValidationState &state, CNode *pfrom, CBlock *pblock, CDiskBlockPos *dbp=NULL)
Process an incoming block.
Definition: main.cpp:4890
validation.h
BlockHasher
Definition: main.h:127
DisconnectBlocks
bool DisconnectBlocks(int nBlocks)
Reprocess a number of blocks to try and get on the correct chain again.
Definition: main.cpp:3647
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:269
ScriptError
enum ScriptError_t ScriptError
minRelayTxFee
CFeeRate minRelayTxFee
Fees smaller than this (in duffs) are considered zero fee (for relaying and mining) We are ~100 times...
Definition: main.cpp:100
tinyformat.h
CScriptCheck::nIn
unsigned int nIn
Definition: main.h:356
txmempool.h
chainActive
CChain chainActive
The currently-connected chain of blocks.
Definition: main.cpp:70
CCoinsView
Abstract view on the open txout dataset.
Definition: coins.h:346
VerifyZeroBlindCommitment
bool VerifyZeroBlindCommitment(const CTxOut &out)
Definition: main.cpp:2540
prefix
const char * prefix
Definition: rest.cpp:588
mapRejectedBlocks
std::map< uint256, int64_t > mapRejectedBlocks
Definition: main.cpp:110
base_uint::GetCheapHash
uint64_t GetCheapHash() const
Definition: arith_uint256.h:304
UnregisterNodeSignals
void UnregisterNodeSignals(CNodeSignals &nodeSignals)
Unregister a network node.
Definition: main.cpp:1106
CScriptCheck::swap
void swap(CScriptCheck &check)
Definition: main.h:368
CScriptCheck::CScriptCheck
CScriptCheck()
Definition: main.h:362
RemoveInvalidTransactionsFromMempool
void RemoveInvalidTransactionsFromMempool()
Definition: main.cpp:3691
COINBASE_FLAGS
CScript COINBASE_FLAGS
Constant stuff for coinbase transactions we create:
Definition: main.cpp:117
nScriptCheckThreads
int nScriptCheckThreads
Definition: main.cpp:79
secp256k1.h
prcycoin-config.h
CScriptCheck::GetScriptError
ScriptError GetScriptError() const
Definition: main.h:378
CTxOut
An output of a transaction.
Definition: transaction.h:164
VerifyShnorrKeyImageTx
bool VerifyShnorrKeyImageTx(const CTransaction &tx)
Definition: main.cpp:1454
RegisterNodeSignals
void RegisterNodeSignals(CNodeSignals &nodeSignals)
Register with a network node to receive its signals.
Definition: main.cpp:1097
ProcessMessages
bool ProcessMessages(CNode *pfrom)
Process protocol messages received from a given node.
Definition: main.cpp:6849
MIN_RING_SIZE
int MIN_RING_SIZE
Definition: main.cpp:91
CheckHaveInputs
bool CheckHaveInputs(const CCoinsViewCache &view, const CTransaction &tx)
Find the best known block, and make it the tip of the block chain.
Definition: main.cpp:1521
bignum.h
GetTransaction
bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, bool fAllowSlow=false, CBlockIndex *blockIndex=nullptr)
Retrieve a transaction (from memory pool, or from disk, if possible)
Definition: main.cpp:2010
ContextualCheckBlock
bool ContextualCheckBlock(const CBlock &block, CValidationState &state, CBlockIndex *pindexPrev)
Definition: main.cpp:4545
AreInputsStandard
bool AreInputsStandard(const CTransaction &tx, const CCoinsViewCache &mapInputs)
Check transaction inputs, and make sure any pay-to-script-hash transactions are evaluating IsStandard...
Definition: main.cpp:1309
GetMinRelayFee
CAmount GetMinRelayFee(const CTransaction &tx, unsigned int nBytes, bool fAllowFree)
Definition: main.cpp:1495
undo.h
UnloadBlockIndex
void UnloadBlockIndex()
Unload database information.
Definition: main.cpp:5386
fIsBareMultisigStd
bool fIsBareMultisigStd
Definition: main.cpp:83
secp256k1_bulletproofs.h
MAX_RING_SIZE
int MAX_RING_SIZE
Definition: main.cpp:92
VerifyShnorrKeyImageTxIn
bool VerifyShnorrKeyImageTxIn(const CTxIn &txin, uint256 sigHash)
Definition: main.cpp:1407
LoadBlockIndex
bool LoadBlockIndex(std::string &strError)
Load the block tree and coins database from disk.
Definition: main.cpp:5416
prevector::swap
void swap(prevector< N, T, Size, Diff > &other)
Definition: prevector.h:440
g_best_block
uint256 g_best_block
Definition: main.cpp:77
AcceptableInputs
bool AcceptableInputs(CTxMemPool &pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, bool *pfMissingInputs, bool fRejectInsaneFee=false, bool isDSTX=false)
Definition: main.cpp:1803
LoadExternalBlockFile
bool LoadExternalBlockFile(FILE *fileIn, CDiskBlockPos *dbp=NULL)
Import blocks from an external file.
Definition: main.cpp:5467
CBlockTreeDB
Access to the block database (blocks/index/)
Definition: txdb.h:74
CDiskBlockPos
Definition: chain.h:76
CScriptCheck::scriptPubKey
CScript scriptPubKey
Definition: main.h:354
CAmount
int64_t CAmount
Amount in PRCY (Can be negative)
Definition: amount.h:17
standard.h
BlockHasher::operator()
size_t operator()(const uint256 &hash) const
Definition: main.h:128
SendMessages
bool SendMessages(CNode *pto)
Send queued protocol messages to be sent to a give node.
Definition: main.cpp:6948
DisconnectBlock
bool DisconnectBlock(CBlock &block, CValidationState &state, CBlockIndex *pindex, CCoinsViewCache &coins, bool *pfClean=NULL)
Functions for validating blocks and updating the block tree.
Definition: main.cpp:2877
hash_impl.h
AcceptBlockHeader
bool AcceptBlockHeader(const CBlockHeader &block, CValidationState &state, CBlockIndex **ppindex=NULL)
ReprocessBlocks
void ReprocessBlocks(int nBlocks)
Definition: main.cpp:3660
mapBlockIndex
BlockMap mapBlockIndex
Definition: main.cpp:67
fReindex
std::atomic< bool > fReindex
Definition: main.cpp:81
uint256
256-bit unsigned big integer.
Definition: uint256.h:38
GetContext
secp256k1_context2 * GetContext()
Definition: main.cpp:348
CScriptCheck::error
ScriptError error
Definition: main.h:359
ReconsiderBlock
bool ReconsiderBlock(CValidationState &state, CBlockIndex *pindex)
Remove invalidity status from a block and its descendants.
Definition: main.cpp:4008
fGeneratePrcycoins
bool fGeneratePrcycoins
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:363
OpenBlockFile
FILE * OpenBlockFile(const CDiskBlockPos &pos, bool fReadOnly=false)
Open a block file (blk?????.dat)
Definition: main.cpp:5150
chain.h
GetWarnings
std::string GetWarnings(std::string strFor)
Format a string that describes several potential problems detected by the core.
Definition: main.cpp:5739
coins.h
InitBlockIndex
bool InitBlockIndex()
Initialize a new block tree database + block data on disk.
Definition: main.cpp:5425
CVerifyDB
RAII wrapper for VerifyDB: Verify consistency of the block and coin databases.
Definition: main.h:421
GetBlockPosFilename
fs::path GetBlockPosFilename(const CDiskBlockPos &pos, const char *prefix)
Translation to a filesystem path.
Definition: main.cpp:5160
poa.h
nLastCoinStakeSearchInterval
int64_t nLastCoinStakeSearchInterval
Definition: miner.cpp:67
CheckInputs
bool CheckInputs(const CTransaction &tx, CValidationState &state, const CCoinsViewCache &view, bool fScriptChecks, unsigned int flags, bool cacheStore, std::vector< CScriptCheck > *pvChecks=NULL)
Check whether all inputs of this transaction are valid (no double spends, scripts & sigs,...
Definition: main.cpp:2766
CBlock
Definition: block.h:142
CheckWork
bool CheckWork(const CBlock block, CBlockIndex *const pindexPrev)
Definition: main.cpp:4437
AcceptToMemoryPool
bool AcceptToMemoryPool(CTxMemPool &pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, bool *pfMissingInputs, bool fRejectInsaneFee=false, bool ignoreFees=false)
(try to) add transaction to memory pool
Definition: main.cpp:1579
pindexBestHeader
CBlockIndex * pindexBestHeader
Best header we've seen so far (used for getheaders queries' starting points).
Definition: main.cpp:71
nLastBlockTx
uint64_t nLastBlockTx
Definition: miner.cpp:65
CVerifyDB::VerifyDB
bool VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth)
Definition: main.cpp:5308
CChain
An in-memory indexed chain of blocks.
Definition: chain.h:583
GetIXConfirmations
int GetIXConfirmations(uint256 nTXHash)
Definition: main.cpp:1392
InvalidateBlock
bool InvalidateBlock(CValidationState &state, CBlockIndex *pindex)
Mark a block as invalid.
Definition: main.cpp:3972
secp256k1_context_struct2
Definition: secp256k1_types.h:15
CCoinsViewCache
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:414
CheckKeyImageSpendInMainChain
bool CheckKeyImageSpendInMainChain(const std::string &kiHex, int &confirmations)
Definition: main.cpp:320
CBlockTemplate
Definition: miner.h:50
GetBlockValue
CAmount GetBlockValue(int nHeight)
Definition: main.cpp:2158
ValidOutPoint
bool ValidOutPoint(const COutPoint out, int nHeight=1)
Definition: main.cpp:2741
fTxIndex
bool fTxIndex
Definition: main.cpp:82
EXCLUSIVE_LOCKS_REQUIRED
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:50
IsSpentKeyImage
bool IsSpentKeyImage(const std::string &kiHex, const uint256 &againsHash)
Definition: main.cpp:283
GetScratch
secp256k1_scratch_space2 * GetScratch()
Definition: main.cpp:355
IsBlockHashInChain
bool IsBlockHashInChain(const uint256 &hashBlock)
Definition: main.cpp:4519
GetTxSignatureHash
uint256 GetTxSignatureHash(const CTransaction &tx)
Definition: main.cpp:681
ActiveProtocol
int ActiveProtocol()
See whether the protocol update is enforced for connected nodes.
Definition: main.cpp:6844
secp256k1_generator.h
CheckFinalTx
bool CheckFinalTx(const CTransaction &tx, int flags=-1)
Check if transaction will be final in the next block to be created.
Definition: main.cpp:1465
CScriptCheck
Closure representing one script verification Note that this stores references to the spending transac...
Definition: main.h:351
CScriptCheck::cacheStore
bool cacheStore
Definition: main.h:358
MIN_TX_INPUTS_FOR_SWEEPING
const int MIN_TX_INPUTS_FOR_SWEEPING
Definition: main.cpp:94
IsStandardTx
bool IsStandardTx(const CTransaction &tx, std::string &reason)
Check for standard transaction types.
Definition: main.cpp:1213
CCoins
Definition: coins.h:77
BlockMap
boost::unordered_map< uint256, CBlockIndex *, BlockHasher > BlockMap
Definition: main.h:134
script.h
CScriptCheck::nFlags
unsigned int nFlags
Definition: main.h:357
COutPoint
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:36
sigcache.h
nCoinCacheUsage
size_t nCoinCacheUsage
Definition: main.cpp:86
CNodeSignals
Definition: net.h:109
GetGenerator
secp256k1_bulletproof_generators * GetGenerator()
Definition: main.cpp:362
fCheckBlockIndex
bool fCheckBlockIndex
Definition: main.cpp:84
ThreadScriptCheck
void ThreadScriptCheck()
Run an instance of the script checking thread.
Definition: main.cpp:2996
CBlockLocator
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
Definition: block.h:249
GetTxInSignatureHash
uint256 GetTxInSignatureHash(const CTxIn &txin)
Definition: main.cpp:687
CNodeStateStats
Definition: main.h:288
net.h
CBlockIndex
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:162
SCRIPT_ERR_UNKNOWN_ERROR
@ SCRIPT_ERR_UNKNOWN_ERROR
Definition: script_error.h:12
pcoinsTip
CCoinsViewCache * pcoinsTip
Global variable that points to the active CCoinsView (protected by cs_main)
Definition: main.cpp:1130
IsInitialBlockDownload
bool IsInitialBlockDownload()
Check whether we are doing an initial block download (synchronizing from disk or network)
Definition: main.cpp:2500
g_best_block_cv
std::condition_variable g_best_block_cv
Definition: main.cpp:76
amount.h
CValidationState
Capture information about block/transaction validation.
Definition: validation.h:23
secp256k1_commitment.h
fVerifyingBlocks
bool fVerifyingBlocks
Definition: main.cpp:85
mapInvalidOutPoints
std::map< COutPoint, COutPoint > mapInvalidOutPoints
Definition: main.cpp:2735
GetNodeStateStats
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats)
Get statistics from node state.
Definition: main.cpp:1081
ConvertBitsToDouble
double ConvertBitsToDouble(unsigned int nBits)
Definition: main.cpp:2139
GetValueIn
CAmount GetValueIn(CCoinsViewCache view, const CTransaction &tx)
Definition: main.cpp:221
FindForkInGlobalIndex
CBlockIndex * FindForkInGlobalIndex(const CChain &chain, const CBlockLocator &locator)
Find the last common block between the parameter chain and a locator.
Definition: main.cpp:1115
secp256k1_bulletproof_generators
Definition: main_impl.h:54
mempool
CTxMemPool mempool
SetRingSize
void SetRingSize(int nHeight)
Definition: main.cpp:2466
RecalculatePRCYSupply
bool RecalculatePRCYSupply(int nHeightStart)
Definition: main.cpp:3002