Browse Source

don't encrypt keys, because it creates new items everytime

283
ThomasV 11 years ago
parent
commit
30a2a9ee51
  1. 26
      plugins/labels.py

26
plugins/labels.py

@ -31,7 +31,7 @@ class Plugin(BasePlugin):
return _('Label Sync') return _('Label Sync')
def description(self): def description(self):
return '%s\n\n%s%s%s' % (_("This plugin can sync your labels across multiple Electrum installs by using a remote database to save your data. Labels, transactions and addresses are all sent and stored encrypted on the remote server. This code might increase the load of your wallet with a few microseconds as it will sync labels on each startup."), _("To get started visit"), " http://labelectrum.herokuapp.com/ ", _(" to sign up for an account.")) return '%s\n\n%s%s%s' % (_("This plugin can sync your labels across multiple Electrum installs by using a remote database to save your data. Labels encrypted before they are sent to the remote server, but transactions IDs and addresses are not. This code might increase the load of your wallet with a few microseconds as it will sync labels on each startup."), _("To get started visit"), " http://labelectrum.herokuapp.com/ ", _(" to sign up for an account."))
def version(self): def version(self):
return "0.2.1" return "0.2.1"
@ -182,17 +182,12 @@ class Plugin(BasePlugin):
try: try:
bundle = {"labels": {}} bundle = {"labels": {}}
for key, value in self.wallet.labels.iteritems(): for key, value in self.wallet.labels.iteritems():
try:
encoded_key = self.encode(key)
except:
print_error('cannot encode', repr(key))
continue
try: try:
encoded_value = self.encode(value) encoded_value = self.encode(value)
except: except:
print_error('cannot encode', repr(value)) print_error('cannot encode', repr(value))
continue continue
bundle["labels"][encoded_key] = encoded_value bundle["labels"][key] = encoded_value
params = json.dumps(bundle) params = json.dumps(bundle)
connection = httplib.HTTPConnection(self.target_host) connection = httplib.HTTPConnection(self.target_host)
@ -226,15 +221,18 @@ class Plugin(BasePlugin):
raise BaseException(_("Could not sync labels: %s" % response["error"])) raise BaseException(_("Could not sync labels: %s" % response["error"]))
for label in response: for label in response:
decoded_key = self.decode(label["external_id"]) key = label["external_id"]
decoded_label = self.decode(label["text"]) try:
value = self.decode(label["text"])
except:
continue
try: try:
json.dumps(decoded_key) json.dumps(key)
json.dumps(decoded_label) json.dumps(value)
except: except:
print_error('json error: cannot save label', decoded_key) print_error('error: no json', key)
continue continue
if force or not self.wallet.labels.get(decoded_key): if force or not self.wallet.labels.get(key):
self.wallet.labels[decoded_key] = decoded_label self.wallet.labels[key] = value
self.wallet.storage.put('labels', self.wallet.labels) self.wallet.storage.put('labels', self.wallet.labels)
print_error("received labels") print_error("received labels")

Loading…
Cancel
Save