@@ -22,6 +22,8 @@ class ClicheWallet(Wallet):
|
||||
|
||||
def __init__(self):
|
||||
self.endpoint = settings.cliche_endpoint
|
||||
if not self.endpoint:
|
||||
raise Exception("cannot initialize cliche")
|
||||
|
||||
async def status(self) -> StatusResponse:
|
||||
try:
|
||||
@@ -36,7 +38,7 @@ class ClicheWallet(Wallet):
|
||||
data = json.loads(r)
|
||||
except:
|
||||
return StatusResponse(
|
||||
f"Failed to connect to {self.endpoint}, got: '{r.text[:200]}...'", 0
|
||||
f"Failed to connect to {self.endpoint}, got: '{r[:200]}...'", 0
|
||||
)
|
||||
|
||||
return StatusResponse(None, data["result"]["wallets"][0]["balance"])
|
||||
@@ -89,6 +91,13 @@ class ClicheWallet(Wallet):
|
||||
async def pay_invoice(self, bolt11: str, fee_limit_msat: int) -> PaymentResponse:
|
||||
ws = create_connection(self.endpoint)
|
||||
ws.send(f"pay-invoice --invoice {bolt11}")
|
||||
checking_id, fee_msat, preimage, error_message, payment_ok = (
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
for _ in range(2):
|
||||
r = ws.recv()
|
||||
data = json.loads(r)
|
||||
@@ -151,9 +160,9 @@ class ClicheWallet(Wallet):
|
||||
async def paid_invoices_stream(self) -> AsyncGenerator[str, None]:
|
||||
while True:
|
||||
try:
|
||||
ws = await create_connection(self.endpoint)
|
||||
ws = create_connection(self.endpoint)
|
||||
while True:
|
||||
r = await ws.recv()
|
||||
r = ws.recv()
|
||||
data = json.loads(r)
|
||||
print(data)
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user