electrum

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

commit bb88c891dca13fdef9a3d3eb04d188aebb563709
parent 9196e9feeaa2eb5505edf95d597c49dd34842c79
Author: ThomasV <thomasv@gitorious>
Date:   Wed, 30 Apr 2014 07:59:59 +0200

move set_url to __init__. fixes #672

Diffstat:
Mgui/qt/__init__.py | 27++++++++++++++++++++++++++-
Mgui/qt/main_window.py | 25+------------------------
Mlib/util.py | 7++-----
3 files changed, 29 insertions(+), 30 deletions(-)

diff --git a/gui/qt/__init__.py b/gui/qt/__init__.py @@ -147,6 +147,29 @@ class ElectrumGui: return int(qtVersion[0]) >= 4 and int(qtVersion[2]) >= 7 + def set_url(self, url): + from electrum import util + from decimal import Decimal + try: + address, amount, label, message, url = util.parse_url(url) + except Exception: + QMessageBox.warning(self.main_window, _('Error'), _('Invalid bitcoin URL'), _('OK')) + return + + try: + if amount and self.main_window.base_unit() == 'mBTC': + amount = str( 1000* Decimal(amount)) + elif amount: + amount = str(Decimal(amount)) + except Exception: + amount = "0.0" + QMessageBox.warning(self.main_window, _('Error'), _('Invalid Amount'), _('OK')) + + + self.main_window.set_send(address, amount, label, message) + if self.lite_window: + self.lite_window.set_payment_fields(address, amount) + def main(self, url): @@ -191,7 +214,9 @@ class ElectrumGui: s.start() self.windows.append(w) - if url: w.set_url(url) + if url: + self.set_url(url) + w.app = self.app w.connect_slots(s) w.update_wallet() diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -880,22 +880,8 @@ class ElectrumWindow(QMainWindow): - def set_url(self, url): - try: - address, amount, label, message, signature, identity, url = util.parse_url(url) - except Exception: - QMessageBox.warning(self, _('Error'), _('Invalid bitcoin URL'), _('OK')) - return - try: - if amount and self.base_unit() == 'mBTC': amount = str( 1000* Decimal(amount)) - elif amount: amount = str(Decimal(amount)) - except Exception: - amount = "0.0" - QMessageBox.warning(self, _('Error'), _('Invalid Amount'), _('OK')) - - if self.mini: - self.mini.set_payment_fields(address, amount) + def set_send(self, address, amount, label, message): if label and self.wallet.labels.get(address) != label: if self.question('Give label "%s" to address %s ?'%(label,address)): @@ -903,8 +889,6 @@ class ElectrumWindow(QMainWindow): self.wallet.addressbook.append(address) self.wallet.set_label(address, label) - run_hook('set_url', url, self.show_message, self.question) - self.tabs.setCurrentIndex(1) label = self.wallet.labels.get(address) m_addr = label + ' <'+ address +'>' if label else address @@ -914,13 +898,6 @@ class ElectrumWindow(QMainWindow): if amount: self.amount_e.setText(amount) - if identity: - self.set_frozen(self.payto_e,True) - self.set_frozen(self.amount_e,True) - self.set_frozen(self.message_e,True) - self.payto_sig.setText( ' '+_('The bitcoin URI was signed by')+' ' + identity ) - else: - self.payto_sig.setVisible(False) def do_clear(self): self.payto_sig.setVisible(False) diff --git a/lib/util.py b/lib/util.py @@ -171,7 +171,7 @@ def parse_url(url): kv = {} - amount = label = message = signature = identity = '' + amount = label = message = '' for p in params: k,v = p.split('=') uv = urldecode(v) @@ -191,11 +191,8 @@ def parse_url(url): message = kv['message'] if 'label' in kv: label = kv['label'] - if 'signature' in kv: - identity, signature = kv['signature'].split(':') - url = url.replace('&%s=%s'%('signature',kv['signature']),'') - return address, amount, label, message, signature, identity, url + return address, amount, label, message, url # Python bug (http://bugs.python.org/issue1927) causes raw_input