fixes for pending accounts
[electrum-nvc.git] / gui / qt / main_window.py
index 4dec40e..3b7c142 100644 (file)
@@ -444,9 +444,14 @@ class ElectrumWindow(QMainWindow):
 
 
     def base_unit(self):
-        assert self.decimal_point in [5,8]
-        return "BTC" if self.decimal_point == 8 else "mBTC"
-
+        assert self.decimal_point in [2, 5, 8]
+        if self.decimal_point == 2:
+            return 'bits'
+        if self.decimal_point == 5:
+            return 'mBTC'
+        if self.decimal_point == 8:
+            return 'BTC'
+        raise Exception('Unknown base unit')
 
     def update_status(self):
         if self.network is None or not self.network.is_running():
@@ -987,7 +992,12 @@ class ElectrumWindow(QMainWindow):
             return
 
         for addr, x in outputs:
-            if addr is None or not bitcoin.is_address(addr):
+            if addr is None:
+                QMessageBox.warning(self, _('Error'), _('Bitcoin Address is None'), _('OK'))
+                return
+            if addr.startswith('OP_RETURN:'):
+                continue
+            if not bitcoin.is_address(addr):
                 QMessageBox.warning(self, _('Error'), _('Invalid Bitcoin Address'), _('OK'))
                 return
             if x is None:
@@ -1043,6 +1053,8 @@ class ElectrumWindow(QMainWindow):
 
         # sign the tx
         def sign_thread():
+            if self.wallet.is_watching_only():
+                return tx
             keypairs = {}
             try:
                 self.wallet.add_keypairs(tx, keypairs, password)
@@ -1763,7 +1775,7 @@ class ElectrumWindow(QMainWindow):
 
         self.wallet.create_pending_account(name, password)
         self.update_address_tab()
-        self.tabs.setCurrentIndex(2)
+        self.tabs.setCurrentIndex(3)
 
 
 
@@ -1975,7 +1987,7 @@ class ElectrumWindow(QMainWindow):
 
         pubkey_e = QLineEdit()
         if address:
-            pubkey = self.wallet.getpubkeys(address)[0]
+            pubkey = self.wallet.get_public_keys(address)[0]
             pubkey_e.setText(pubkey)
         layout.addWidget(QLabel(_('Public key')), 2, 0)
         layout.addWidget(pubkey_e, 2, 1)
@@ -2051,7 +2063,7 @@ class ElectrumWindow(QMainWindow):
 
         if is_hex:
             try:
-                return Transaction(txt)
+                return Transaction.deserialize(txt)
             except:
                 traceback.print_exc(file=sys.stdout)
                 QMessageBox.critical(None, _("Unable to parse transaction"), _("Electrum was unable to parse your transaction"))
@@ -2060,7 +2072,7 @@ class ElectrumWindow(QMainWindow):
         try:
             tx_dict = json.loads(str(txt))
             assert "hex" in tx_dict.keys()
-            tx = Transaction(tx_dict["hex"])
+            tx = Transaction.deserialize(tx_dict["hex"])
             #if tx_dict.has_key("input_info"):
             #    input_info = json.loads(tx_dict['input_info'])
             #    tx.add_input_info(input_info)
@@ -2111,7 +2123,7 @@ class ElectrumWindow(QMainWindow):
         if ok and txid:
             r = self.network.synchronous_get([ ('blockchain.transaction.get',[str(txid)]) ])[0]
             if r:
-                tx = transaction.Transaction(r)
+                tx = transaction.Transaction.deserialize(r)
                 if tx:
                     self.show_transaction(tx)
                 else:
@@ -2481,7 +2493,7 @@ class ElectrumWindow(QMainWindow):
         if not self.config.is_modifiable('fee_per_kb'):
             for w in [fee_e, fee_label]: w.setEnabled(False)
 
-        units = ['BTC', 'mBTC']
+        units = ['BTC', 'mBTC', 'bits']
         unit_label = QLabel(_('Base unit') + ':')
         grid.addWidget(unit_label, 3, 0)
         unit_combo = QComboBox()
@@ -2552,7 +2564,14 @@ class ElectrumWindow(QMainWindow):
 
         unit_result = units[unit_combo.currentIndex()]
         if self.base_unit() != unit_result:
-            self.decimal_point = 8 if unit_result == 'BTC' else 5
+            if unit_result == 'BTC':
+                self.decimal_point = 8
+            elif unit_result == 'mBTC':
+                self.decimal_point = 5
+            elif unit_result == 'bits':
+                self.decimal_point = 2
+            else:
+                raise Exception('Unknown base unit')
             self.config.set_key('decimal_point', self.decimal_point, True)
             self.update_history_tab()
             self.update_status()