electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit c59ac49feadeb6905aef17990b0f93414fd93574
parent 91ef367176eeb516e6baee2923222078d938f702
Author: SomberNight <somber.night@protonmail.com>
Date:   Mon, 17 Dec 2018 13:41:00 +0100

fix greenaddress plugin: follow-up 75f6ab913316998e1e3c4b1d256de17bc367ea8e

Diffstat:
Melectrum/plugins/greenaddress_instant/qt.py | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/electrum/plugins/greenaddress_instant/qt.py b/electrum/plugins/greenaddress_instant/qt.py @@ -26,6 +26,7 @@ import base64 import urllib.parse import sys +from typing import TYPE_CHECKING from PyQt5.QtWidgets import QApplication, QPushButton @@ -33,6 +34,9 @@ from electrum.plugin import BasePlugin, hook from electrum.i18n import _ from electrum.network import Network +if TYPE_CHECKING: + from aiohttp import ClientResponse + class Plugin(BasePlugin): @@ -89,15 +93,17 @@ class Plugin(BasePlugin): sig = base64.b64encode(sig).decode('ascii') # 2. send the request + async def handle_request(resp: 'ClientResponse'): + resp.raise_for_status() + return await resp.json() url = "https://greenaddress.it/verify/?signature=%s&txhash=%s" % (urllib.parse.quote(sig), tx.txid()) - response = Network.send_http_on_proxy('get', url, headers = {'User-Agent': 'Electrum'}) - response = response.json() + response = Network.send_http_on_proxy('get', url, headers = {'User-Agent': 'Electrum'}, on_finish=handle_request) # 3. display the result if response.get('verified'): d.show_message(_('{} is covered by GreenAddress instant confirmation').format(tx.txid()), title=_('Verification successful!')) else: - d.show_critical(_('{} is not covered by GreenAddress instant confirmation').format(tx.txid()), title=_('Verification failed!')) + d.show_warning(_('{} is not covered by GreenAddress instant confirmation').format(tx.txid()), title=_('Verification failed!')) except BaseException as e: import traceback traceback.print_exc(file=sys.stdout)