async def poll_lightning(ln, last_index): ln_invoice = ln.waitanyinvoice(last_index) if Invoice.mark_paid( ln_invoice.label, ln_invoice.pay_index, ln_invoice.paid_at, ln_invoice.msatoshi_received, ): invoice = Invoice.get(ln_invoice.label) payment_signal.send(invoice)
def invoice_qr(invoice_id): invoice = Invoice.get_by_id(invoice_id) if invoice is None: abort(404) qr = qrcode.make(f"lightning:{invoice.payreq}".uppercase()) response = make_response(qr) response.headers.set("Content-Type", "image/png") return response
def checkout_wait(invoice_id): """ like invoice_wait but no auth required, user accessible, hides private fields """ invoice = Invoice.get_by_id(invoice_id) if invoice is None: abort(404) if invoice.status == "paid": return invoice_schema.jsonify(invoice) if invoice.status == "expired": abort(410)
def invoice_webhook(invoice_id): invoice = Invoice.get_by_id(invoice_id) if invoice is None: abort(404) if invoice.status == "paid": abort(405) if invoice.status == "expired": abort(410) hook = InvoiceWebhook(invoice_id=invoice_id, url=request.POST.get("url")) hook.save() return "OK", 201
def checkout_invoice(invoice_id): invoice = Invoice.get_by_id(invoice_id) if invoice is None: abort(404) return render_template("checkout", invoice)
def invoice_wait(invoice_id): invoice = Invoice.get_by_id(invoice_id) if invoice.status == "paid": return invoice_schema.jsonify(invoice) if invoice.status == "expired": abort(410)
def create_invoice(): invoice = Invoice(msatoshi=request.POST.get("msatoshi"), expires_at=datetime.now()) invoice.save() return invoice_schema.jsonify(invoice)
def get_invoice(invoice_id): invoice = Invoice.get_by_id(invoice_id) if invoice is None: abort(404) return invoice_schema.jsonify(invoice)