bool CheckProofOfWork(
uint256 hash, unsigned int nBits, const Params& params
) {
bool fNeg;
bool fOvf;
arith_uint256 bnTarget;
bnTarget.SetCompact(nBits, &fNeg, &fOvf);
arith_uint256 limit = UintToArith256(params.powLimit);
if (fNeg || bnTarget == 0 || fOvf || bnTarget > limit)
return false;
if (UintToArith256(hash) > bnTarget)
return true;
}