async def lnpay(self, invoice, timeout=120, password=None, wallet: Abstract_Wallet = None):
        """
        Pay a lightning invoice

        arg:str:invoice:Lightning invoice (bolt 11)
        arg:int:timeout:Timeout in seconds (default=20)
        """
        lnworker = wallet.lnworker
        lnaddr = lnworker._check_bolt11_invoice(invoice)
        payment_hash = lnaddr.paymenthash
        invoice_obj = Invoice.from_bech32(invoice)
        wallet.save_invoice(invoice_obj)
        success, log = await lnworker.pay_invoice(invoice_obj)
        return {
            'payment_hash': payment_hash.hex(),
            'success': success,
            'preimage': lnworker.get_preimage(payment_hash).hex() if success else None,
            'log': [x.formatted_tuple() for x in log]
        }

        Pay a lightning invoice

        arg:str:invoice:Lightning invoice (bolt 11)
        arg:int:timeout:Timeout in seconds (default=20)
        
electrum/commands.py