refactor: unify responses in backend wallets

This commit is contained in:
Eneko Illarramendi
2020-01-10 21:26:42 +01:00
parent 676fa29852
commit 47b93a97d6
8 changed files with 200 additions and 139 deletions
+32
View File
@@ -0,0 +1,32 @@
from abc import ABC, abstractmethod
from requests import Response
from typing import NamedTuple, Optional
class InvoiceResponse(NamedTuple):
raw_response: Response
payment_hash: Optional[str] = None
payment_request: Optional[str] = None
class TxStatus(NamedTuple):
raw_response: Response
settled: Optional[bool] = None
class Wallet(ABC):
@abstractmethod
def create_invoice(self, amount: int, memo: str = "") -> InvoiceResponse:
pass
@abstractmethod
def pay_invoice(self, bolt11: str) -> Response:
pass
@abstractmethod
def get_invoice_status(self, payment_hash: str, wait: bool = True) -> TxStatus:
pass
@abstractmethod
def get_payment_status(self, payment_hash: str) -> TxStatus:
pass