store output type explicitly in tuple
[electrum-nvc.git] / gui / qt / main_window.py
index 3b7c142..7ced30e 100644 (file)
@@ -991,20 +991,20 @@ class ElectrumWindow(QMainWindow):
             QMessageBox.warning(self, _('Error'), _('No outputs'), _('OK'))
             return
 
-        for addr, x in outputs:
+        for type, addr, amount in outputs:
             if addr is None:
                 QMessageBox.warning(self, _('Error'), _('Bitcoin Address is None'), _('OK'))
                 return
-            if addr.startswith('OP_RETURN:'):
+            if type == 'op_return':
                 continue
-            if not bitcoin.is_address(addr):
+            if type == 'address' and not bitcoin.is_address(addr):
                 QMessageBox.warning(self, _('Error'), _('Invalid Bitcoin Address'), _('OK'))
                 return
-            if x is None:
+            if amount is None:
                 QMessageBox.warning(self, _('Error'), _('Invalid Amount'), _('OK'))
                 return
 
-        amount = sum(map(lambda x:x[1], outputs))
+        amount = sum(map(lambda x:x[2], outputs))
 
         fee = self.fee_e.get_amount()
         if fee is None:
@@ -1013,7 +1013,7 @@ class ElectrumWindow(QMainWindow):
 
         confirm_amount = self.config.get('confirm_amount', 100000000)
         if amount >= confirm_amount:
-            o = '\n'.join(map(lambda x:x[0], outputs))
+            o = '\n'.join(map(lambda x:x[1], outputs))
             if not self.question(_("send %(amount)s to %(address)s?")%{ 'amount' : self.format_amount(amount) + ' '+ self.base_unit(), 'address' : o}):
                 return
             
@@ -2136,12 +2136,12 @@ class ElectrumWindow(QMainWindow):
         try:
             for position, row in enumerate(csvReader):
                 address = row[0]
-                if not is_valid(address):
+                if not is_address(address):
                     errors.append((position, address))
                     continue
                 amount = Decimal(row[1])
                 amount = int(100000000*amount)
-                outputs.append((address, amount))
+                outputs.append(('address', address, amount))
         except (ValueError, IOError, os.error), reason:
             QMessageBox.critical(None, _("Unable to read file or no transaction found"), _("Electrum was unable to open your transaction file") + "\n" + str(reason))
             return