electrum

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

commit deefd74c3751d1f7e84dbdfe6812db460f7124d5
parent 0215aee047fe1e7d6c61c0bb204a7c041b9cb641
Author: ThomasV <thomasv@electrum.org>
Date:   Tue,  1 Dec 2015 17:29:24 +0100

labels sync for kivy

Diffstat:
Mgui/kivy/main_window.py | 1+
Mlib/plugins.py | 6------
Mplugins/labels/kivy.py | 13++++++++++++-
Mplugins/labels/labels.py | 19+++++++++++++++----
Mplugins/labels/qt.py | 16+---------------
5 files changed, 29 insertions(+), 26 deletions(-)

diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py @@ -404,6 +404,7 @@ class ElectrumWindow(App): # since the callback has been called before the GUI was initialized self.update_history_tab() self.notify_transactions() + run_hook('load_wallet', wallet, self) def update_status(self, *dt): if not self.wallet: diff --git a/lib/plugins.py b/lib/plugins.py @@ -194,12 +194,6 @@ class BasePlugin(PrintError): def thread_jobs(self): return [] - @hook - def load_wallet(self, wallet, window): pass - - @hook - def close_wallet(self): pass - def is_enabled(self): return self.is_available() and self.config.get('use_'+self.name) is True diff --git a/plugins/labels/kivy.py b/plugins/labels/kivy.py @@ -1,3 +1,14 @@ from labels import LabelsPlugin +from electrum.plugins import hook + class Plugin(LabelsPlugin): - pass + + @hook + def load_wallet(self, wallet, window): + self.window = window + self.start_wallet(wallet) + + def on_pulled(self, wallet): + self.print_error('on pulled') + self.window.update_history_tab() + diff --git a/plugins/labels/labels.py b/plugins/labels/labels.py @@ -1,3 +1,4 @@ +import hashlib import requests import threading import json @@ -132,7 +133,17 @@ class LabelsPlugin(BasePlugin): traceback.print_exc(file=sys.stderr) self.print_error("could not retrieve labels") - - - - + def start_wallet(self, wallet): + nonce = self.get_nonce(wallet) + self.print_error("wallet", wallet.basename(), "nonce is", nonce) + mpk = ''.join(sorted(wallet.get_master_public_keys().values())) + if not mpk: + return + password = hashlib.sha1(mpk).digest().encode('hex')[:32] + iv = hashlib.sha256(password).digest()[:16] + wallet_id = hashlib.sha256(mpk).digest().encode('hex') + self.wallets[wallet] = (password, iv, wallet_id) + # If there is an auth token we can try to actually start syncing + t = threading.Thread(target=self.pull_thread, args=(wallet, False)) + t.setDaemon(True) + t.start() diff --git a/plugins/labels/qt.py b/plugins/labels/qt.py @@ -1,4 +1,3 @@ -import hashlib import threading from functools import partial @@ -59,20 +58,7 @@ class Plugin(LabelsPlugin): @hook def on_new_window(self, window): window.connect(window.app, SIGNAL('labels_changed'), window.update_tabs) - wallet = window.wallet - nonce = self.get_nonce(wallet) - self.print_error("wallet", wallet.basename(), "nonce is", nonce) - mpk = ''.join(sorted(wallet.get_master_public_keys().values())) - if not mpk: - return - password = hashlib.sha1(mpk).digest().encode('hex')[:32] - iv = hashlib.sha256(password).digest()[:16] - wallet_id = hashlib.sha256(mpk).digest().encode('hex') - self.wallets[wallet] = (password, iv, wallet_id) - # If there is an auth token we can try to actually start syncing - t = threading.Thread(target=self.pull_thread, args=(wallet, False)) - t.setDaemon(True) - t.start() + self.start_wallet(window.wallet) @hook def on_close_window(self, window):