def transactionDetails(request, txid, provider_id): provider_id = int(provider_id) # set the request in the connector object connector.request = request # get wallet for provider_id wallet = getWalletByProviderId(connector, provider_id) transaction = wallet.getTransactionById(txid) if transaction.get('fee', False): transaction['fee'] = misc.longNumber(transaction['fee']) else: transaction['fee'] = "" if transaction['details'][0]['category'] == 'receive': if not len(transaction['details'][0]['account']): # get the default account for provider_id account = wallet.getDefaultAccount() else: account = wallet.getAccountByAddress( transaction['details'][0]['address']) elif transaction['details'][0]['category'] == 'send': account = transaction['account'] page_title = "Transaction details for %s" % txid context = { 'globals': MainConfig['globals'], 'system_errors': connector.errors, 'system_alerts': connector.alerts, 'request': request, 'breadcrumbs': misc.buildBreadcrumbs(current_section, '', 'Details of %s' % txid), 'page_title': page_title, 'page_sections': misc.getSiteSections(current_section), 'transaction': transaction, 'account': account, 'conf_limit': MainConfig['globals']['confirmation_limit'], } if request.method == 'GET': return render(request, 'transactions/details.html', context) else: # maybe convert to PDF ? return render(request, 'transactions/details.html', context)
def balance(self): ''' Get wallet balance ''' # check for cached data, use that or get it again cache_hash = self.getParamHash("balance") cached_object = self._cache.fetch('balance', cache_hash) if cached_object: return cached_object.get(self.provider_id, "-") balance = connector.getBalance(self.provider_id) # store result in cache self._cache.store('balance', cache_hash, balance) return misc.longNumber(balance.get(self.provider_id, "-"))
def transactionDetails(request, txid, provider_id): provider_id = int(provider_id) # set the request in the connector object connector.request = request # get wallet for provider_id wallet = getWalletByProviderId(connector, provider_id) transaction = wallet.getTransactionById(txid) if transaction.get('fee', False): transaction['fee'] = misc.longNumber(transaction['fee']) else: transaction['fee'] = "" if transaction['details'][0]['category'] == 'receive': if not len(transaction['details'][0]['account']): # get the default account for provider_id account = wallet.getDefaultAccount() else: account = wallet.getAccountByAddress(transaction['details'][0]['address']) elif transaction['details'][0]['category'] == 'send': account = transaction['account'] page_title = "Transaction details for %s" % txid context = { 'globals': MainConfig['globals'], 'system_errors': connector.errors, 'system_alerts': connector.alerts, 'request': request, 'breadcrumbs': misc.buildBreadcrumbs(current_section, '', 'Details of %s' % txid), 'page_title': page_title, 'page_sections': misc.getSiteSections(current_section), 'transaction': transaction, 'account': account, 'conf_limit': MainConfig['globals']['confirmation_limit'], } if request.method == 'GET': return render(request, 'transactions/details.html', context) else: # maybe convert to PDF ? return render(request, 'transactions/details.html', context)
def getBalance(self): ''' Return the account balance ''' balance = connector.getBalance(self.provider_id, self['name']) return misc.longNumber(balance)