6 #include <chainparams.h>
12 #include <validation.h>
31 return (tip) ?
TipBlock{tip->GetBlockHash(), tip->GetBlockTime(), tip->nHeight} :
38 const CScript& coinbase_out_script)
45 coinbase_tx.
vin.resize(1);
46 coinbase_tx.
vin[0].prevout.SetNull();
47 coinbase_tx.
vout.resize(2);
48 coinbase_tx.
vout[0].scriptPubKey = coinbase_out_script;
49 coinbase_tx.
vout[0].nValue = 49 *
COIN;
50 coinbase_tx.
vin[0].scriptSig =
CScript() << ++tip.tip_height <<
OP_0;
51 coinbase_tx.
vout[1].scriptPubKey = coinbase_out_script;
52 coinbase_tx.
vout[1].nValue = 1 *
COIN;
58 block.
nTime = ++tip.prev_block_time;
67 context.
chainman->ActiveChain().SetTip(*pindex);
83 const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
86 SetMockTime(test_setup->m_node.chainman->GetParams().GenesisBlock().nTime);
91 wallet.SetupDescriptorScriptPubKeyMans();
98 const auto& params =
Params();
100 unsigned int chain_size = 5000;
101 for (
unsigned int i = 0; i < chain_size; ++i) {
116 filter_coins.
max_count = preset_inputs->num_of_internal_inputs;
119 for (
int i=0; i < preset_inputs->num_of_internal_inputs; i++) {
120 const auto& coin{res.coins.at(output_type)[i]};
121 target += coin.txout.nValue;
122 coin_control.
Select(coin.outpoint);
128 std::vector<wallet::CRecipient> recipients = {{dest, target,
true}};
139 const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
141 SetMockTime(test_setup->m_node.chainman->GetParams().GenesisBlock().nTime);
146 wallet.SetupDescriptorScriptPubKeyMans();
150 std::vector<CScript> dest_wallet;
151 dest_wallet.reserve(output_type.size());
152 for (
auto type : output_type) {
157 const auto& params =
Params();
158 unsigned int chain_size = 1000;
159 for (
unsigned int i = 0; i < chain_size / dest_wallet.size(); ++i) {
160 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)