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

Method SatHash

src/test/miniscript_tests.cpp:235–246  ·  view source on GitHub ↗

Helper function for the various hash based satisfactions.

Source from the content-addressed store, hash-verified

233
234 //! Helper function for the various hash based satisfactions.
235 miniscript::Availability SatHash(const std::vector<unsigned char>& hash, std::vector<unsigned char>& preimage, ChallengeType chtype) const {
236 if (!supported.contains(Challenge(chtype, ChallengeNumber(hash)))) return miniscript::Availability::NO;
237 const auto& m =
238 chtype == ChallengeType::SHA256 ? g_testdata->sha256_preimages :
239 chtype == ChallengeType::HASH256 ? g_testdata->hash256_preimages :
240 chtype == ChallengeType::RIPEMD160 ? g_testdata->ripemd160_preimages :
241 g_testdata->hash160_preimages;
242 auto it = m.find(hash);
243 if (it == m.end()) return miniscript::Availability::NO;
244 preimage = it->second;
245 return miniscript::Availability::YES;
246 }
247
248 // Functions that produce the preimage for hashes of various types.
249 miniscript::Availability SatSHA256(const std::vector<unsigned char>& hash, std::vector<unsigned char>& preimage) const { return SatHash(hash, preimage, ChallengeType::SHA256); }

Callers

nothing calls this directly

Calls 4

ChallengeNumberFunction · 0.85
findMethod · 0.80
containsMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected