Merge branch 'dabura667-fixmultiline'

This commit is contained in:
ThomasV 2014-09-06 15:06:55 +02:00
commit f1e55a5b16
2 changed files with 11 additions and 2 deletions

View File

@ -1034,6 +1034,10 @@ class ElectrumWindow(QMainWindow):
if self.payment_request:
outputs = self.payment_request.get_outputs()
else:
errors = self.payto_e.get_errors()
if errors:
self.show_warning(_("Invalid Lines found:") + "\n\n" + '\n'.join([ _("Line #") + str(x[0]+1) + ": " + x[1] for x in errors]))
return
outputs = self.payto_e.get_outputs()
if not outputs:

View File

@ -42,6 +42,7 @@ class PayToEdit(QRTextEdit):
self.c = None
self.textChanged.connect(self.check_text)
self.outputs = []
self.errors = []
self.is_pr = False
self.scan_f = self.win.pay_from_URI
self.update_size()
@ -94,6 +95,7 @@ class PayToEdit(QRTextEdit):
def check_text(self):
self.errors = []
if self.is_pr:
return
@ -114,10 +116,11 @@ class PayToEdit(QRTextEdit):
self.unlock_amount()
return
for line in lines:
for i, line in enumerate(lines):
try:
type, to_address, amount = self.parse_address_and_amount(line)
except:
self.errors.append((i, line.strip()))
continue
outputs.append((type, to_address, amount))
@ -139,13 +142,15 @@ class PayToEdit(QRTextEdit):
self.unlock_amount()
def get_errors(self):
return self.errors
def get_outputs(self):
if self.payto_address:
try:
amount = self.amount_edit.get_amount()
except:
amount = None
self.outputs = [('address', self.payto_address, amount)]
return self.outputs[:]