URI: 
       tfix paying bip70 payment request with Kivy GUI - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 96fa03c11bdc80c7a3313607ab4131fc387f343e
   DIR parent 1d0aa4042a74136e85929edbfe683432ef00591d
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Tue, 31 Dec 2019 03:37:50 +0100
       
       fix paying bip70 payment request with Kivy GUI
       
       Diffstat:
         M electrum/gui/kivy/main_window.py    |       5 +++--
         M electrum/gui/kivy/uix/screens.py    |      24 ++++++++++++++----------
       
       2 files changed, 17 insertions(+), 12 deletions(-)
       ---
   DIR diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py
       t@@ -82,6 +82,7 @@ if TYPE_CHECKING:
            from . import ElectrumGui
            from electrum.simple_config import SimpleConfig
            from electrum.plugin import Plugins
       +    from electrum.paymentrequest import PaymentRequest
        
        
        class ElectrumWindow(App):
       t@@ -364,13 +365,13 @@ class ElectrumWindow(App):
                self.fee_status = self.electrum_config.get_fee_status()
                self.request_popup = None
        
       -    def on_pr(self, pr):
       +    def on_pr(self, pr: 'PaymentRequest'):
                if not self.wallet:
                    self.show_error(_('No wallet loaded.'))
                    return
                if pr.verify(self.wallet.contacts):
                    key = pr.get_id()
       -            invoice = self.wallet.get_invoice(key)
       +            invoice = self.wallet.get_invoice(key)  # FIXME wrong key...
                    if invoice and invoice['status'] == PR_PAID:
                        self.show_error("invoice already paid")
                        self.send_screen.do_clear()
   DIR diff --git a/electrum/gui/kivy/uix/screens.py b/electrum/gui/kivy/uix/screens.py
       t@@ -4,7 +4,7 @@ from decimal import Decimal
        import re
        import threading
        import traceback, sys
       -from typing import TYPE_CHECKING, List
       +from typing import TYPE_CHECKING, List, Optional
        
        from kivy.app import App
        from kivy.cache import Cache
       t@@ -43,6 +43,7 @@ from electrum.gui.kivy.i18n import _
        
        if TYPE_CHECKING:
            from electrum.gui.kivy.main_window import ElectrumWindow
       +    from electrum.paymentrequest import PaymentRequest
        
        
        class HistoryRecycleView(RecycleView):
       t@@ -183,11 +184,11 @@ class HistoryScreen(CScreen):
        class SendScreen(CScreen):
        
            kvname = 'send'
       -    payment_request = None
       -    payment_request_queued = None
       +    payment_request = None  # type: Optional[PaymentRequest]
       +    payment_request_queued = None  # type: Optional[str]
            parsed_URI = None
        
       -    def set_URI(self, text):
       +    def set_URI(self, text: str):
                if not self.app.wallet:
                    self.payment_request_queued = text
                    return
       t@@ -263,7 +264,7 @@ class SendScreen(CScreen):
                self.screen.locked = False
                self.parsed_URI = None
        
       -    def set_request(self, pr):
       +    def set_request(self, pr: 'PaymentRequest'):
                self.screen.address = pr.get_requestor()
                amount = pr.get_amount()
                self.screen.amount = self.app.format_amount_and_units(amount) if amount else ''
       t@@ -308,11 +309,14 @@ class SendScreen(CScreen):
                message = self.screen.message
                if self.screen.is_lightning:
                    return self.app.wallet.lnworker.parse_bech32_invoice(address)
       -        else:
       -            if not bitcoin.is_address(address):
       -                self.app.show_error(_('Invalid Bitcoin Address') + ':\n' + address)
       -                return
       -            outputs = [PartialTxOutput.from_address_and_value(address, amount)]
       +        else:  # on-chain
       +            if self.payment_request:
       +                outputs = self.payment_request.get_outputs()
       +            else:
       +                if not bitcoin.is_address(address):
       +                    self.app.show_error(_('Invalid Bitcoin Address') + ':\n' + address)
       +                    return
       +                outputs = [PartialTxOutput.from_address_and_value(address, amount)]
                    return self.app.wallet.create_invoice(outputs, message, self.payment_request, self.parsed_URI)
        
            def do_save(self):