Skip to content

Commit

Permalink
make it work
Browse files Browse the repository at this point in the history
  • Loading branch information
talvasconcelos committed Feb 10, 2024
1 parent 2f2dabe commit 10e857d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
12 changes: 6 additions & 6 deletions crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ async def start_lnurlcharge(tpos_id: str):
assert tpos, f"TPoS with {tpos_id} not found!"

now = await get_current_timestamp()
withdraw_time_seconds = tpos.withdrawbtwn * 60
if tpos.withdrawtimeopt == "secs":
withdraw_time_seconds = tpos.withdrawbtwn
withdraw_time_seconds = (
tpos.withdrawbtwn * 60 if tpos.withdrawtimeopt != "secs" else tpos.withdrawbtwn
)
assert (
now - tpos.withdrawtime > withdraw_time_seconds
), f"Last withdraw was made too recently, please try again in {int(withdraw_time_seconds - (now - tpos.withdrawtime))} secs"
Expand Down Expand Up @@ -109,9 +109,9 @@ async def update_tpos_withdraw(data: TPoS, tpos_id: str) -> TPoS:
# Calculate the time between withdrawals in seconds
now = await get_current_timestamp()
time_elapsed = now - data.withdrawtime
withdraw_time_seconds = data.withdrawbtwn * 60
if data.withdrawtimeopt != "secs":
withdraw_time_seconds = data.withdrawbtwn * 60
withdraw_time_seconds = (
data.withdrawbtwn * 60 if data.withdrawtimeopt != "secs" else data.withdrawbtwn
)

logger.debug(f"Time between: {time_elapsed} seconds")

Expand Down
14 changes: 10 additions & 4 deletions templates/tpos/tpos.html
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ <h5 class="q-mt-none q-mb-sm">
currency: '{{ tpos.currency }}',
withdrawamtposs: `{{ withdrawamtposs }}`,
atmPremium: Number('{{ tpos.withdrawpremium }}') / 100,
withdrawpinopen:Number('{{ withdrawpinopen }}'),
withdrawpinopen: Number('{{ withdrawpinopen }}'),
tip_options: null,
exchangeRate: null,
stack: [],
Expand Down Expand Up @@ -890,8 +890,8 @@ <h5 class="q-mt-none q-mb-sm">
},
atm() {
if (this.atmPremium > 0) {
this.exchangeRate = this.exchangeRate / (1 + this.atmPremium)
}
this.exchangeRate = this.exchangeRate / (1 + this.atmPremium)
}
if (this.withdrawpinopen != 0) {
this.atmPin = this.withdrawpinopen
this.atmSubmit()
Expand Down Expand Up @@ -1149,10 +1149,11 @@ <h5 class="q-mt-none q-mb-sm">
//User feedback, show loader icon
self.nfcTagReading = false
if (self.atmMode) {
const URL = lnurl.replace('lnurlp://', 'https://')
LNbits.api
.request('GET', `${lnurl.replace('lnurlw://', 'https://')}`)
.then(res => {
self.makeWithdraw(res.data.payLink)
self.makeWithdraw(res.data.payLink, readerAbortController)
})
} else {
self.payInvoice(lnurl, readerAbortController)
Expand Down Expand Up @@ -1203,6 +1204,10 @@ <h5 class="q-mt-none q-mb-sm">
}
readerAbortController.abort()
})
.catch(e => {
console.error(e)
readerAbortController.abort()
})
},
payInvoice: function (lnurl, readerAbortController) {
const self = this
Expand Down Expand Up @@ -1296,6 +1301,7 @@ <h5 class="q-mt-none q-mb-sm">
created: function () {
var getRates = this.getRates
getRates()
this.pinDisabled = JSON.parse('{{ tpos.withdrawpindisabled | tojson }}')
this.tip_options =
'{{ tpos.tip_options | tojson }}' == 'null'
? null
Expand Down
1 change: 0 additions & 1 deletion views_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ async def api_tpos_check_invoice(tpos_id: str, payment_hash: str):
@tpos_ext.get("/api/v1/atm/{tpos_id}/{atmpin}", status_code=HTTPStatus.CREATED)
async def api_tpos_atm_pin_check(tpos_id: str, atmpin: int):
tpos = await get_tpos(tpos_id)
logger.debug(tpos)
if not tpos:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND, detail="TPoS does not exist."
Expand Down

0 comments on commit 10e857d

Please sign in to comment.