CSV: Show erroneous addresses in warning window.
authordabura667 <matsuringo667@gmail.com>
Mon, 24 Feb 2014 12:22:13 +0000 (21:22 +0900)
committerdabura667 <matsuringo667@gmail.com>
Mon, 24 Feb 2014 12:22:13 +0000 (21:22 +0900)
This will show all erroneous addresses given in a CSV import to the user
before returning out of the function.

gui/qt/main_window.py

index 97dfbac..97927cb 100644 (file)
@@ -1889,15 +1889,25 @@ class ElectrumWindow(QMainWindow):
 
     def do_process_from_csvReader(self, csvReader):
         outputs = []
+        errors = []
+        errtext = ""
         try:
-            for row in csvReader:
+            for position, row in enumerate(csvReader):
                 address = row[0]
+                if not is_valid(address):
+                    errors.append((position, address))
+                    continue
                 amount = Decimal(row[1])
                 amount = int(100000000*amount)
                 outputs.append((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
+        if errors != []:
+            for x in errors:
+                errtext += "CSV Row " + str(x[0]+1) + ": " + x[1] + "\n"
+            QMessageBox.critical(None, _("Invalid Addresses"), _("ABORTING! Invalid Addresses found:") + "\n\n" + errtext)
+            return
 
         try:
             tx = self.wallet.make_unsigned_transaction(outputs, None, None)