Skip to content

Commit 87e9528

Browse files
fix: exchange rate uses core api endpoint (#115)
1 parent f8648fd commit 87e9528

File tree

2 files changed

+10
-23
lines changed

2 files changed

+10
-23
lines changed

static/js/tpos.js

+10-11
Original file line numberDiff line numberDiff line change
@@ -103,42 +103,42 @@ window.app = Vue.createApp({
103103
}
104104
},
105105
computed: {
106-
amount: function () {
106+
amount() {
107107
if (!this.stack.length) return 0.0
108108
if (this.currency == 'sats') return Number(this.stack.join(''))
109109
return (
110110
this.stack.reduce((acc, dig) => acc * 10 + dig, 0) *
111111
(this.currency == 'sats' ? 1 : 0.01)
112112
)
113113
},
114-
amountFormatted: function () {
114+
amountFormatted() {
115115
return this.formatAmount(this.amount, this.currency)
116116
},
117117
totalFormatted() {
118118
return this.formatAmount(this.total, this.currency)
119119
},
120-
amountWithTipFormatted: function () {
120+
amountWithTipFormatted() {
121121
return this.formatAmount(this.amount + this.tipAmount, this.currency)
122122
},
123-
sat: function () {
123+
sat() {
124124
if (!this.exchangeRate) return 0
125125
return Math.ceil(this.amount * this.exchangeRate)
126126
},
127-
totalSat: function () {
127+
totalSat() {
128128
if (!this.exchangeRate) return 0
129129
return Math.ceil(this.total * this.exchangeRate)
130130
},
131-
tipAmountSat: function () {
131+
tipAmountSat() {
132132
if (!this.exchangeRate) return 0
133133
return Math.ceil(this.tipAmount * this.exchangeRate)
134134
},
135-
tipAmountFormatted: function () {
135+
tipAmountFormatted() {
136136
return LNbits.utils.formatSat(this.tipAmountSat)
137137
},
138-
fsat: function () {
138+
fsat() {
139139
return LNbits.utils.formatSat(this.sat)
140140
},
141-
totalfsat: function () {
141+
totalfsat() {
142142
return LNbits.utils.formatSat(this.totalSat)
143143
},
144144
roundToSugestion() {
@@ -656,10 +656,9 @@ window.app = Vue.createApp({
656656
Quasar.Loading.hide()
657657
} else {
658658
LNbits.api
659-
.request('GET', `/tpos/api/v1/rate/${this.currency}`)
659+
.request('GET', `/api/v1/rate/${this.currency}`)
660660
.then(response => {
661661
this.exchangeRate = response.data.rate
662-
console.log(this.exchangeRate)
663662
Quasar.Loading.hide()
664663
})
665664
.catch(e => console.error(e))

views_api.py

-12
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
require_admin_key,
1616
require_invoice_key,
1717
)
18-
from lnbits.utils.exchange_rates import get_fiat_rate_satoshis
1918
from lnurl import decode as decode_lnurl
2019

2120
from .crud import (
@@ -104,7 +103,6 @@ async def api_tpos_delete(
104103
"/api/v1/tposs/{tpos_id}/invoices", status_code=HTTPStatus.CREATED
105104
)
106105
async def api_tpos_create_invoice(tpos_id: str, data: CreateTposInvoice) -> dict:
107-
108106
tpos = await get_tpos(tpos_id)
109107

110108
if not tpos:
@@ -337,16 +335,6 @@ async def api_tpos_create_withdraw(
337335
return {**lnurlcharge.dict(), **{"lnurl": lnurlcharge.lnurl(request)}}
338336

339337

340-
@tpos_api_router.get("/api/v1/rate/{currency}", status_code=HTTPStatus.OK)
341-
async def api_check_fiat_rate(currency):
342-
try:
343-
rate = await get_fiat_rate_satoshis(currency)
344-
except AssertionError:
345-
rate = None
346-
347-
return {"rate": rate}
348-
349-
350338
@tpos_api_router.put("/api/v1/tposs/{tpos_id}/items", status_code=HTTPStatus.CREATED)
351339
async def api_tpos_create_items(
352340
data: CreateUpdateItemData,

0 commit comments

Comments
 (0)