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

Function CheckParentProofOfWork

src/pegins.cpp:226–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226bool CheckParentProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params& params)
227{
228 bool fNegative;
229 bool fOverflow;
230 arith_uint256 bnTarget;
231
232 bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
233
234 // Check range
235 if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(params.parentChainPowLimit))
236 return false;
237
238 // Check proof of work matches claimed amount
239 if (UintToArith256(hash) > bnTarget)
240 return false;
241
242 return true;
243}
244
245bool IsValidPeginWitness(const CScriptWitness& pegin_witness, const std::vector<std::pair<CScript, CScript>>& fedpegscripts, const COutPoint& prevout, std::string& err_msg, bool check_depth, bool* depth_failed) {
246 if (depth_failed) {

Callers 3

IsValidPeginWitnessFunction · 0.85
createrawpeginFunction · 0.85
ConstructTransactionFunction · 0.85

Calls 1

UintToArith256Function · 0.85

Tested by

no test coverage detected