AmountEdit:get_amount
[electrum-nvc.git] / plugins / labels.py
index 4d8d813..83609b0 100644 (file)
@@ -7,7 +7,7 @@ import json
 from urlparse import urlparse, parse_qs
 try:
     import PyQt4
-except:
+except Exception:
     sys.exit("Error: Could not import PyQt4 on Linux systems, you may try 'sudo apt-get install python-qt4'")
 
 from PyQt4.QtGui import *
@@ -16,11 +16,10 @@ import PyQt4.QtCore as QtCore
 import PyQt4.QtGui as QtGui
 import aes
 import base64
-from electrum import bmp, pyqrnative
 from electrum.plugins import BasePlugin
 from electrum.i18n import _
 
-from electrum_gui.qt import HelpButton
+from electrum_gui.qt import HelpButton, EnterButton
 
 class Plugin(BasePlugin):
 
@@ -51,7 +50,10 @@ class Plugin(BasePlugin):
 
     def load_wallet(self, wallet):
         self.wallet = wallet
-        mpk = self.wallet.master_public_keys["m/0'/"][1]
+        if self.wallet.get_master_public_key():
+            mpk = self.wallet.get_master_public_key()
+        else:
+            mpk = self.wallet.master_public_keys["m/0'/"][1]
         self.encode_password = hashlib.sha1(mpk).digest().encode('hex')[:32]
         self.wallet_id = hashlib.sha256(mpk).digest().encode('hex')
 
@@ -92,6 +94,9 @@ class Plugin(BasePlugin):
             print_error('Error connecting to service: %s ' %  e)
             return False
 
+    def settings_widget(self, window):
+        return EnterButton(_('Settings'), self.settings_dialog)
+
     def settings_dialog(self):
         def check_for_api_key(api_key):
             if api_key and len(api_key) > 12:
@@ -104,7 +109,7 @@ class Plugin(BasePlugin):
               self.download.setEnabled(False)
               self.accept.setEnabled(False)
 
-        d = QDialog(self.window)
+        d = QDialog()
         layout = QGridLayout(d)
         layout.addWidget(QLabel("API Key: "),0,0)
 
@@ -147,6 +152,7 @@ class Plugin(BasePlugin):
     def enable(self):
         if not self.auth_token(): # First run, throw plugin settings in your face
             self.init()
+            self.load_wallet(self.gui.main_window.wallet)
             if self.settings_dialog():
                 self.set_enabled(True)
                 return True