mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-10 12:32:34 +02:00
show unpaid invoices, balance calculated on server-side so isn't affected.
This commit is contained in:
@@ -14,7 +14,9 @@ function generateChart(canvas, payments) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_.each(
|
_.each(
|
||||||
payments.slice(0).sort(function (a, b) {
|
payments
|
||||||
|
.filter(p => !p.pending)
|
||||||
|
.sort(function (a, b) {
|
||||||
return a.time - b.time
|
return a.time - b.time
|
||||||
}),
|
}),
|
||||||
function (tx) {
|
function (tx) {
|
||||||
@@ -184,14 +186,7 @@ new Vue({
|
|||||||
return LNbits.utils.search(this.payments, q)
|
return LNbits.utils.search(this.payments, q)
|
||||||
},
|
},
|
||||||
balance: function () {
|
balance: function () {
|
||||||
if (this.payments.length) {
|
return this.apiBalance || this.g.wallet.sat
|
||||||
return (
|
|
||||||
_.pluck(this.payments, 'amount').reduce(function (a, b) {
|
|
||||||
return a + b
|
|
||||||
}, 0) / 1000
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return this.g.wallet.sat
|
|
||||||
},
|
},
|
||||||
fbalance: function () {
|
fbalance: function () {
|
||||||
return LNbits.utils.formatSat(this.balance)
|
return LNbits.utils.formatSat(this.balance)
|
||||||
@@ -404,7 +399,15 @@ new Vue({
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
payments: function () {
|
payments: function () {
|
||||||
EventHub.$emit('update-wallet-balance', [this.g.wallet.id, this.balance])
|
var self = this
|
||||||
|
|
||||||
|
LNbits.api.getWallet(self.g.wallet).then(function (response) {
|
||||||
|
self.apiBalance = Math.round(response.data.balance / 1000)
|
||||||
|
EventHub.$emit('update-wallet-balance', [
|
||||||
|
self.g.wallet.id,
|
||||||
|
self.balance
|
||||||
|
])
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function () {
|
created: function () {
|
||||||
|
@@ -4,6 +4,32 @@
|
|||||||
label="API info"
|
label="API info"
|
||||||
:content-inset-level="0.5"
|
:content-inset-level="0.5"
|
||||||
>
|
>
|
||||||
|
<q-expansion-item
|
||||||
|
group="api"
|
||||||
|
dense
|
||||||
|
expand-separator
|
||||||
|
label="Get wallet details"
|
||||||
|
>
|
||||||
|
<q-card>
|
||||||
|
<q-card-section>
|
||||||
|
<code><span class="text-light-green">GET</span> /api/v1/wallet</code>
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">Headers</h5>
|
||||||
|
<code>{"X-Api-Key": "<i>{{ wallet.adminkey }}</i>"}</code><br />
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">
|
||||||
|
Returns 200 OK (application/json)
|
||||||
|
</h5>
|
||||||
|
<code
|
||||||
|
>{"id": <string>, "name": <string>, "balance":
|
||||||
|
<int>}</code
|
||||||
|
>
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||||
|
<code
|
||||||
|
>curl {{ request.url_root }}api/v1/wallet -H "X-Api-Key:
|
||||||
|
<i>{{ wallet.inkey }}</i>"</code
|
||||||
|
>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
</q-expansion-item>
|
||||||
<q-expansion-item
|
<q-expansion-item
|
||||||
group="api"
|
group="api"
|
||||||
dense
|
dense
|
||||||
|
@@ -127,10 +127,10 @@
|
|||||||
class="q-pa-lg q-pt-xl lnbits__dialog-card"
|
class="q-pa-lg q-pt-xl lnbits__dialog-card"
|
||||||
>
|
>
|
||||||
<div class="text-center q-mb-lg">
|
<div class="text-center q-mb-lg">
|
||||||
<a :href="'lightning:' + receive.paymentReq">
|
<a :href="'lightning:' + props.row.bolt11">
|
||||||
<q-responsive :ratio="1" class="q-mx-xl">
|
<q-responsive :ratio="1" class="q-mx-xl">
|
||||||
<qrcode
|
<qrcode
|
||||||
:value="receive.paymentReq"
|
:value="props.row.bolt11"
|
||||||
:options="{width: 340}"
|
:options="{width: 340}"
|
||||||
class="rounded-borders"
|
class="rounded-borders"
|
||||||
></qrcode>
|
></qrcode>
|
||||||
@@ -141,7 +141,7 @@
|
|||||||
<q-btn
|
<q-btn
|
||||||
outline
|
outline
|
||||||
color="grey"
|
color="grey"
|
||||||
@click="copyText(receive.paymentReq)"
|
@click="copyText(props.row.bolt11)"
|
||||||
>Copy invoice</q-btn
|
>Copy invoice</q-btn
|
||||||
>
|
>
|
||||||
<q-btn v-close-popup flat color="grey" class="q-ml-auto"
|
<q-btn v-close-popup flat color="grey" class="q-ml-auto"
|
||||||
@@ -172,7 +172,7 @@
|
|||||||
Outgoing payment pending
|
Outgoing payment pending
|
||||||
</div>
|
</div>
|
||||||
<q-tooltip>Payment Hash</q-tooltip>
|
<q-tooltip>Payment Hash</q-tooltip>
|
||||||
<div class="text-wrap mono q-pa-md">
|
<div class="text-wrap mono q-pt-sm text-body1">
|
||||||
{{ props.row.payment_hash }}
|
{{ props.row.payment_hash }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -10,6 +10,21 @@ from lnbits.decorators import api_check_wallet_key, api_validate_post_request
|
|||||||
from lnbits.settings import WALLET
|
from lnbits.settings import WALLET
|
||||||
|
|
||||||
|
|
||||||
|
@core_app.route("/api/v1/wallet", methods=["GET"])
|
||||||
|
@api_check_wallet_key("invoice")
|
||||||
|
async def api_wallet():
|
||||||
|
return (
|
||||||
|
jsonify(
|
||||||
|
{
|
||||||
|
"id": g.wallet.id,
|
||||||
|
"name": g.wallet.name,
|
||||||
|
"balance": g.wallet.balance_msat,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
HTTPStatus.OK,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@core_app.route("/api/v1/payments", methods=["GET"])
|
@core_app.route("/api/v1/payments", methods=["GET"])
|
||||||
@api_check_wallet_key("invoice")
|
@api_check_wallet_key("invoice")
|
||||||
async def api_payments():
|
async def api_payments():
|
||||||
@@ -22,7 +37,7 @@ async def api_payments():
|
|||||||
else:
|
else:
|
||||||
payment.set_pending(WALLET.get_invoice_status(payment.checking_id).pending)
|
payment.set_pending(WALLET.get_invoice_status(payment.checking_id).pending)
|
||||||
|
|
||||||
return jsonify(g.wallet.get_payments()), HTTPStatus.OK
|
return jsonify(g.wallet.get_payments(pending=True)), HTTPStatus.OK
|
||||||
|
|
||||||
|
|
||||||
@api_check_wallet_key("invoice")
|
@api_check_wallet_key("invoice")
|
||||||
|
@@ -29,6 +29,9 @@ var LNbits = {
|
|||||||
bolt11: bolt11
|
bolt11: bolt11
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
getWallet: function (wallet) {
|
||||||
|
return this.request('get', '/api/v1/wallet', wallet.inkey)
|
||||||
|
},
|
||||||
getPayments: function (wallet, checkPending) {
|
getPayments: function (wallet, checkPending) {
|
||||||
var query_param = checkPending ? '?check_pending' : ''
|
var query_param = checkPending ? '?check_pending' : ''
|
||||||
return this.request(
|
return this.request(
|
||||||
|
@@ -101,3 +101,8 @@ video {
|
|||||||
-moz-font-feature-settings: 'liga';
|
-moz-font-feature-settings: 'liga';
|
||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// text-wrap
|
||||||
|
.text-wrap {
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user