electrum

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

commit 35aba0c14bb9ae29a3bbcdb7153ce72e8692f7c5
parent 2e6aa9067f45535fe0b5e28ce9b2de7f417613a1
Author: ThomasV <thomasv@gitorious>
Date:   Sat, 11 Jul 2015 18:14:00 +0200

show alias satus in gui after fetch

Diffstat:
Mgui/qt/main_window.py | 29++++++++++++++++++++++-------
Mgui/qt/paytoedit.py | 6++++--
Mgui/qt/util.py | 4++++
Mlib/contacts.py | 5++++-
4 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -184,13 +184,15 @@ class ElectrumWindow(QMainWindow): self.qr_window = None self.not_enough_funds = False self.pluginsdialog = None - self.fetch_alias_info() + self.fetch_alias() - def fetch_alias_info(self): + def fetch_alias(self): self.alias_info = None alias = str(self.config.get('alias')) if alias: - f = lambda: setattr(self, 'alias_info', self.contacts.resolve_openalias(alias)) + def f(): + self.alias_info = self.contacts.resolve_openalias(alias) + self.emit(SIGNAL('alias_received')) t = threading.Thread(target=f) t.setDaemon(True) t.start() @@ -2533,12 +2535,25 @@ class ElectrumWindow(QMainWindow): + '\n'.join(['https://cryptoname.co/', 'http://xmr.link']) + '\n\n'\ + 'For more information, see http://openalias.org' alias_label = HelpLabel(_('Alias') + ':', alias_help) - alias_e = QLineEdit(self.config.get('alias','')) - def on_alias(): + alias = self.config.get('alias','') + alias_e = QLineEdit(alias) + def set_alias_color(): + if self.alias_info: + alias_addr, alias_name, validated = self.alias_info + alias_e.setStyleSheet(GREEN_BG if validated else RED_BG) + else: + alias_e.setStyleSheet(RED_BG) + + def on_alias_edit(): + alias_e.setStyleSheet("") alias = str(alias_e.text()) self.config.set_key('alias', alias, True) - self.fetch_alias_info() - alias_e.editingFinished.connect(on_alias) + self.fetch_alias() + + set_alias_color() + self.connect(self, SIGNAL('alias_received'), set_alias_color) + alias_e.editingFinished.connect(on_alias_edit) + tx_widgets.append((alias_label, alias_e)) units = ['BTC', 'mBTC', 'bits'] diff --git a/gui/qt/paytoedit.py b/gui/qt/paytoedit.py @@ -24,6 +24,8 @@ import re from decimal import Decimal from electrum import bitcoin +import util + RE_ADDRESS = '[1-9A-HJ-NP-Za-km-z]{26,}' RE_ALIAS = '(.*?)\s*\<([1-9A-HJ-NP-Za-km-z]{26,})\>' @@ -64,10 +66,10 @@ class PayToEdit(ScanQRTextEdit): button.setHidden(b) def setGreen(self): - self.setStyleSheet("QWidget { background-color:#80ff80;}") + self.setStyleSheet(util.GREEN_BG) def setExpired(self): - self.setStyleSheet("QWidget { background-color:#ffcccc;}") + self.setStyleSheet(util.RED_BG) def parse_address_and_amount(self, line): x, y = line.split(',') diff --git a/gui/qt/util.py b/gui/qt/util.py @@ -16,6 +16,10 @@ else: MONOSPACE_FONT = 'monospace' +GREEN_BG = "QWidget {background-color:#80ff80;}" +RED_BG = "QWidget {background-color:#ffcccc;}" + + class WaitingDialog(QThread): def __init__(self, parent, message, run_task, on_success=None, on_complete=None): QThread.__init__(self) diff --git a/lib/contacts.py b/lib/contacts.py @@ -40,7 +40,10 @@ class Contacts(StoreDict): def resolve_openalias(self, url): # support email-style addresses, per the OA standard url = url.replace('@', '.') - records, validated = dnssec.query(url, dns.rdatatype.TXT) + try: + records, validated = dnssec.query(url, dns.rdatatype.TXT) + except: + return prefix = 'btc' for record in records: string = record.strings[0]