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

Function GetPackageHash

src/policy/packages.cpp:151–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151uint256 GetPackageHash(const std::vector<CTransactionRef>& transactions)
152{
153 // Create a vector of the wtxids.
154 std::vector<Wtxid> wtxids_copy;
155 std::transform(transactions.cbegin(), transactions.cend(), std::back_inserter(wtxids_copy),
156 [](const auto& tx){ return tx->GetWitnessHash(); });
157
158 // Sort in ascending order
159 std::sort(wtxids_copy.begin(), wtxids_copy.end(), [](const auto& lhs, const auto& rhs) {
160 return std::lexicographical_compare(std::make_reverse_iterator(lhs.end()), std::make_reverse_iterator(lhs.begin()),
161 std::make_reverse_iterator(rhs.end()), std::make_reverse_iterator(rhs.begin()));
162 });
163
164 // Get sha256 hash of the wtxids concatenated in this order
165 HashWriter hashwriter;
166 for (const auto& wtxid : wtxids_copy) {
167 hashwriter << wtxid;
168 }
169 return hashwriter.GetSHA256();
170}

Callers 6

PackageRBFChecksMethod · 0.85
FinalizeSubpackageMethod · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
txdownloadman.cppFile · 0.85
Find1P1CPackageMethod · 0.85

Calls 5

GetSHA256Method · 0.80
cbeginMethod · 0.45
cendMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68