Helper function for the various hash based satisfactions.
| 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); } |
nothing calls this directly
no test coverage detected