From: Michael Wozniak Date: Mon, 3 Mar 2014 03:18:26 +0000 (-0500) Subject: update for new transactions with exchange plugin X-Git-Url: https://git.novaco.in/?p=electrum-nvc.git;a=commitdiff_plain;h=3a078f507c0e3a1a938f2efad8444662f2cb8076 update for new transactions with exchange plugin new transactions aren't already loaded to the wallet when the update is run. this catches the exception and gets the transaction value --- diff --git a/plugins/exchange_rate.py b/plugins/exchange_rate.py index e7da497..76fa55c 100644 --- a/plugins/exchange_rate.py +++ b/plugins/exchange_rate.py @@ -219,7 +219,7 @@ class Plugin(BasePlugin): tx_list = self.tx_list mintimestr = datetime.datetime.fromtimestamp(int(min(tx_list.items(), key=lambda x: x[1]['timestamp'])[1]['timestamp'])).strftime('%Y-%m-%d') - maxtimestr = datetime.datetime.fromtimestamp(int( max(tx_list.items(), key=lambda x: x[1]['timestamp'])[1]['timestamp'])).strftime('%Y-%m-%d') + maxtimestr = datetime.datetime.now().strftime('%Y-%m-%d') try: connection = httplib.HTTPSConnection('api.coindesk.com') connection.request("GET", "/v1/bpi/historical/close.json?start=" + mintimestr + "&end=" + maxtimestr) @@ -240,7 +240,14 @@ class Plugin(BasePlugin): childcount = root.childCount() for i in range(childcount): item = root.child(i) - tx_info = tx_list[str(item.data(0, Qt.UserRole).toPyObject())] + try: + tx_info = tx_list[str(item.data(0, Qt.UserRole).toPyObject())] + except Exception: + newtx = self.wallet.get_tx_history() + v = newtx[[x[0] for x in newtx].index(str(item.data(0, Qt.UserRole).toPyObject()))][3] + + tx_info = {'timestamp':int(datetime.datetime.now().strftime("%s")), 'value': v } + pass tx_time = int(tx_info['timestamp']) tx_time_str = datetime.datetime.fromtimestamp(tx_time).strftime('%Y-%m-%d') tx_USD_val = "%.2f %s" % (Decimal(tx_info['value']) / 100000000 * Decimal(resp_hist['bpi'][tx_time_str]), "USD")