8#include <chainparams.h>
25#include <validation.h>
56 return (tip) ?
TipBlock{tip->GetBlockHash(), tip->GetBlockTime(), tip->nHeight} :
63 const CScript& coinbase_out_script)
70 coinbase_tx.
vin.resize(1);
71 coinbase_tx.
vin[0].prevout.SetNull();
72 coinbase_tx.
vout.resize(2);
73 coinbase_tx.
vout[0].scriptPubKey = coinbase_out_script;
74 coinbase_tx.
vout[0].nValue = 49 *
COIN;
75 coinbase_tx.
vin[0].scriptSig =
CScript() << ++tip.tip_height <<
OP_0;
76 coinbase_tx.
vout[1].scriptPubKey = coinbase_out_script;
77 coinbase_tx.
vout[1].nValue = 1 *
COIN;
83 block.
nTime = ++tip.prev_block_time;
92 context.
chainman->ActiveChain().SetTip(*pindex);
108 const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
111 SetMockTime(test_setup->m_node.chainman->GetParams().GenesisBlock().nTime);
116 wallet.SetupDescriptorScriptPubKeyMans();
123 const auto& params =
Params();
125 unsigned int chain_size = 5000;
126 for (
unsigned int i = 0; i < chain_size; ++i) {
141 filter_coins.
max_count = preset_inputs->num_of_internal_inputs;
144 for (
int i=0; i < preset_inputs->num_of_internal_inputs; i++) {
145 const auto& coin{res.coins.at(output_type)[i]};
146 target += coin.txout.nValue;
147 coin_control.
Select(coin.outpoint);
153 std::vector<wallet::CRecipient> recipients = {{dest, target,
true}};
164 const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
166 SetMockTime(test_setup->m_node.chainman->GetParams().GenesisBlock().nTime);
171 wallet.SetupDescriptorScriptPubKeyMans();
175 std::vector<CScript> dest_wallet;
176 dest_wallet.reserve(output_type.size());
177 for (
auto type : output_type) {
182 const auto& params =
Params();
183 unsigned int chain_size = 1000;
184 for (
unsigned int i = 0; i < chain_size / dest_wallet.size(); ++i) {
185 for (
const auto& dest : dest_wallet) {
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
int64_t CAmount
Amount in satoshis (Can be negative)
static constexpr CAmount COIN
The amount of satoshis in one BTC.
const CChainParams & Params()
Return the currently selected parameters.
std::vector< CTransactionRef > vtx
The block chain is a tree shaped structure starting with the genesis block at the root,...
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
const CBlock & GenesisBlock() const
Serialized script, used inside transaction inputs and outputs.
Main entry point to nanobench's benchmarking facility.
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Bench & epochIterations(uint64_t numIters) noexcept
Sets exactly the number of iterations for each epoch.
PreselectedInput & Select(const COutPoint &outpoint)
Lock-in the given output for spending.
bool m_allow_other_inputs
If true, the selection process can add extra unselected inputs from the wallet while requires all sel...
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
static const int COINBASE_MATURITY
Coinbase transaction outputs can only be spent after this number of new blocks (network rule)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
interfaces::BlockInfo MakeBlockInfo(const CBlockIndex *index, const CBlock *data)
Return data from block index.
util::Result< CreatedTransactionResult > CreateTransaction(CWallet &wallet, const std::vector< CRecipient > &vecSend, std::optional< unsigned int > change_pos, const CCoinControl &coin_control, bool sign)
Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also cr...
std::unique_ptr< WalletDatabase > CreateMockableWalletDatabase(MockableData records)
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
CTxDestination getNewDestination(CWallet &w, OutputType output_type)
Returns a new destination, of an specific type, from the wallet.
CoinsResult AvailableCoins(const CWallet &wallet, const CCoinControl *coinControl, std::optional< CFeeRate > feerate, const CoinFilterParams ¶ms)
Populate the CoinsResult struct with vectors of available COutputs, organized by OutputType.
static CTransactionRef MakeTransactionRef(Tx &&txIn)
A mutable version of CTransaction.
std::vector< CTxOut > vout
NodeContext struct containing references to chain state and connection state.
std::unique_ptr< ChainstateManager > chainman
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
static const int32_t VERSIONBITS_LAST_OLD_BLOCK_VERSION
What block version to use for new blocks (pre versionbits)
static void WalletCreateTxUsePresetInputsAndCoinSelection(benchmark::Bench &bench)
BENCHMARK(WalletAvailableCoins, benchmark::PriorityLevel::LOW)
static void WalletAvailableCoins(benchmark::Bench &bench)
TipBlock getTip(const CChainParams ¶ms, const node::NodeContext &context)
void generateFakeBlock(const CChainParams ¶ms, const node::NodeContext &context, CWallet &wallet, const CScript &coinbase_out_script)
static void WalletCreateTx(benchmark::Bench &bench, const OutputType output_type, bool allow_other_inputs, std::optional< PreSelectInputs > preset_inputs)
static void AvailableCoins(benchmark::Bench &bench, const std::vector< OutputType > &output_type)
static void WalletCreateTxUseOnlyPresetInputs(benchmark::Bench &bench)