diff --git a/lnbits/wallets/clightning.py b/lnbits/wallets/clightning.py index bb9543896..8f21f3c88 100644 --- a/lnbits/wallets/clightning.py +++ b/lnbits/wallets/clightning.py @@ -8,6 +8,7 @@ import random from functools import partial, wraps from os import getenv from typing import AsyncGenerator, Optional +import time from .base import ( InvoiceResponse, @@ -30,6 +31,10 @@ def async_wrap(func): return run +def _pay_invoice(ln, bolt11): + return ln.pay(bolt11) + + def _paid_invoices_stream(ln, last_pay_index): return ln.waitanyinvoice(last_pay_index) @@ -99,7 +104,8 @@ class CLightningWallet(Wallet): async def pay_invoice(self, bolt11: str) -> PaymentResponse: try: - r = self.ln.pay(bolt11) + wrapped = async_wrap(_pay_invoice) + r = await wrapped(self.ln, bolt11) except RpcError as exc: return PaymentResponse(False, None, 0, None, str(exc)) @@ -133,4 +139,4 @@ class CLightningWallet(Wallet): wrapped = async_wrap(_paid_invoices_stream) paid = await wrapped(self.ln, self.last_pay_index) self.last_pay_index = paid["pay_index"] - yield paid["label"] + yield paid["label"] \ No newline at end of file