make all methods from all wallets async.

This commit is contained in:
fiatjaf
2021-03-24 01:01:09 -03:00
parent 42bd5ea989
commit d4d069fc77
15 changed files with 219 additions and 187 deletions
+13 -7
View File
@@ -1,5 +1,5 @@
from abc import ABC, abstractmethod
from typing import NamedTuple, Optional, AsyncGenerator
from typing import NamedTuple, Optional, AsyncGenerator, Coroutine
class StatusResponse(NamedTuple):
@@ -15,7 +15,9 @@ class InvoiceResponse(NamedTuple):
class PaymentResponse(NamedTuple):
ok: bool
ok: Optional[
bool
] = None # when ok is None it means we don't know if this succeeded
checking_id: Optional[str] = None # payment_hash, rcp_id
fee_msat: int = 0
preimage: Optional[str] = None
@@ -32,7 +34,7 @@ class PaymentStatus(NamedTuple):
class Wallet(ABC):
@abstractmethod
def status(self) -> StatusResponse:
def status(self) -> Coroutine[None, None, StatusResponse]:
pass
@abstractmethod
@@ -41,19 +43,23 @@ class Wallet(ABC):
amount: int,
memo: Optional[str] = None,
description_hash: Optional[bytes] = None,
) -> InvoiceResponse:
) -> Coroutine[None, None, InvoiceResponse]:
pass
@abstractmethod
def pay_invoice(self, bolt11: str) -> PaymentResponse:
def pay_invoice(self, bolt11: str) -> Coroutine[None, None, PaymentResponse]:
pass
@abstractmethod
def get_invoice_status(self, checking_id: str) -> PaymentStatus:
def get_invoice_status(
self, checking_id: str
) -> Coroutine[None, None, PaymentStatus]:
pass
@abstractmethod
def get_payment_status(self, checking_id: str) -> PaymentStatus:
def get_payment_status(
self, checking_id: str
) -> Coroutine[None, None, PaymentStatus]:
pass
@abstractmethod