Ejemplo n.º 1
0
    def listTransactions(self,
                         limit=100000,
                         start=0,
                         orderby='time',
                         reverse=True):
        '''
        Get a list of transactions by account name and provider_id
        '''

        cache_hash = self.getParamHash(
            "limit=%s&start=%sorderby=%s&reverse=%s" %
            (limit, start, orderby, reverse))
        cached_object = self._cache.fetch('transactions', cache_hash)
        if cached_object:
            return cached_object

        transactions = []
        transaction_list = connector.listTransactionsByAccount(
            self['name'], self['provider_id'], limit, start)

        for entry in transaction_list:
            if entry.get('address', False):
                entry['address'] = CoinAddress(entry['address'], self)

            # give out a provider id and a currency code to the transaction dict
            entry['provider_id'] = self.provider_id
            entry['currency'] = self['currency']

            if entry['category'] == 'receive':
                entry['source_address'] = CoinAddress(
                    entry.get('details', {}).get('sender_address', False),
                    "This is a sender address!")
            elif entry['category'] == 'send':
                entry['source_addresses'] = self[
                    'wallet'].getAddressesByAccount(entry['account'])

            entry['wallet'] = self['wallet']

            coin_transaction = CoinTransaction(entry)
            transactions.append(coin_transaction)

        # sort result
        transactions = sorted(transactions,
                              key=lambda transaction: transaction[orderby],
                              reverse=reverse)

        # cache the result
        self._cache.store('transactions', cache_hash, transactions)
        return transactions
Ejemplo n.º 2
0
 def listTransactions(self, limit=10, start=0):
     '''
     Return a list of transactions wallet-wide
     '''
     # check for cached data, use that or get it again
     cache_hash = self.getParamHash("limit=%s&start=%s" % (limit, start))
     cached_object = self._cache.fetch('transactions', cache_hash)
     if cached_object:
         return cached_object
     
     transactions = []
     transactions_dicts = connector.listTransactionsByAccount("*", self.provider_id, limit, start)
     for transaction in transactions_dicts:
         transaction['wallet'] = self
         transaction['currency'] = self.getCurrencyCode()
         transaction['currency_symbol'] = self.getCurrencySymbol()
         transaction['provider_id'] = self.provider_id
         transactions.append(CoinTransaction(transaction))
     
     self._cache.store('transactions', cache_hash, transactions)
     return transactions
Ejemplo n.º 3
0
    def listTransactions(self, limit=10, start=0):
        '''
        Return a list of transactions wallet-wide
        '''
        # check for cached data, use that or get it again
        cache_hash = self.getParamHash("limit=%s&start=%s" % (limit, start))
        cached_object = self._cache.fetch('transactions', cache_hash)
        if cached_object:
            return cached_object

        transactions = []
        transactions_dicts = connector.listTransactionsByAccount(
            "*", self.provider_id, limit, start)
        for transaction in transactions_dicts:
            transaction['wallet'] = self
            transaction['currency'] = self.getCurrencyCode()
            transaction['currency_symbol'] = self.getCurrencySymbol()
            transaction['provider_id'] = self.provider_id
            transactions.append(CoinTransaction(transaction))

        self._cache.store('transactions', cache_hash, transactions)
        return transactions
Ejemplo n.º 4
0
    def listTransactions(self, limit=100000, start=0, orderby='time', reverse=True):    
        '''
        Get a list of transactions by account name and provider_id
        '''

        cache_hash = self.getParamHash("limit=%s&start=%sorderby=%s&reverse=%s" % (limit, start, orderby, reverse))
        cached_object = self._cache.fetch('transactions', cache_hash)
        if cached_object:
            return cached_object
        
        transactions = []
        transaction_list = connector.listTransactionsByAccount(self['name'], self['provider_id'], limit, start)
        
        for entry in transaction_list:
            if entry.get('address', False):
                entry['address'] = CoinAddress(entry['address'], self)
            
            # give out a provider id and a currency code to the transaction dict
            entry['provider_id'] = self.provider_id
            entry['currency'] = self['currency']
            
            if entry['category'] == 'receive':
                entry['source_address'] = CoinAddress(entry.get('details', {}).get('sender_address', False), "This is a sender address!")
            elif entry['category'] == 'send':
                entry['source_addresses'] = self['wallet'].getAddressesByAccount(entry['account'])
            
            entry['wallet'] = self['wallet']
            
            coin_transaction = CoinTransaction(entry)
            transactions.append(coin_transaction)
            
        # sort result
        transactions = sorted(transactions, key=lambda transaction: transaction[orderby], reverse=reverse) 
            
        # cache the result
        self._cache.store('transactions', cache_hash, transactions)
        return transactions