def check_payment(self):
"""
Checks if the Lightning payment has been received for this invoice
"""
if self.status == 'pending_invoice':
return False
channel = grpc.insecure_channel(settings.LND_RPCHOST)
stub = lnrpc.LightningStub(channel)
r_hash_base64 = self.r_hash.encode('utf-8')
r_hash_bytes = str(codecs.decode(r_hash_base64, 'base64'))
invoice_resp = stub.LookupInvoice(ln.PaymentHash(r_hash=r_hash_bytes))
if invoice_resp.settled:
# Payment complete
self.status = 'complete'
self.save()
return True
else:
# Payment not received
return False
评论列表
文章目录