|
@ -26,6 +26,7 @@ |
|
|
import base64 |
|
|
import base64 |
|
|
import urllib.parse |
|
|
import urllib.parse |
|
|
import sys |
|
|
import sys |
|
|
|
|
|
from typing import TYPE_CHECKING |
|
|
|
|
|
|
|
|
from PyQt5.QtWidgets import QApplication, QPushButton |
|
|
from PyQt5.QtWidgets import QApplication, QPushButton |
|
|
|
|
|
|
|
@ -33,6 +34,9 @@ from electrum.plugin import BasePlugin, hook |
|
|
from electrum.i18n import _ |
|
|
from electrum.i18n import _ |
|
|
from electrum.network import Network |
|
|
from electrum.network import Network |
|
|
|
|
|
|
|
|
|
|
|
if TYPE_CHECKING: |
|
|
|
|
|
from aiohttp import ClientResponse |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Plugin(BasePlugin): |
|
|
class Plugin(BasePlugin): |
|
|
|
|
|
|
|
@ -89,15 +93,17 @@ class Plugin(BasePlugin): |
|
|
sig = base64.b64encode(sig).decode('ascii') |
|
|
sig = base64.b64encode(sig).decode('ascii') |
|
|
|
|
|
|
|
|
# 2. send the request |
|
|
# 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()) |
|
|
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 = Network.send_http_on_proxy('get', url, headers = {'User-Agent': 'Electrum'}, on_finish=handle_request) |
|
|
response = response.json() |
|
|
|
|
|
|
|
|
|
|
|
# 3. display the result |
|
|
# 3. display the result |
|
|
if response.get('verified'): |
|
|
if response.get('verified'): |
|
|
d.show_message(_('{} is covered by GreenAddress instant confirmation').format(tx.txid()), title=_('Verification successful!')) |
|
|
d.show_message(_('{} is covered by GreenAddress instant confirmation').format(tx.txid()), title=_('Verification successful!')) |
|
|
else: |
|
|
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: |
|
|
except BaseException as e: |
|
|
import traceback |
|
|
import traceback |
|
|
traceback.print_exc(file=sys.stdout) |
|
|
traceback.print_exc(file=sys.stdout) |
|
|