Browse Source

labels sync for kivy

283
ThomasV 9 years ago
parent
commit
deefd74c37
  1. 1
      gui/kivy/main_window.py
  2. 6
      lib/plugins.py
  3. 13
      plugins/labels/kivy.py
  4. 19
      plugins/labels/labels.py
  5. 16
      plugins/labels/qt.py

1
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:

6
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

13
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()

19
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()

16
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):

Loading…
Cancel
Save