chore: remove wait option for LntxbotWallet

This commit is contained in:
Eneko Illarramendi 2020-03-05 23:01:16 +01:00
parent 9382381144
commit 7996c48b70
4 changed files with 7 additions and 9 deletions

View file

@ -30,7 +30,7 @@ class Wallet(ABC):
pass pass
@abstractmethod @abstractmethod
def get_invoice_status(self, payment_hash: str, wait: bool = True) -> TxStatus: def get_invoice_status(self, payment_hash: str) -> TxStatus:
pass pass
@abstractmethod @abstractmethod

View file

@ -41,8 +41,8 @@ class LndWallet(Wallet):
) )
return PaymentResponse(r, not r.ok) return PaymentResponse(r, not r.ok)
def get_invoice_status(self, payment_hash: str, wait: bool = True) -> TxStatus: def get_invoice_status(self, payment_hash: str) -> TxStatus:
r = get(url=f"{self.endpoint}/v1/invoice/{payment_hash}", headers=self.auth_read, verify=False,) r = get(url=f"{self.endpoint}/v1/invoice/{payment_hash}", headers=self.auth_read, verify=False)
if not r.ok or "settled" not in r.json(): if not r.ok or "settled" not in r.json():
return TxStatus(r, None) return TxStatus(r, None)

View file

@ -44,7 +44,6 @@ class LNPayWallet(Wallet):
return TxStatus(r, None) return TxStatus(r, None)
statuses = {0: None, 1: True, -1: False} statuses = {0: None, 1: True, -1: False}
return TxStatus(r, statuses[r.json()["settled"]]) return TxStatus(r, statuses[r.json()["settled"]])
def get_payment_status(self, payment_hash: str) -> TxStatus: def get_payment_status(self, payment_hash: str) -> TxStatus:
@ -54,5 +53,4 @@ class LNPayWallet(Wallet):
return TxStatus(r, None) return TxStatus(r, None)
statuses = {0: None, 1: True, -1: False} statuses = {0: None, 1: True, -1: False}
return TxStatus(r, statuses[r.json()["settled"]]) return TxStatus(r, statuses[r.json()["settled"]])

View file

@ -34,9 +34,8 @@ class LntxbotWallet(Wallet):
return PaymentResponse(r, failed, fee_msat) return PaymentResponse(r, failed, fee_msat)
def get_invoice_status(self, payment_hash: str, wait: bool = True) -> TxStatus: def get_invoice_status(self, payment_hash: str) -> TxStatus:
wait = "true" if wait else "false" r = post(url=f"{self.endpoint}/invoicestatus/{payment_hash}?wait=false", headers=self.auth_invoice)
r = post(url=f"{self.endpoint}/invoicestatus/{payment_hash}?wait={wait}", headers=self.auth_invoice)
if not r.ok: if not r.ok:
return TxStatus(r, None) return TxStatus(r, None)
@ -57,4 +56,5 @@ class LntxbotWallet(Wallet):
if not r.ok or "error" in r.json(): if not r.ok or "error" in r.json():
return TxStatus(r, None) return TxStatus(r, None)
return TxStatus(r, {"complete": True, "failed": False, "unknown": None}[r.json().get("status", "unknown")]) statuses = {"complete": True, "failed": False, "unknown": None}
return TxStatus(r, statuses[r.json().get("status", "unknown")])