From c5aa69a1f06e21fac4c9a1a2ad6c12da852b9c45 Mon Sep 17 00:00:00 2001 From: dabura667 Date: Mon, 24 Feb 2014 21:22:13 +0900 Subject: [PATCH 1/2] CSV: Show erroneous addresses in warning window. 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 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index 97dfbac8..97927cb2 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -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) From c49a97ef14379abaf91be2e252ccacab150e9090 Mon Sep 17 00:00:00 2001 From: dabura667 Date: Tue, 25 Feb 2014 02:49:51 +0900 Subject: [PATCH 2/2] Is_valid assert wasn't displaying anything. Fixed it with a message. --- lib/wallet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/wallet.py b/lib/wallet.py index b80ad9e1..bfb6b74b 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -1333,7 +1333,7 @@ class Wallet: def make_unsigned_transaction(self, outputs, fee=None, change_addr=None, domain=None ): for address, x in outputs: - assert is_valid(address) + assert is_valid(address), "Address " + address + " is invalid!" amount = sum( map(lambda x:x[1], outputs) ) inputs, total, fee = self.choose_tx_inputs( amount, fee, domain ) if not inputs: