Browse Source

Merge pull request #3057 from SomberNight/greenaddress_maintenance1

maintenance for greenaddress plugin
master
ThomasV 8 years ago committed by GitHub
parent
commit
a74e49ea31
  1. 14
      plugins/greenaddress_instant/qt.py

14
plugins/greenaddress_instant/qt.py

@ -24,7 +24,7 @@
# SOFTWARE. # SOFTWARE.
import base64 import base64
import urllib import urllib.parse
import sys import sys
import requests import requests
@ -67,7 +67,7 @@ class Plugin(BasePlugin):
window = d.parent window = d.parent
# 1. get the password and sign the verification request # 1. get the password and sign the verification request
password = None password = None
if wallet.use_encryption: if wallet.has_password():
msg = _('GreenAddress requires your signature \n' msg = _('GreenAddress requires your signature \n'
'to verify that transaction is instant.\n' 'to verify that transaction is instant.\n'
'Please enter your password to sign a\n' 'Please enter your password to sign a\n'
@ -80,20 +80,20 @@ class Plugin(BasePlugin):
QApplication.processEvents() # update the button label QApplication.processEvents() # update the button label
addr = self.get_my_addr(d) addr = self.get_my_addr(d)
message = "Please verify if %s is GreenAddress instant confirmed" % tx.hash() message = "Please verify if %s is GreenAddress instant confirmed" % tx.txid()
sig = wallet.sign_message(addr, message, password) sig = wallet.sign_message(addr, message, password)
sig = base64.b64encode(sig) sig = base64.b64encode(sig).decode('ascii')
# 2. send the request # 2. send the request
response = requests.request("GET", ("https://greenaddress.it/verify/?signature=%s&txhash=%s" % (urllib.quote(sig), tx.hash())), response = requests.request("GET", ("https://greenaddress.it/verify/?signature=%s&txhash=%s" % (urllib.parse.quote(sig), tx.txid())),
headers = {'User-Agent': 'Electrum'}) headers = {'User-Agent': 'Electrum'})
response = response.json() response = response.json()
# 3. display the result # 3. display the result
if response.get('verified'): if response.get('verified'):
d.show_message(_('%s is covered by GreenAddress instant confirmation') % (tx.hash()), title=_('Verification successful!')) d.show_message(_('%s is covered by GreenAddress instant confirmation') % (tx.txid()), title=_('Verification successful!'))
else: else:
d.show_critical(_('%s is not covered by GreenAddress instant confirmation') % (tx.hash()), title=_('Verification failed!')) d.show_critical(_('%s is not covered by GreenAddress instant confirmation') % (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)

Loading…
Cancel
Save