Esempio n. 1
0
def lndhub_gettxs():
    for payment in g.wallet.get_payments(complete=False,
                                         pending=True,
                                         outgoing=True,
                                         incoming=False,
                                         exclude_uncheckable=True):
        payment.set_pending(
            WALLET.get_payment_status(payment.checking_id).pending)

    limit = int(request.args.get("limit", 200))
    return jsonify([{
        "payment_preimage":
        payment.preimage,
        "payment_hash":
        payment.payment_hash,
        "fee_msat":
        payment.fee * 1000,
        "type":
        "paid_invoice",
        "fee":
        payment.fee,
        "value":
        int(payment.amount / 1000),
        "timestamp":
        payment.time,
        "memo":
        payment.memo if not payment.pending else "Payment in transition",
    } for payment in reversed(
        g.wallet.get_payments(
            pending=True, complete=True, outgoing=True, incoming=False)
        [:limit])])
Esempio n. 2
0
async def api_payment(payment_hash):
    payment = g.wallet.get_payment(payment_hash)

    if not payment:
        return jsonify({"message":
                        "Payment does not exist."}), HTTPStatus.NOT_FOUND
    elif not payment.pending:
        return jsonify({"paid": True}), HTTPStatus.OK

    try:
        if payment.is_uncheckable:
            pass
        elif payment.is_out:
            is_paid = not WALLET.get_payment_status(
                payment.checking_id).pending
        elif payment.is_in:
            is_paid = not WALLET.get_invoice_status(
                payment.checking_id).pending
    except Exception:
        return jsonify({"paid": False}), HTTPStatus.OK

    if is_paid:
        payment.set_pending(False)
        return jsonify({"paid": True}), HTTPStatus.OK

    return jsonify({"paid": False}), HTTPStatus.OK
Esempio n. 3
0
    def check_pending(self) -> None:
        if self.is_uncheckable:
            return

        if self.is_out:
            pending = WALLET.get_payment_status(self.checking_id)
        else:
            pending = WALLET.get_invoice_status(self.checking_id)

        self.set_pending(pending.pending)
Esempio n. 4
0
def api_payments():
    if "check_pending" in request.args:
        g.wallet.delete_expired_payments()

        for payment in g.wallet.get_payments(include_all_pending=True):
            if payment.is_out:
                payment.set_pending(WALLET.get_payment_status(payment.checking_id).pending)
            else:
                payment.set_pending(WALLET.get_invoice_status(payment.checking_id).pending)

    return jsonify(g.wallet.get_payments()), Status.OK
Esempio n. 5
0
async def api_payments():
    if "check_pending" in request.args:
        delete_expired_invoices()

        for payment in g.wallet.get_payments(complete=False,
                                             pending=True,
                                             exclude_uncheckable=True):
            if payment.is_out:
                payment.set_pending(
                    WALLET.get_payment_status(payment.checking_id).pending)
            else:
                payment.set_pending(
                    WALLET.get_invoice_status(payment.checking_id).pending)

    return jsonify(g.wallet.get_payments(pending=True)), HTTPStatus.OK