Browse Source

Update clightning.py

fee_issues
Arc 5 years ago
committed by GitHub
parent
commit
377b0c9d47
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      lnbits/wallets/clightning.py

13
lnbits/wallets/clightning.py

@ -7,28 +7,29 @@ import random
class CLightningWallet(Wallet):
def __init__(self):
l1 = LightningRpc(getenv("CLIGHTNING_RPC"))
self.l1 = LightningRpc(getenv("CLIGHTNING_RPC"))
def create_invoice(self, amount: int, memo: str = "") -> InvoiceResponse:
print(self.l1)
label = "lbl{}".format(random.random())
r = l1.invoice(amount*1000, label, memo, exposeprivatechannels=True)
r = self.l1.invoice(amount*1000, label, memo, exposeprivatechannels=True)
print(r)
ok, checking_id, payment_request, error_message = True, r["payment_hash"], r["bolt11"], None
return InvoiceResponse(ok, checking_id, payment_request, error_message)
def pay_invoice(self, bolt11: str) -> PaymentResponse:
r = l1.pay(bolt11)
r = self.l1.pay(bolt11)
ok, checking_id, fee_msat, error_message = True, None, None, None
return PaymentResponse(ok, checking_id, fee_msat, error_message)
def get_invoice_status(self, checking_id: str) -> PaymentStatus:
r = l1.listinvoices(checking_id)
r = self.l1.listinvoices(checking_id)
if r['invoices'][0]['status'] == 'unpaid':
return PaymentStatus(False)
return PaymentStatus(True)
def get_payment_status(self, checking_id: str) -> PaymentStatus:
r = l1.listsendpays(checking_id)
r = self.l1.listsendpays(checking_id)
if not r.ok:
return PaymentStatus(r, None)
payments = [p for p in r.json()["payments"] if p["payment_hash"] == payment_hash]

Loading…
Cancel
Save