Ejemplo n.º 1
0
    def Verify(self):
        if not self.Hash.ToBytes() == GetGenesis().Hash.ToBytes():
            return False

        bc = GetBlockchain()

        if not bc.ContainsBlock(self.Index):
            return False

        if self.Index > 0:
            prev_header = GetBlockchain().GetHeader(self.PrevHash.ToBytes())

            if prev_header is None:
                return False

            if prev_header.Index + 1 != self.Index:
                return False

            if prev_header.Timestamp >= self.Timestamp:
                return False

        # this should be done to actually verify the block
        if not Helper.VerifyScripts(self):
            return False

        return True
Ejemplo n.º 2
0
    def Verify(self):
        print("verifying block base 1")
        if not self.Hash.ToBytes() == GetGenesis().Hash.ToBytes(): return False
        print("verifying block base @ %s " % self.Index)
        bc = GetBlockchain()
        print("BC: %s " % bc)
        if not bc.ContainsBlock(self.Index):
            print("blockchin didnt contain block index")
            return False
        print("verifying block base 3 %s " % self.PrevHash.ToBytes())

        if self.Index > 0:
            prev_header = GetBlockchain().GetHeader(self.PrevHash.ToBytes())

            if prev_header == None: return False

            if prev_header.Index + 1 != self.Index: return False

            if prev_header.Timestamp >= self.Timestamp: return False

        print("Will verify scripts!!")
        #this should be done to actually verify the block
        if not Helper.VerifyScripts(self):
            print("could not verify scripts")
            return False

        return True