Browse Source

disallow adding receive requests without valid is_mine addresses

3.2.x
SomberNight 7 years ago
parent
commit
8e79d09511
  1. 17
      gui/kivy/uix/screens.py
  2. 5
      lib/wallet.py

17
gui/kivy/uix/screens.py

@ -371,13 +371,20 @@ class ReceiveScreen(CScreen):
def save_request(self):
addr = self.screen.address
if not addr:
return
return False
amount = self.screen.amount
message = self.screen.message
amount = self.app.get_amount(amount) if amount else 0
req = self.app.wallet.make_payment_request(addr, amount, message, None)
self.app.wallet.add_payment_request(req, self.app.electrum_config)
self.app.update_tab('requests')
try:
self.app.wallet.add_payment_request(req, self.app.electrum_config)
added_request = True
except Exception as e:
self.app.show_error(_('Error adding payment request') + ':\n' + str(e))
added_request = False
finally:
self.app.update_tab('requests')
return added_request
def on_amount_or_message(self):
self.save_request()
@ -389,8 +396,8 @@ class ReceiveScreen(CScreen):
self.app.show_info(_('Please use the existing requests first.'))
def do_save(self):
self.save_request()
self.app.show_info(_('Request was saved.'))
if self.save_request():
self.app.show_info(_('Request was saved.'))
class TabbedCarousel(Factory.TabbedPanel):

5
lib/wallet.py

@ -1588,6 +1588,11 @@ class Abstract_Wallet(PrintError):
def add_payment_request(self, req, config):
addr = req['address']
if not bitcoin.is_address(addr):
raise Exception(_('Invalid Bitcoin address.'))
if not self.is_mine(addr):
raise Exception(_('Address not in wallet.'))
amount = req.get('amount')
message = req.get('memo')
self.receive_requests[addr] = req

Loading…
Cancel
Save