Browse Source

simplification

283
thomasv 13 years ago
parent
commit
6057926016
  1. 28
      client/gui.py
  2. 27
      client/gui_qt.py
  3. 23
      client/wallet.py

28
client/gui.py

@ -696,34 +696,8 @@ class ElectrumWindow:
def set_url(self, url):
payto, amount, label, message, signature, identity, url = self.wallet.parse_url(url)
payto, amount, label, message, signature, identity, url = self.wallet.parse_url(url, self.show_message, self.question)
self.notebook.set_current_page(1)
if signature:
if re.match('^(|([\w\-\.]+)@)((\w[\w\-]+\.)+[\w\-]+)$', identity):
signing_address = self.wallet.get_alias(identity, True, self.show_message, self.question)
elif self.wallet.is_valid(identity):
signing_address = identity
else:
signing_address = None
if not signing_address:
return
try:
self.wallet.verify_message(signing_address, signature, url )
self.wallet.receipt = (signing_address, signature, url)
except:
self.show_message('Warning: the URI contains a bad signature.\nThe identity of the recipient cannot be verified.')
payto = amount = label = identity = message = ''
# redundant with aliases
#if label and payto:
# self.labels[payto] = label
if re.match('^(|([\w\-\.]+)@)((\w[\w\-]+\.)+[\w\-]+)$', payto):
payto_address = self.wallet.get_alias(payto, True, self.show_message, self.question)
if payto_address:
payto = payto + ' <' + payto_address + '>'
self.payto_entry.set_text(payto)
self.message_entry.set_text(message)
self.amount_entry.set_text(amount)

27
client/gui_qt.py

@ -328,33 +328,8 @@ class ElectrumWindow(QMainWindow):
def set_url(self, url):
payto, amount, label, message, signature, identity, url = self.wallet.parse_url(url)
payto, amount, label, message, signature, identity, url = self.wallet.parse_url(url, self.show_message, self.question)
self.tabs.setCurrentIndex(1)
if signature:
if re.match('^(|([\w\-\.]+)@)((\w[\w\-]+\.)+[\w\-]+)$', identity):
signing_address = self.wallet.get_alias(identity, True, self.show_message, self.question)
elif self.wallet.is_valid(identity):
signing_address = identity
else:
signing_address = None
if not signing_address:
return
try:
self.wallet.verify_message(signing_address, signature, url )
self.wallet.receipt = (signing_address, signature, url)
except:
self.show_message('Warning: the URI contains a bad signature.\nThe identity of the recipient cannot be verified.')
payto = amount = label = identity = message = ''
# redundant with aliases
#if label and payto:
# self.labels[payto] = label
if re.match('^(|([\w\-\.]+)@)((\w[\w\-]+\.)+[\w\-]+)$', payto):
payto_address = self.wallet.get_alias(payto, True, self.show_message, self.question)
if payto_address:
payto = payto + ' <' + payto_address + '>'
self.payto_e.setText(payto)
self.message_e.setText(message)
self.amount_e.setText(amount)

23
client/wallet.py

@ -815,7 +815,7 @@ class Wallet:
return target
def parse_url(self, url):
def parse_url(self, url, show_message, question):
o = url[8:].split('?')
address = o[0]
if len(o)>1:
@ -836,4 +836,25 @@ class Wallet:
else:
print k,v
if signature:
if re.match('^(|([\w\-\.]+)@)((\w[\w\-]+\.)+[\w\-]+)$', identity):
signing_address = self.get_alias(identity, True, show_message, question)
elif self.is_valid(identity):
signing_address = identity
else:
signing_address = None
if not signing_address:
return
try:
self.verify_message(signing_address, signature, url )
self.receipt = (signing_address, signature, url)
except:
self.show_message('Warning: the URI contains a bad signature.\nThe identity of the recipient cannot be verified.')
address = amount = label = identity = message = ''
if re.match('^(|([\w\-\.]+)@)((\w[\w\-]+\.)+[\w\-]+)$', address):
payto_address = self.get_alias(payto, True, show_message, question)
if payto_address:
address = address + ' <' + payto_address + '>'
return address, amount, label, message, signature, identity, url

Loading…
Cancel
Save