Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes compatible with fakewallet #119

Merged
merged 10 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,9 @@ window.app = Vue.createApp({
.request('GET', '/api/v1/currencies')
.then(response => {
this.currencyOptions = ['sats', ...response.data]
if (LNBITS_DENOMINATION != 'sats') {
this.formDialog.data.currency = DENOMINATION
}
})
.catch(err => {
LNbits.utils.notifyApiError(err)
Expand Down
7 changes: 5 additions & 2 deletions static/js/tpos.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ window.app = Vue.createApp({
})
},
getRates() {
if (this.currency == 'sats') {
if (this.currency == LNBITS_DENOMINATION) {
this.exchangeRate = 1
Quasar.Loading.hide()
} else {
Expand Down Expand Up @@ -728,8 +728,11 @@ window.app = Vue.createApp({
}
},
formatAmount: function (amount, currency) {
if (LNBITS_DENOMINATION != 'sats') {
return LNbits.utils.formatCurrency(amount / 100, LNBITS_DENOMINATION)
}
if (currency == 'sats') {
return LNbits.utils.formatSat(amount) + ' sat'
return LNbits.utils.formatSat(amount) + ' sats'
} else {
return LNbits.utils.formatCurrency(Number(amount).toFixed(2), currency)
}
Expand Down
3 changes: 1 addition & 2 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import asyncio

from loguru import logger

from lnbits.core.models import Payment
from lnbits.core.services import create_invoice, pay_invoice, websocket_updater
from lnbits.tasks import register_invoice_listener
from loguru import logger

from .crud import get_tpos
from .helpers import get_pr
Expand Down
9 changes: 5 additions & 4 deletions templates/tpos/dialogs.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
<div class="text-center">
<h3 class="q-my-md">${ amountWithTipFormatted }</h3>
<h5 class="q-mt-none q-mb-sm">
${ fsat }
<small> sat </small>
${ amountFormatted }
<span v-show="tip_options" style="font-size: 0.75rem"
>(+ ${ tipAmountFormatted } tip)</span
>
Expand Down Expand Up @@ -151,9 +150,11 @@ <h5 class="q-mt-none q-mb-sm">
</q-item>
<q-item v-for="(payment, idx) in lastPaymentsDialog.data" :key="idx">
<q-item-section>
<q-item-label class="text-bold"
>${payment.amount / 1000} sats</q-item-label
<q-item-label
class="text-bold"
v-text="formatBalance(payment.amount / 1000)"
>
</q-item-label>
<q-item-label caption lines="2"
>Hash: ${payment.checking_id.slice(0, 30)}...</q-item-label
>
Expand Down
9 changes: 7 additions & 2 deletions templates/tpos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ <h6 class="text-subtitle1 q-my-none">{{SITE_TITLE}} TPoS extension</h6>
label="Wallet *"
></q-select>
<q-select
v-if="'{{LNBITS_DENOMINATION}}' == 'sats'"
filled
dense
emit-value
Expand Down Expand Up @@ -393,7 +394,7 @@ <h6 class="text-subtitle1 q-my-none">{{SITE_TITLE}} TPoS extension</h6>
dense
v-model.number="formDialog.data.withdraw_limit"
type="number"
label="Max amount to be sold daily (sats)"
label="Max amount to be sold daily ({{LNBITS_DENOMINATION}})"
></q-input>

<div class="row">
Expand Down Expand Up @@ -498,13 +499,14 @@ <h6 class="text-subtitle1 q-my-none">{{SITE_TITLE}} TPoS extension</h6>
unelevated
color="primary"
type="submit"
:disable="formDialog.data.currency == null || formDialog.data.name == null || formDialog.data.wallet == null"
>Update TPoS</q-btn
>
<q-btn
v-else
unelevated
color="primary"
:disable="formDialog.data.currency == null || formDialog.data.name == null"
:disable="formDialog.data.currency == null || formDialog.data.name == null || formDialog.data.wallet == null"
type="submit"
>Create TPoS</q-btn
>
Expand Down Expand Up @@ -644,5 +646,8 @@ <h6 class="text-subtitle1 q-my-none">
</q-dialog>
</div>
{% endblock %} {% block scripts %} {{ window_vars(user) }}
<script>
const DENOMINATION = '{{ LNBITS_DENOMINATION }}'
</script>
<script src="{{ static_url_for('tpos/static', path='js/index.js') }}"></script>
{% endblock %}
5 changes: 4 additions & 1 deletion templates/tpos/tpos.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
<div class="row justify-center full-width">
<div class="col-12 col-sm-8 col-md-6 col-lg-4 text-center">
<h3 class="q-mb-md">${ amountFormatted }</h3>
<h5 v-show="!denomIsSats" class="q-mt-none q-mb-sm">
<h5
v-show="!denomIsSats && '{{LNBITS_DENOMINATION}}' == 'sats'"
class="q-mt-none q-mb-sm"
>
${ fsat }<small> sat</small>
</h5>
<div v-if="total > 0.0">
Expand Down