MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / CreateKeysAndOutputs

Function CreateKeysAndOutputs

src/bench/connectblock.cpp:83–102  ·  view source on GitHub ↗

* Creates key pairs and corresponding outputs for the benchmark transactions. * - For Schnorr signatures: Creates simple key path spendable outputs * - For Ecdsa signatures: Creates P2WPKH (native SegWit v0) outputs * - All outputs have value of 1 BTC */

Source from the content-addressed store, hash-verified

81 * - All outputs have value of 1 BTC
82 */
83std::pair<std::vector<CKey>, std::vector<CTxOut>> CreateKeysAndOutputs(const CKey& coinbaseKey, size_t num_schnorr, size_t num_ecdsa)
84{
85 std::vector<CKey> keys{coinbaseKey};
86 keys.reserve(num_schnorr + num_ecdsa + 1);
87
88 std::vector<CTxOut> outputs;
89 outputs.reserve(num_schnorr + num_ecdsa);
90
91 for (size_t i{0}; i < num_ecdsa; ++i) {
92 keys.emplace_back(GenerateRandomKey());
93 outputs.emplace_back(COIN, GetScriptForDestination(WitnessV0KeyHash{keys.back().GetPubKey()}));
94 }
95
96 for (size_t i{0}; i < num_schnorr; ++i) {
97 keys.emplace_back(GenerateRandomKey());
98 outputs.emplace_back(COIN, GetScriptForDestination(WitnessV1Taproot{XOnlyPubKey(keys.back().GetPubKey())}));
99 }
100
101 return {keys, outputs};
102}
103
104void BenchmarkConnectBlock(benchmark::Bench& bench, std::vector<CKey>& keys, std::vector<CTxOut>& outputs, TestChain100Setup& test_setup)
105{

Callers 3

ConnectBlockAllSchnorrFunction · 0.85
ConnectBlockAllEcdsaFunction · 0.85

Calls 7

GenerateRandomKeyFunction · 0.85
GetScriptForDestinationFunction · 0.85
XOnlyPubKeyClass · 0.50
reserveMethod · 0.45
emplace_backMethod · 0.45
GetPubKeyMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected