6 #include <chainparams.h>
12 #include <validation.h>
32 return (tip) ?
TipBlock{tip->GetBlockHash(), tip->GetBlockTime(), tip->nHeight} :
39 const CScript& coinbase_out_script)
46 coinbase_tx.
vin.resize(1);
47 coinbase_tx.
vin[0].prevout.SetNull();
48 coinbase_tx.
vout.resize(2);
49 coinbase_tx.
vout[0].scriptPubKey = coinbase_out_script;
50 coinbase_tx.
vout[0].nValue = 49 *
COIN;
51 coinbase_tx.
vin[0].scriptSig =
CScript() << ++tip.tip_height <<
OP_0;
52 coinbase_tx.
vout[1].scriptPubKey = coinbase_out_script;
53 coinbase_tx.
vout[1].nValue = 1 *
COIN;
59 block.
nTime = ++tip.prev_block_time;
68 context.chainman->ActiveChain().SetTip(*pindex);
84 const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
87 SetMockTime(test_setup->m_node.chainman->GetParams().GenesisBlock().nTime);
92 wallet.SetupDescriptorScriptPubKeyMans();
93 if (
wallet.LoadWallet() != DBErrors::LOAD_OK)
assert(
false);
100 const auto& params =
Params();
101 unsigned int chain_size = 5000;
102 for (
unsigned int i = 0; i < chain_size; ++i) {
117 filter_coins.
max_count = preset_inputs->num_of_internal_inputs;
120 for (
int i=0; i < preset_inputs->num_of_internal_inputs; i++) {
121 const auto& coin{res.coins.at(output_type)[i]};
122 target += coin.txout.nValue;
123 coin_control.
Select(coin.outpoint);
129 std::vector<wallet::CRecipient> recipients = {{dest, target,
true}};
140 const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
142 SetMockTime(test_setup->m_node.chainman->GetParams().GenesisBlock().nTime);
147 wallet.SetupDescriptorScriptPubKeyMans();
148 if (
wallet.LoadWallet() != DBErrors::LOAD_OK)
assert(
false);
152 std::vector<CScript> dest_wallet;
153 dest_wallet.reserve(output_type.size());
154 for (
auto type : output_type) {
159 const auto& params =
Params();
160 unsigned int chain_size = 1000;
161 for (
unsigned int i = 0; i < chain_size / dest_wallet.size(); ++i) {
162 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.
void Select(const COutPoint &output)
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.
DBErrors
Error statuses for the wallet database.
util::Result< CreatedTransactionResult > CreateTransaction(CWallet &wallet, const std::vector< CRecipient > &vecSend, 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.
#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)