URI: 
       tMerge branch 'master' of git://github.com/spesmilo/electrum - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 87b94b3ccc4180a84e1f309ead65abd37eae3a9f
   DIR parent 8889c524b556bd3903b6d90f99e9172974f3e20b
  HTML Author: ecdsa <ecdsa@github>
       Date:   Sun, 17 Mar 2013 19:09:06 +0100
       
       Merge branch 'master' of git://github.com/spesmilo/electrum
       
       Diffstat:
         M plugins/labels.py                   |      32 +++++++++++++++++--------------
       
       1 file changed, 18 insertions(+), 14 deletions(-)
       ---
   DIR diff --git a/plugins/labels.py b/plugins/labels.py
       t@@ -13,11 +13,21 @@ from PyQt4.QtGui import *
        from PyQt4.QtCore import *
        import PyQt4.QtCore as QtCore
        import PyQt4.QtGui as QtGui
       +import aes
       +import base64
        from electrum_gui import bmp, pyqrnative, BasePlugin
        from electrum_gui.i18n import _
        
        class Plugin(BasePlugin):
        
       +    def encode(self, message):
       +        encoded_message = base64.b64encode(aes.encryptData(self.encode_password, message))
       +        return encoded_message
       +
       +    def decode(self, message):
       +        decoded_message = aes.decryptData(self.encode_password, base64.b64decode(message)) 
       +        return decoded_message
       +
            def __init__(self, gui):
                self.target_host = 'labelectrum.herokuapp.com'
                BasePlugin.__init__(self, gui, 'labels', _('Label Sync'),_('This plugin can sync your labels accross multiple Electrum installs by using a remote database to save your data. Labels are not encrypted, \
       t@@ -29,6 +39,7 @@ To get started visit http://labelectrum.herokuapp.com/ to sign up for an account
                self.config = gui.config
                self.labels = self.wallet.labels
                self.transactions = self.wallet.transactions
       +        self.encode_password = hashlib.sha1(self.config.get("master_public_key")).digest().encode('hex')[:32]
        
                self.wallet_id = hashlib.sha256(str(self.config.get("master_public_key"))).digest().encode('hex')
        
       t@@ -57,8 +68,7 @@ To get started visit http://labelectrum.herokuapp.com/ to sign up for an account
                if not changed:
                    return 
        
       -        hashed = hashlib.sha256(item).digest().encode('hex')
       -        bundle = {"label": {"external_id": hashed, "text": label}}
       +        bundle = {"label": {"external_id": self.encode(item), "text": self.encode(label)}}
                params = json.dumps(bundle)
                connection = httplib.HTTPConnection(self.target_host)
                connection.request("POST", ("/api/wallets/%s/labels.json?auth_token=%s" % (self.wallet_id, self.auth_token())), params, {'Content-Type': 'application/json'})
       t@@ -143,8 +153,8 @@ To get started visit http://labelectrum.herokuapp.com/ to sign up for an account
            def do_full_push(self):
                bundle = {"labels": {}}
                for key, value in self.labels.iteritems():
       -            hashed = hashlib.sha256(key).digest().encode('hex')
       -            bundle["labels"][hashed] = value
       +            encoded = self.encode(key)
       +            bundle["labels"][encoded] = self.encode(value)
        
                params = json.dumps(bundle)
                connection = httplib.HTTPConnection(self.target_host)
       t@@ -180,14 +190,8 @@ To get started visit http://labelectrum.herokuapp.com/ to sign up for an account
                    return False
        
                for label in response:
       -            for key in self.addresses:
       -                target_hashed = hashlib.sha256(key).digest().encode('hex')
       -                if label["external_id"] == target_hashed:
       -                   if force or not self.labels.get(key):
       -                       self.labels[key] = label["text"] 
       -            for key, value in self.transactions.iteritems():
       -                target_hashed = hashlib.sha256(key).digest().encode('hex')
       -                if label["external_id"] == target_hashed:
       -                   if force or not self.labels.get(key):
       -                       self.labels[key] = label["text"] 
       +             decoded_key = self.decode(label["external_id"]) 
       +             decoded_label = self.decode(label["text"]) 
       +             if force or not self.labels.get(decoded_key):
       +                 self.labels[decoded_key] = decoded_label 
                return True