def tx_signed(self, tx, block, check_mempool):
        tx.calc_sha256()

        for i in xrange(len(tx.vin)):
            txin = tx.vin[i]

            # search database for dependent TX
            txfrom = self.gettx(txin.prevout.hash)

            # search block for dependent TX
            if txfrom is None and block is not None:
                for blktx in block.vtx:
                    blktx.calc_sha256()
                    if blktx.sha256 == txin.prevout.hash:
                        txfrom = blktx
                        break

            # search mempool for dependent TX
            if txfrom is None and check_mempool:
                try:
                    txfrom = self.mempool.pool[txin.prevout.hash]
                except:
                    self.log.write("TX %064x/%d no-dep %064x" %
                                   (tx.sha256, i, txin.prevout.hash))
                    return False
            if txfrom is None:
                self.log.write("TX %064x/%d no-dep %064x" %
                               (tx.sha256, i, txin.prevout.hash))
                return False

            if not VerifySignature(txfrom, tx, i, 0):
                self.log.write("TX %064x/%d sigfail" % (tx.sha256, i))
                return False

        return True
def scan_tx(tx):
	if tx:
        	tx.calc_sha256()
        	for i in xrange(len(tx.vin)):
                	txin = tx.vin[i]
                	txfrom = chaindb.gettx(txin.prevout.hash)
                	if not VerifySignature(txfrom, tx, i, 0):
                        	log.write("TX %064x/%d failed" % (tx.sha256, i))
                        	log.write("FROMTX %064x" % (txfrom.sha256,))
                        	log.write(txfrom.__repr__())
                        	log.write("TOTX %064x" % (tx.sha256,))
                        	log.write(tx.__repr__())
                        	return False
		return True
	else:
		return False
Exemple #3
0
def scan_tx(chaindb, tx):
    tx.calc_sha256()

    flag = 1

    for i in xrange(len(tx.vin)):
        txin = tx.vin[i]
        try:
            txfrom = chaindb.gettx(txin.prevout.hash)
        except:
            txfrom = ""
            log.write("ERROR: tx %064x" % tx.sha256)

        if txfrom:
            if not VerifySignature(txfrom, tx, i, 0):
                log.write("TX %064x/%d failed" % (tx.sha256, i))
                #log.write("FROMTX %064x" % (txfrom.sha256,))
                #log.write(txfrom.__repr__())
                #log.write("TOTX %064x" % (tx.sha256,))
                #log.write(tx.__repr__())
                flag = 0

    return flag