MCPcopy Index your code
hub / github.com/petertodd/python-bitcoinlib / CheckProofOfWork

Function CheckProofOfWork

bitcoin/core/__init__.py:822–836  ·  view source on GitHub ↗

Check a proof-of-work Raises CheckProofOfWorkError

(hash, nBits)

Source from the content-addressed store, hash-verified

820 pass
821
822def CheckProofOfWork(hash, nBits):
823 """Check a proof-of-work
824
825 Raises CheckProofOfWorkError
826 """
827 target = uint256_from_compact(nBits)
828
829 # Check range
830 if not (0 < target <= coreparams.PROOF_OF_WORK_LIMIT):
831 raise CheckProofOfWorkError("CheckProofOfWork() : nBits below minimum work")
832
833 # Check proof of work matches claimed amount
834 hash = uint256_from_str(hash)
835 if hash > target:
836 raise CheckProofOfWorkError("CheckProofOfWork() : hash doesn't match nBits")
837
838
839def CheckBlockHeader(block_header, fCheckPoW = True, cur_time=None):

Callers 1

CheckBlockHeaderFunction · 0.85

Calls 3

uint256_from_compactFunction · 0.85
uint256_from_strFunction · 0.85

Tested by

no test coverage detected