@log_exceptions
async def pay_invoice(self, invoice: str, *, amount_msat: int=None, attempts: int=1, full_path: LNPaymentPath=None) -> Tuple[(bool, List[HtlcLog])]:
    lnaddr = self._check_invoice(invoice, amount_msat=amount_msat)
    min_cltv_expiry = lnaddr.get_min_final_cltv_expiry()
    payment_hash = lnaddr.paymenthash
    key = payment_hash.hex()
    payment_secret = lnaddr.payment_secret
    invoice_pubkey = lnaddr.pubkey.serialize()
    invoice_features = lnaddr.get_features()
    r_tags = lnaddr.get_routing_info('r')
    amount_to_pay = lnaddr.get_amount_msat()
    status = self.get_payment_status(payment_hash)
    if (status == PR_PAID):
        raise PaymentFailure(_('This invoice has been paid already'))
    if (status == PR_INFLIGHT):
        raise PaymentFailure(_('A payment was already initiated for this invoice'))
    if (payment_hash in self.get_payments(status='inflight')):
        raise PaymentFailure(_('A previous attempt to pay this invoice did not clear'))
    info = PaymentInfo(payment_hash, amount_to_pay, SENT, PR_UNPAID)
    self.save_payment_info(info)
    self.wallet.set_label(key, lnaddr.get_description())
    self.set_invoice_status(key, PR_INFLIGHT)
    try:
        (await self.pay_to_node(node_pubkey=invoice_pubkey, payment_hash=payment_hash, payment_secret=payment_secret, amount_to_pay=amount_to_pay, min_cltv_expiry=min_cltv_expiry, r_tags=r_tags, invoice_features=invoice_features, attempts=attempts, full_path=full_path))
        success = True
    except PaymentFailure as e:
        self.logger.info(f'payment failure: {e!r}')
        success = False
        reason = str(e)
    if success:
        self.set_invoice_status(key, PR_PAID)
        util.trigger_callback('payment_succeeded', self.wallet, key)
    else:
        self.set_invoice_status(key, PR_UNPAID)
        util.trigger_callback('payment_failed', self.wallet, key, reason)
    log = self.logs[key]
    return (success, log)
@log_exceptions
async def pay_invoice(self, invoice: str, *, amount_msat: int=None, attempts: int=1, full_path: LNPaymentPath=None) -> Tuple[(bool, List[HtlcLog])]:
    lnaddr = self._check_invoice(invoice, amount_msat=amount_msat)
    min_cltv_expiry = lnaddr.get_min_final_cltv_expiry()
    payment_hash = lnaddr.paymenthash
    key = payment_hash.hex()
    payment_secret = lnaddr.payment_secret
    invoice_pubkey = lnaddr.pubkey.serialize()
    invoice_features = lnaddr.get_features()
    r_tags = lnaddr.get_routing_info('r')
    amount_to_pay = lnaddr.get_amount_msat()
    status = self.get_payment_status(payment_hash)
    if (status == PR_PAID):
        raise PaymentFailure(_('This invoice has been paid already'))
    if (status == PR_INFLIGHT):
        raise PaymentFailure(_('A payment was already initiated for this invoice'))
    if (payment_hash in self.get_payments(status='inflight')):
        raise PaymentFailure(_('A previous attempt to pay this invoice did not clear'))
    info = PaymentInfo(payment_hash, amount_to_pay, SENT, PR_UNPAID)
    self.save_payment_info(info)
    self.wallet.set_label(key, lnaddr.get_description())
    self.set_invoice_status(key, PR_INFLIGHT)
    try:
        (await self.pay_to_node(node_pubkey=invoice_pubkey, payment_hash=payment_hash, payment_secret=payment_secret, amount_to_pay=amount_to_pay, min_cltv_expiry=min_cltv_expiry, r_tags=r_tags, invoice_features=invoice_features, attempts=attempts, full_path=full_path))
        success = True
    except PaymentFailure as e:
        self.logger.info(f'payment failure: {e!r}')
        success = False
        reason = str(e)
    if success:
        self.set_invoice_status(key, PR_PAID)
        util.trigger_callback('payment_succeeded', self.wallet, key)
    else:
        self.set_invoice_status(key, PR_UNPAID)
        util.trigger_callback('payment_failed', self.wallet, key, reason)
    log = self.logs[key]
    return (success, log)