MCPcopy Create free account
hub / github.com/ElementsProject/elements / GetSpentScriptPubKeysSHA256

Function GetSpentScriptPubKeysSHA256

src/script/interpreter.cpp:2500–2511  ·  view source on GitHub ↗

Compute the vector where each element is SHA256 of scriptPubKeys spent by a tx. */

Source from the content-addressed store, hash-verified

2498
2499/** Compute the vector where each element is SHA256 of scriptPubKeys spent by a tx. */
2500std::vector<uint256> GetSpentScriptPubKeysSHA256(const std::vector<CTxOut>& outputs_spent)
2501{
2502 std::vector<uint256> spent_spk_single_hashes;
2503 spent_spk_single_hashes.reserve(outputs_spent.size());
2504 for (const auto& txout : outputs_spent) {
2505 // Normal serialization using the << operator would also serialize the length, therefore we directly write using CSHA256
2506 uint256 spent_spk_single_hash;
2507 CSHA256().Write(txout.scriptPubKey.data(), txout.scriptPubKey.size()).Finalize(spent_spk_single_hash.data());
2508 spent_spk_single_hashes.push_back(std::move(spent_spk_single_hash));
2509 }
2510 return spent_spk_single_hashes;
2511}
2512
2513/** Compute the vector where each element is SHA256 of output scriptPubKey of a tx. */
2514template <class T>

Callers 1

InitMethod · 0.85

Calls 7

CSHA256Class · 0.85
reserveMethod · 0.45
sizeMethod · 0.45
FinalizeMethod · 0.45
WriteMethod · 0.45
dataMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected