X-Git-Url: https://git.novaco.in/?p=NovacoinLibrary.git;a=blobdiff_plain;f=Novacoin%2FCBlock.cs;h=9bf7e360511138be2d36f284f93c73ef58d52cd7;hp=d80e68e81a7ae960e45df09dd72e0a3baec0f361;hb=3aae916a057b494e197fc0adaaa5656880090565;hpb=bcd2751ce110fd1ad5fcea7e7cbf838673059aea diff --git a/Novacoin/CBlock.cs b/Novacoin/CBlock.cs index d80e68e..9bf7e36 100644 --- a/Novacoin/CBlock.cs +++ b/Novacoin/CBlock.cs @@ -271,7 +271,22 @@ namespace Novacoin private bool CheckProofOfWork(uint256 hash, uint nBits) { - // TODO: stub! + uint256 nTarget = new uint256(); + nTarget.Compact = nBits; + + // Check range + if (nTarget > NetUtils.nProofOfWorkLimit) + { + // nBits below minimum work + return false; + } + + // Check proof of work matches claimed amount + if (hash > nTarget) + { + // hash doesn't match nBits + return false; + } return true; }