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

Function ParseSighashString

src/core_read.cpp:259–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259int ParseSighashString(const UniValue& sighash)
260{
261 int hash_type = SIGHASH_DEFAULT;
262 if (!sighash.isNull()) {
263 static std::map<std::string, int> map_sighash_values = {
264 {std::string("DEFAULT"), int(SIGHASH_DEFAULT)},
265 {std::string("ALL"), int(SIGHASH_ALL)},
266 {std::string("ALL|ANYONECANPAY"), int(SIGHASH_ALL|SIGHASH_ANYONECANPAY)},
267 {std::string("ALL|RANGEPROOF"), int(SIGHASH_ALL|SIGHASH_RANGEPROOF)},
268 {std::string("ALL|ANYONECANPAY|RANGEPROOF"), int(SIGHASH_ALL|SIGHASH_ANYONECANPAY|SIGHASH_RANGEPROOF)},
269 {std::string("NONE"), int(SIGHASH_NONE)},
270 {std::string("NONE|ANYONECANPAY"), int(SIGHASH_NONE|SIGHASH_ANYONECANPAY)},
271 {std::string("NONE|RANGEPROOF"), int(SIGHASH_NONE|SIGHASH_RANGEPROOF)},
272 {std::string("NONE|ANYONECANPAY|RANGEPROOF"), int(SIGHASH_NONE|SIGHASH_ANYONECANPAY|SIGHASH_RANGEPROOF)},
273 {std::string("SINGLE"), int(SIGHASH_SINGLE)},
274 {std::string("SINGLE|ANYONECANPAY"), int(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY)},
275 {std::string("SINGLE|RANGEPROOF"), int(SIGHASH_SINGLE|SIGHASH_RANGEPROOF)},
276 {std::string("SINGLE|ANYONECANPAY|RANGEPROOF"), int(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY|SIGHASH_RANGEPROOF)},
277 };
278 std::string strHashType = sighash.get_str();
279 const auto& it = map_sighash_values.find(strHashType);
280 if (it != map_sighash_values.end()) {
281 hash_type = it->second;
282 } else {
283 throw std::runtime_error(strHashType + " is not a valid sighash parameter.");
284 }
285 }
286 return hash_type;
287}

Callers 4

walletprocesspsbtFunction · 0.85
FUZZ_TARGET_INITFunction · 0.85
SignTransactionFunction · 0.85

Calls 3

findMethod · 0.80
isNullMethod · 0.45
endMethod · 0.45

Tested by 1

FUZZ_TARGET_INITFunction · 0.68