Example #1
0
    def Verify(self):
        """
        Verify block using the verification script.

        Returns:
            bool: True if valid. False otherwise.
        """
        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
    def Verify(self, mempool):
        """
        Verify the transaction.

        Args:
            mempool:

        Returns:
            bool: True if verified. False otherwise.
        """
        logger.info("Verifying transaction: %s " % self.Hash.ToBytes())

        return Helper.VerifyScripts(self)
Example #3
0
    def Verify(self, mempool):
        self.__log.debug("Verifying transaction: %s " % self.Hash.ToBytes())

        return Helper.VerifyScripts(self)
Example #4
0
    def Verify(self, mempool):
        self.__log.debug("Verifying transaction: %s " % self.HashToString())
        for i in range(1, len(self.inputs)):
            j = 0
            while j < i:
                j = j + 1
                if self.inputs[i].PrevHash() == self.inputs[j].PrevHash(
                ) and self.inputs[i].PrevIndex() == self.inputs[j].PrevIndex():
                    return False
        self.__log.debug("Verified inputs 1")
        for tx in mempool:
            if tx is not self:
                for ip in self.inputs:
                    if ip in tx.inputs:
                        return False

        self.__log.debug("Verified inputs 2, checking double spend")

        if GetBlockchain().IsDoubleSpend(self):
            return False

        self.__log.debug("verifying outputs ...")
        for txOutput in self.outputs:
            asset = GetBlockchain().GetAssetState(txOutput.AssetId)

            if asset is None: return False

            if txOutput.Value % pow(10, 8 - asset.Precision) != 0:
                return False

        self.__log.debug("unimplemented after here ...")
        return True

        txResults = self.GetTransactionResults()

        if txResults is None: return False

        destroyedResults = []
        [
            destroyedResults.append(tx) for tx in txResults
            if tx.Amount == Fixed8(0)
        ]
        numDestroyed = len(destroyedResults)
        if numDestroyed > 1:
            return False
        if numDestroyed == 1 and destroyedResults[0].AssetId != GetSystemCoin(
        ).Hash():
            return False
        if self.SystemFee() > Fixed8(0) and (
                numDestroyed == 0
                or destroyedResults[0].Amount < self.SystemFee()):
            return False

        issuedResults = []

        [
            issuedResults.append(tx) for tx in txResults
            if tx.Amount() < Fixed8(0)
        ]

        if self.Type == TransactionType.MinerTransaction or self.Type == TransactionType.ClaimTransaction:
            for tx in issuedResults:
                if tx.AssetId != GetSystemCoin().Hash():
                    return False

        elif self.Type == TransactionType.IssueTransaction:
            for tx in issuedResults:
                if tx.AssetId != GetSystemCoin().Hash():
                    return False

        else:
            if len(issuedResults) > 0:
                return False

        usageECDH = 0

        for attr in self.Attributes:
            if attr.Usage == TransactionAttributeUsage.ECDH02 or attr.Usage == TransactionAttributeUsage.ECDH03:
                usageECDH = usageECDH + 1
                if usageECDH > 1:
                    return False

        return Helper.VerifyScripts(self)
Example #5
0
    def Verify(self, mempool):
        logger.info("Verifying transaction: %s " % self.Hash.ToBytes())

        return Helper.VerifyScripts(self)