From 2ffd419e66ac4d2cedae1dd5e91d11203101f4ec Mon Sep 17 00:00:00 2001 From: ThomasV Date: Wed, 19 Aug 2015 09:12:46 +0200 Subject: [PATCH] possibly fix #1403 --- gui/qt/paytoedit.py | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/gui/qt/paytoedit.py b/gui/qt/paytoedit.py index c7f1214a3..ded2b950f 100644 --- a/gui/qt/paytoedit.py +++ b/gui/qt/paytoedit.py @@ -75,39 +75,34 @@ class PayToEdit(ScanQRTextEdit): x, y = line.split(',') n = re.match('^SCRIPT\s+([0-9a-fA-F]+)$', x.strip()) if n: - _type = 'script' - address = n.group(1).decode('hex') + script = str(n.group(1)).decode('hex') amount = self.parse_amount(y) + return 'script', script, amount else: - _type = 'address' address = self.parse_address(x) amount = self.parse_amount(y) - return _type, address, amount - + return 'address', address, amount def parse_amount(self, x): p = pow(10, self.amount_edit.decimal_point()) - return int( p * Decimal(x.strip())) - + return int(p * Decimal(x.strip())) def parse_address(self, line): r = line.strip() m = re.match('^'+RE_ALIAS+'$', r) - address = m.group(2) if m else r + address = str(m.group(2)) if m else r assert bitcoin.is_address(address) return address - def check_text(self): self.errors = [] if self.is_pr: return # filter out empty lines - lines = filter( lambda x: x, self.lines()) + lines = filter(lambda x: x, self.lines()) outputs = [] total = 0 self.payto_address = None - if len(lines) == 1: data = lines[0] if data.startswith("bitcoin:"): @@ -123,12 +118,12 @@ class PayToEdit(ScanQRTextEdit): for i, line in enumerate(lines): try: - type, to_address, amount = self.parse_address_and_amount(line) + _type, to_address, amount = self.parse_address_and_amount(line) except: self.errors.append((i, line.strip())) continue - outputs.append((type, to_address, amount)) + outputs.append((_type, to_address, amount)) total += amount self.outputs = outputs @@ -158,11 +153,9 @@ class PayToEdit(ScanQRTextEdit): return self.outputs[:] - def lines(self): return unicode(self.toPlainText()).split('\n') - def is_multiline(self): return len(self.lines()) > 1