# Path: database.py
# def txn_required(func):
#     @functools.wraps(func)
#     def _func(*args, **kwargs):
#         txn = current_txn()
#         if txn:
#             return func(*args, **kwargs)
#         else:
#             return run_in_transaction(func, txn_name=func.__name__, *args, **kwargs)
#     return _func


import eventlet
import genesisblock
import msgs
import jserialize as js
import bserialize as bs
import logging
import database
import struct
import ec
import settings
from utils import *
from database import txn_required
        return txs.has_key(h)
        
    @property
    def hash(self): return self.tx.hash
    @property
    def hexhash(self): return h2h(self.hash)
    @property
    def confirmed(self): return self.block != nullhash
    @property
    def inputs(self): return self.tx.inputs
    @property
    def outputs(self): return self.tx.outputs
    @property
    def coinbase(self): return self.tx.coinbase
    
    def get_block(self):
        """get the block in which this transaction is included. returns None, if the transaction is not confirmed"""
        if self.confirmed:
            return blockchain.Block.get_by_hash(self.block)
        else:
            return None
            
    def get_confirmations(self):
        """get the number of confirmations this transactions haves."""
        blk0 = self.get_block()
        if not blk0:
            return 0
        blk1 = blockchain.get_bestblock()
        return blk1.number-blk0.number+1
        

# Path: database.py
# def txn_required(func):
#     @functools.wraps(func)
#     def _func(*args, **kwargs):
#         txn = current_txn()
#         if txn:
#             return func(*args, **kwargs)
#         else:
#             return run_in_transaction(func, txn_name=func.__name__, *args, **kwargs)
#     return _func


# Path: transactions.py
import eventlet
import genesisblock
import msgs
import jserialize as js
import bserialize as bs
import logging
import database
import struct
import ec
import settings
from utils import *
from database import txn_required

        return txs.has_key(h)
        
    @property
    def hash(self): return self.tx.hash
    @property
    def hexhash(self): return h2h(self.hash)
    @property
    def confirmed(self): return self.block != nullhash
    @property
    def inputs(self): return self.tx.inputs
    @property
    def outputs(self): return self.tx.outputs
    @property
    def coinbase(self): return self.tx.coinbase
    
    def get_block(self):
        """get the block in which this transaction is included. returns None, if the transaction is not confirmed"""
        if self.confirmed:
            return blockchain.Block.get_by_hash(self.block)
        else:
            return None
            
    def get_confirmations(self):
        """get the number of confirmations this transactions haves."""
        blk0 = self.get_block()
        if not blk0:
            return 0
        blk1 = blockchain.get_bestblock()
        return blk1.number-blk0.number+1
        

    @txn_required