18 #include "validation.h"
21 #include <boost/thread.hpp>
31 txCoinbase.
vout.emplace_back();
32 txCoinbase.
vout[0].SetEmpty();
33 txCoinbase.
vout[0].scriptPubKey = scriptPubKey;
34 txCoinbase.
vin.emplace_back();
43 const std::vector<CMutableTransaction>& txns,
46 int nextHeight = prevpindex ? prevpindex->
nHeight + 1 : 0;
52 block.
vtx.emplace_back(MakeTransactionRef(coinbaseTx));
54 block.
vtx.emplace_back(MakeTransactionRef(tx));
58 const auto& blockHash = block.
GetHash();
60 fakeIndex->
nHeight = nextHeight;
61 BlockMap::iterator mi =
mapBlockIndex.emplace(blockHash, fakeIndex).first;
67 return std::make_shared<CBlock>(block);
75 std::vector<CRecipient> vecSend;
76 vecSend.reserve(numOfOutputs);
77 for (
int i=0; i<numOfOutputs; i++) {
78 vecSend.emplace_back(dest, 5 * COIN,
false);
84 int nChangePosInOut = -1;
85 std::string strFailReason;
100 static void initBasics()
104 threadGroup.create_thread(std::bind(&TraceThread<CScheduler::Function>,
"scheduler", serviceLoop));
120 const static auto verify_handle = std::make_unique<ECCVerifyHandle>();
126 const auto& params =
Params();
131 pwallet->LoadWallet(isInit);
132 pwallet->SetupSPKM(
true,
true);
133 auto res = pwallet->getNewAddress(
"coinbase");
134 if (!res)
throw std::runtime_error(
"Cannot create coinbase address");
139 for (
int i=0; i<gen; i++) {
140 std::vector<CMutableTransaction> vtx;
151 pwallet->BlockConnected(pblock,
mapBlockIndex[pblock->GetHash()]);
154 int nextBlockHeight = gen + 1;
158 std::vector<std::shared_ptr<CBlock>> blocks;
159 for (
int i=0; i<30; i++) {
160 std::vector<CMutableTransaction> vtx;
161 for (
int j=0; j<3; j++) {
162 std::vector<SendManyRecipient> recipients;
163 recipients.emplace_back(pwallet->GenerateNewSaplingZKey(), 2 * COIN,
"",
false);
164 recipients.emplace_back(pwallet->GenerateNewSaplingZKey(), 100 * COIN,
"",
false);
165 recipients.emplace_back(pwallet->GenerateNewSaplingZKey(), 240 * COIN,
"",
false);
168 auto operationResult = operation.setRecipients(recipients)
169 ->setSelectTransparentCoins(
true)
173 assert(operationResult);
174 vtx.emplace_back(operation.getFinalTx());
182 blocks.emplace_back(pblock);
188 for (
const auto& pblock : blocks) {
189 pwallet->BlockConnected(pblock,
mapBlockIndex[pblock->GetHash()]);
int64_t CAmount
Amount in PIV (Can be negative)
uint256 CalculateSaplingTreeRoot(CBlock *pblock, int nHeight, const CChainParams &chainparams)
void UpdateNetworkUpgradeParameters(Consensus::UpgradeIndex idx, int nActivationHeight)
Allows modifying the network upgrade regtest parameters.
void SelectParams(const std::string &network)
Sets the params returned by Params() to those for the given chain name.
const CChainParams & Params()
Return the currently selected parameters.
static std::unique_ptr< BerkeleyDatabase > CreateMock()
Return object for accessing temporary in-memory database.
static const std::string REGTEST
std::vector< CTransactionRef > vtx
The block chain is a tree shaped structure starting with the genesis block at the root,...
uint256 GetBlockHash() const
int nHeight
height of the entry in the chain. The genesis block has height 0
const uint256 * phashBlock
pointer to the hash of the block, if any. memory is owned by this CBlockIndex
Access to the block database (blocks/index/)
CBlockIndex * Tip(bool fProofOfStake=false) const
Returns the index entry for the tip of this chain, or nullptr if none.
int Height() const
Return the maximal height in the chain.
void SetTip(CBlockIndex *pindex)
Set/initialize a chain with a given tip.
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
CChainParams defines various tweakable parameters of a given instance of the PIVX system.
CCoinsView that adds a memory cache for transactions to another CCoinsView.
CCoinsView backed by the LevelDB coin database (chainstate/)
void RegisterBackgroundSignalScheduler(CScheduler &scheduler)
Register a CScheduler to give callbacks which should run in the background (may only be called once)
A key allocated from the key pool.
void stop(bool drain=false)
std::function< void(void)> Function
Serialized script, used inside transaction inputs and outputs.
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,...
Zerocoin database (zerocoin/)
const Optional< T > & getObjResult() const
std::unique_ptr< CDeterministicMNManager > deterministicMNManager
std::unique_ptr< CEvoDB > evoDb
bool CreateTransaction(const std::vector< CRecipient > &vecSend, CTransactionRef &txRet, CReserveKey &reservekey, CAmount &nFeeRet, int &nChangePosInOut, std::string &strFailReason, const CCoinControl *coinControl=nullptr, bool sign=true, CAmount nFeePay=0, bool fIncludeDelegated=false, bool *fStakeDelegationVoided=nullptr, int nExtraSize=0, int nMinDepth=0)
Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also cr...
CallResult< CTxDestination > getNewAddress(const std::string &addressLabel, const std::string purpose, const CChainParams::Base58Type addrType=CChainParams::PUBKEY_ADDRESS)
void ECC_Stop()
Deinitialize the elliptic curve support.
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
RecursiveMutex cs_main
Global state.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a PIVX scriptPubKey for the given CTxDestination.
A mutable version of CTransaction.
std::vector< CTxOut > vout
static constexpr int NO_ACTIVATION_HEIGHT
Special value for nActivationHeight indicating that the upgrade will never activate.
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
std::shared_ptr< const CTransaction > CTransactionRef
std::unique_ptr< CBlockTreeDB > pblocktree
Global variable that points to the active block tree (protected by cs_main)
std::unique_ptr< CZerocoinDB > zerocoinDB
Global variable that points to the zerocoin database (protected by cs_main)
std::unique_ptr< CSporkDB > pSporkDB
Global variable that points to the spork database (protected by cs_main)
std::unique_ptr< CCoinsViewCache > pcoinsTip
Global variable that points to the active CCoinsView (protected by cs_main)
CAmount GetBlockValue(int nHeight)
std::unique_ptr< CCoinsViewDB > pcoinsdbview
Global variable that points to the coins database (protected by cs_main)
void UnloadBlockIndex()
Unload database information.
CChain chainActive
The currently-connected chain of blocks (protected by cs_main).
CMainSignals & GetMainSignals()
void RegisterValidationInterface(CValidationInterface *pwalletIn)
Register a wallet to receive updates from core.
CTransactionRef createNoisyTx(CWallet *pwallet, int numOfOutputs)
BENCHMARK(WalletProcessBlockBench, 0)
const unsigned int CREATE_TRANSACTIONS_PER_BLOCK
std::shared_ptr< CBlock > createAndProcessBlock(const CChainParams ¶ms, const CScript &coinbaseScript, const std::vector< CMutableTransaction > &txns, CBlockIndex *prevpindex)
boost::thread_group threadGroup
EvoNotificationInterface * pEvoNotificationInterface
const unsigned int CREATE_BLOCK