def validate_tx(tx, tx_db, network):
    if (not tx.txs_out):
        return
    if tx.missing_unspents():
        print("\n** can't validate transaction as source transactions missing", file=sys.stderr)
    else:
        try:
            if (tx_db is None):
                tx_db = create_tx_db(network)
            tx.validate_unspents(tx_db)
            print('all incoming transaction values validated')
        except BadSpendableError as ex:
            print(('\n**** ERROR: FEES INCORRECTLY STATED: %s' % ex.args[0]), file=sys.stderr)
        except Exception as ex:
            print(("\n*** can't validate source transactions as untampered: %s" % ex.args[0]), file=sys.stderr)
def validate_tx(tx, tx_db, network):
    if (not tx.txs_out):
        return
    if tx.missing_unspents():
        print("\n** can't validate transaction as source transactions missing", file=sys.stderr)
    else:
        try:
            if (tx_db is None):
                tx_db = create_tx_db(network)
            tx.validate_unspents(tx_db)
            print('all incoming transaction values validated')
        except BadSpendableError as ex:
            print(('\n**** ERROR: FEES INCORRECTLY STATED: %s' % ex.args[0]), file=sys.stderr)
        except Exception as ex:
            print(("\n*** can't validate source transactions as untampered: %s" % ex.args[0]), file=sys.stderr)