mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-01 17:55:20 +00:00
fix: sanitize outputs
This commit is contained in:
parent
0673df9176
commit
38a6747eff
4 changed files with 23 additions and 23 deletions
|
@ -797,10 +797,22 @@ class ElectrumWindow(QMainWindow):
|
||||||
|
|
||||||
if self.gui_object.payment_request:
|
if self.gui_object.payment_request:
|
||||||
outputs = self.gui_object.payment_request.outputs
|
outputs = self.gui_object.payment_request.outputs
|
||||||
amount = self.gui_object.payment_request.get_amount()
|
|
||||||
else:
|
else:
|
||||||
outputs = self.payto_e.get_outputs()
|
outputs = self.payto_e.get_outputs()
|
||||||
amount = sum(map(lambda x:x[1], outputs))
|
|
||||||
|
if not outputs:
|
||||||
|
QMessageBox.warning(self, _('Error'), _('No outputs'), _('OK'))
|
||||||
|
return
|
||||||
|
|
||||||
|
for addr, x in outputs:
|
||||||
|
if addr is None or not bitcoin.is_address(addr):
|
||||||
|
QMessageBox.warning(self, _('Error'), _('Invalid Bitcoin Address'), _('OK'))
|
||||||
|
return
|
||||||
|
if type(x) is not int:
|
||||||
|
QMessageBox.warning(self, _('Error'), _('Invalid Amount'), _('OK'))
|
||||||
|
return
|
||||||
|
|
||||||
|
amount = sum(map(lambda x:x[1], outputs))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
fee = self.fee_e.get_amount()
|
fee = self.fee_e.get_amount()
|
||||||
|
|
|
@ -41,6 +41,7 @@ class PayToEdit(QTextEdit):
|
||||||
self.setMaximumHeight(27)
|
self.setMaximumHeight(27)
|
||||||
self.c = None
|
self.c = None
|
||||||
self.textChanged.connect(self.check_text)
|
self.textChanged.connect(self.check_text)
|
||||||
|
self.outputs = []
|
||||||
|
|
||||||
def lock_amount(self):
|
def lock_amount(self):
|
||||||
self.amount_edit.setFrozen(True)
|
self.amount_edit.setFrozen(True)
|
||||||
|
@ -88,8 +89,15 @@ class PayToEdit(QTextEdit):
|
||||||
self.payto_address = self.parse_address(lines[0])
|
self.payto_address = self.parse_address(lines[0])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if self.payto_address:
|
if self.payto_address:
|
||||||
self.unlock_amount()
|
self.unlock_amount()
|
||||||
|
try:
|
||||||
|
amount = self.amount_edit.get_amount()
|
||||||
|
except:
|
||||||
|
amount = None
|
||||||
|
|
||||||
|
self.outputs = [(self.payto_address, amount)]
|
||||||
return
|
return
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
@ -115,24 +123,7 @@ class PayToEdit(QTextEdit):
|
||||||
self.unlock_amount()
|
self.unlock_amount()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_outputs(self):
|
def get_outputs(self):
|
||||||
|
|
||||||
if self.payto_address:
|
|
||||||
|
|
||||||
if not bitcoin.is_address(self.payto_address):
|
|
||||||
QMessageBox.warning(self, _('Error'), _('Invalid Bitcoin Address') + ':\n' + self.payto_address, _('OK'))
|
|
||||||
return
|
|
||||||
|
|
||||||
try:
|
|
||||||
amount = self.amount_edit.get_amount()
|
|
||||||
except Exception:
|
|
||||||
QMessageBox.warning(self, _('Error'), _('Invalid Amount'), _('OK'))
|
|
||||||
return
|
|
||||||
|
|
||||||
outputs = [(self.payto_address, amount)]
|
|
||||||
return outputs
|
|
||||||
|
|
||||||
return self.outputs
|
return self.outputs
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -57,9 +57,6 @@ class PaymentRequest:
|
||||||
self.outputs = []
|
self.outputs = []
|
||||||
self.error = ""
|
self.error = ""
|
||||||
|
|
||||||
def get_amount(self):
|
|
||||||
return sum(map(lambda x:x[1], self.outputs))
|
|
||||||
|
|
||||||
|
|
||||||
def verify(self):
|
def verify(self):
|
||||||
u = urlparse.urlparse(self.url)
|
u = urlparse.urlparse(self.url)
|
||||||
|
|
|
@ -118,7 +118,7 @@ class WalletStorage:
|
||||||
with self.lock:
|
with self.lock:
|
||||||
if value is not None:
|
if value is not None:
|
||||||
self.data[key] = value
|
self.data[key] = value
|
||||||
else:
|
elif key in self.data:
|
||||||
self.data.pop(key)
|
self.data.pop(key)
|
||||||
if save:
|
if save:
|
||||||
self.write()
|
self.write()
|
||||||
|
|
Loading…
Add table
Reference in a new issue