URI: 
       tMerge pull request #4115 from SomberNight/disallow_adding_requests_w_invalid_addresses - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 800c783580ca2cff6d8ac380f66e04f059026355
   DIR parent 774b6ca30d6fe0d9726ed0aeccdd79b2eff52828
  HTML Author: ThomasV <thomasv@electrum.org>
       Date:   Thu, 22 Mar 2018 15:34:05 +0100
       
       Merge pull request #4115 from SomberNight/disallow_adding_requests_w_invalid_addresses
       
       disallow adding receive requests without valid is_mine addresses
       Diffstat:
         M gui/kivy/uix/screens.py             |      17 ++++++++++++-----
         M lib/wallet.py                       |       5 +++++
       
       2 files changed, 17 insertions(+), 5 deletions(-)
       ---
   DIR diff --git a/gui/kivy/uix/screens.py b/gui/kivy/uix/screens.py
       t@@ -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):
                Clock.schedule_once(lambda dt: self.update_qr())
       t@@ -388,8 +395,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):
   DIR diff --git a/lib/wallet.py b/lib/wallet.py
       t@@ -1590,6 +1590,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