store output type explicitly in tuple
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -69,13 +69,15 @@ class PayToEdit(QRTextEdit):
|
||||
def parse_address_and_amount(self, line):
|
||||
m = re.match('^OP_RETURN\s+"(.+)"$', line.strip())
|
||||
if m:
|
||||
address = 'OP_RETURN:' + m.group(1)
|
||||
type = 'op_return'
|
||||
address = m.group(1)
|
||||
amount = 0
|
||||
else:
|
||||
x, y = line.split(',')
|
||||
type = 'address'
|
||||
address = self.parse_address(x)
|
||||
amount = self.parse_amount(y)
|
||||
return address, amount
|
||||
return type, address, amount
|
||||
|
||||
|
||||
def parse_amount(self, x):
|
||||
@@ -114,11 +116,11 @@ class PayToEdit(QRTextEdit):
|
||||
|
||||
for line in lines:
|
||||
try:
|
||||
to_address, amount = self.parse_address_and_amount(line)
|
||||
type, to_address, amount = self.parse_address_and_amount(line)
|
||||
except:
|
||||
continue
|
||||
|
||||
outputs.append((to_address, amount))
|
||||
outputs.append((type, to_address, amount))
|
||||
total += amount
|
||||
|
||||
self.outputs = outputs
|
||||
@@ -144,7 +146,7 @@ class PayToEdit(QRTextEdit):
|
||||
except:
|
||||
amount = None
|
||||
|
||||
self.outputs = [(self.payto_address, amount)]
|
||||
self.outputs = [('address', self.payto_address, amount)]
|
||||
|
||||
return self.outputs[:]
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ class TxDialog(QDialog):
|
||||
vbox.addWidget(i_text)
|
||||
|
||||
vbox.addWidget(QLabel(_("Outputs")))
|
||||
lines = map(lambda x: x[0] + u'\t\t' + self.parent.format_amount(x[1]), self.tx.outputs)
|
||||
lines = map(lambda x: x[0] + u'\t\t' + self.parent.format_amount(x[1]), self.tx.get_outputs())
|
||||
o_text = QTextEdit()
|
||||
o_text.setText('\n'.join(lines))
|
||||
o_text.setReadOnly(True)
|
||||
|
||||
Reference in New Issue
Block a user