Exemple #1
0
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)
Exemple #2
0
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
Exemple #3
0
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)
Exemple #4
0
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
Exemple #5
0
def checkout_invoice(invoice_id):
    invoice = Invoice.get_by_id(invoice_id)
    if invoice is None:
        abort(404)
    return render_template("checkout", invoice)
Exemple #6
0
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)
Exemple #7
0
def create_invoice():
    invoice = Invoice(msatoshi=request.POST.get("msatoshi"),
                      expires_at=datetime.now())
    invoice.save()
    return invoice_schema.jsonify(invoice)
Exemple #8
0
def get_invoice(invoice_id):
    invoice = Invoice.get_by_id(invoice_id)
    if invoice is None:
        abort(404)
    return invoice_schema.jsonify(invoice)