mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-02-20 13:34:47 +01:00
Fixed payment checking
This commit is contained in:
parent
6c7248ae94
commit
e03370188a
28 changed files with 193 additions and 212 deletions
|
@ -46,9 +46,9 @@ class Wallet(BaseModel):
|
|||
)
|
||||
|
||||
async def get_payment(self, payment_hash: str) -> Optional["Payment"]:
|
||||
from .crud import get_wallet_payment
|
||||
from .crud import get_standalone_payment
|
||||
|
||||
return await get_wallet_payment(self.id, payment_hash)
|
||||
return await get_standalone_payment(payment_hash)
|
||||
|
||||
|
||||
class User(BaseModel):
|
||||
|
|
|
@ -314,7 +314,6 @@ async def check_invoice_status(
|
|||
if not payment:
|
||||
return PaymentStatus(None)
|
||||
status = await WALLET.get_invoice_status(payment.checking_id)
|
||||
print(status)
|
||||
if not payment.pending:
|
||||
return status
|
||||
if payment.is_out and status.failed:
|
||||
|
|
|
@ -587,28 +587,29 @@ new Vue({
|
|||
}
|
||||
})
|
||||
},
|
||||
updateWalletName: function(){
|
||||
updateWalletName: function () {
|
||||
let newName = this.newName
|
||||
if(!newName || !newName.length) return
|
||||
if (!newName || !newName.length) return
|
||||
// let data = {name: newName}
|
||||
LNbits.api
|
||||
.request(
|
||||
'PUT',
|
||||
'/api/v1/wallet/' + newName,
|
||||
this.g.wallet.inkey,
|
||||
{}
|
||||
).then(res => {
|
||||
this.newName = ''
|
||||
this.$q.notify({
|
||||
message: `Wallet named updated.`,
|
||||
type: 'positive',
|
||||
timeout: 3500
|
||||
.request('PUT', '/api/v1/wallet/' + newName, this.g.wallet.inkey, {})
|
||||
.then(res => {
|
||||
this.newName = ''
|
||||
this.$q.notify({
|
||||
message: `Wallet named updated.`,
|
||||
type: 'positive',
|
||||
timeout: 3500
|
||||
})
|
||||
LNbits.href.updateWallet(
|
||||
res.data.name,
|
||||
this.user.id,
|
||||
this.g.wallet.id
|
||||
)
|
||||
})
|
||||
.catch(err => {
|
||||
this.newName = ''
|
||||
LNbits.utils.notifyApiError(err)
|
||||
})
|
||||
LNbits.href.updateWallet(res.data.name, this.user.id, this.g.wallet.id)
|
||||
}).catch(err => {
|
||||
this.newName = ''
|
||||
LNbits.utils.notifyApiError(err)
|
||||
})
|
||||
},
|
||||
deleteWallet: function (walletId, user) {
|
||||
LNbits.utils
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
>
|
||||
<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:
|
||||
>curl {{ request.base_url }}api/v1/wallet -H "X-Api-Key:
|
||||
<i>{{ wallet.inkey }}</i>"</code
|
||||
>
|
||||
</q-card-section>
|
||||
|
@ -59,7 +59,7 @@
|
|||
>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X POST {{ request.url_root }}api/v1/payments -d '{"out": false,
|
||||
>curl -X POST {{ request.base_url }}api/v1/payments -d '{"out": false,
|
||||
"amount": <int>, "memo": <string>, "webhook":
|
||||
<url:string>}' -H "X-Api-Key: <i>{{ wallet.inkey }}</i>" -H
|
||||
"Content-type: application/json"</code
|
||||
|
@ -86,7 +86,7 @@
|
|||
<code>{"payment_hash": <string>}</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X POST {{ request.url_root }}api/v1/payments -d '{"out": true,
|
||||
>curl -X POST {{ request.base_url }}api/v1/payments -d '{"out": true,
|
||||
"bolt11": <string>}' -H "X-Api-Key:
|
||||
<i>{{ wallet.adminkey }}"</i> -H "Content-type:
|
||||
application/json"</code
|
||||
|
@ -116,7 +116,7 @@
|
|||
</h5>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X POST {{ request.url_root }}api/v1/payments/decode -d
|
||||
>curl -X POST {{ request.base_url }}api/v1/payments/decode -d
|
||||
'{"data": <bolt11/lnurl, string>}' -H "X-Api-Key:
|
||||
<i>{{ wallet.inkey }}</i>" -H "Content-type: application/json"</code
|
||||
>
|
||||
|
@ -144,7 +144,7 @@
|
|||
<code>{"paid": <bool>}</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root
|
||||
>curl -X GET {{ request.base_url
|
||||
}}api/v1/payments/<payment_hash> -H "X-Api-Key:
|
||||
<i>{{ wallet.inkey }}"</i> -H "Content-type: application/json"</code
|
||||
>
|
||||
|
|
|
@ -270,22 +270,24 @@
|
|||
can scan it from your phone to open your wallet from there.
|
||||
</p>
|
||||
<qrcode
|
||||
:value="'{{request.url_root}}'+'wallet?usr={{user.id}}&wal={{wallet.id}}'"
|
||||
:value="'{{request.base_url}}' +'wallet?usr={{user.id}}&wal={{wallet.id}}'"
|
||||
:options="{width:240}"
|
||||
></qrcode>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-expansion-item>
|
||||
<q-separator></q-separator>
|
||||
<q-expansion-item
|
||||
group="extras"
|
||||
icon="edit"
|
||||
label="Rename wallet"
|
||||
>
|
||||
<q-expansion-item group="extras" icon="edit" label="Rename wallet">
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<div class="" style="max-width: 320px">
|
||||
<q-input filled v-model.trim="newName" label="Label" dense="dense" @update:model-value="(e) => console.log(e)"/>
|
||||
<q-input
|
||||
filled
|
||||
v-model.trim="newName"
|
||||
label="Label"
|
||||
dense="dense"
|
||||
@update:model-value="(e) => console.log(e)"
|
||||
/>
|
||||
</div>
|
||||
<q-btn
|
||||
:disable="!newName.length"
|
||||
|
@ -466,7 +468,8 @@
|
|||
</span>
|
||||
</p>
|
||||
<p v-else class="q-my-none text-h6 text-center">
|
||||
<b>{{ parse.lnurlpay.targetUser || parse.lnurlpay.domain }}</b> is requesting <br />
|
||||
<b>{{ parse.lnurlpay.targetUser || parse.lnurlpay.domain }}</b> is
|
||||
requesting <br />
|
||||
between <b>{{ parse.lnurlpay.minSendable | msatoshiFormat }}</b> and
|
||||
<b>{{ parse.lnurlpay.maxSendable | msatoshiFormat }}</b> sat
|
||||
<span v-if="parse.lnurlpay.commentAllowed > 0">
|
||||
|
|
|
@ -27,7 +27,12 @@ from lnbits.requestvars import g
|
|||
from lnbits.utils.exchange_rates import currencies, fiat_amount_as_satoshis
|
||||
|
||||
from .. import core_app, db
|
||||
from ..crud import get_payments, save_balance_check, update_wallet
|
||||
from ..crud import (
|
||||
get_payments,
|
||||
save_balance_check,
|
||||
update_wallet,
|
||||
get_standalone_payment,
|
||||
)
|
||||
from ..services import (
|
||||
InvoiceFailure,
|
||||
PaymentFailure,
|
||||
|
@ -318,9 +323,11 @@ async def api_payments_sse(
|
|||
|
||||
|
||||
@core_app.get("/api/v1/payments/{payment_hash}")
|
||||
async def api_payment(payment_hash, wallet: WalletTypeInfo = Depends(get_key_type)):
|
||||
payment = await wallet.wallet.get_payment(payment_hash)
|
||||
async def api_payment(payment_hash):
|
||||
|
||||
payment = await get_standalone_payment(payment_hash)
|
||||
await check_invoice_status(payment.wallet_id, payment_hash)
|
||||
payment = await get_standalone_payment(payment_hash)
|
||||
if not payment:
|
||||
return {"message": "Payment does not exist."}
|
||||
elif not payment.pending:
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<code>[<copilot_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X POST {{ request.url_root }}api/v1/copilot -d '{"title":
|
||||
>curl -X POST {{ request.base_url }}api/v1/copilot -d '{"title":
|
||||
<string>, "animation": <string>,
|
||||
"show_message":<string>, "amount": <integer>,
|
||||
"lnurl_title": <string>}' -H "Content-type: application/json"
|
||||
|
@ -58,7 +58,7 @@
|
|||
<code>[<copilot_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X POST {{ request.url_root
|
||||
>curl -X POST {{ request.base_url
|
||||
}}api/v1/copilot/<copilot_id> -d '{"title": <string>,
|
||||
"animation": <string>, "show_message":<string>,
|
||||
"amount": <integer>, "lnurl_title": <string>}' -H
|
||||
|
@ -87,7 +87,7 @@
|
|||
<code>[<copilot_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/copilot/<copilot_id>
|
||||
>curl -X GET {{ request.base_url }}api/v1/copilot/<copilot_id>
|
||||
-H "X-Api-Key: {{ user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -110,7 +110,7 @@
|
|||
<code>[<copilot_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/copilots -H "X-Api-Key: {{
|
||||
>curl -X GET {{ request.base_url }}api/v1/copilots -H "X-Api-Key: {{
|
||||
user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -135,7 +135,7 @@
|
|||
<code></code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X DELETE {{ request.url_root
|
||||
>curl -X DELETE {{ request.base_url
|
||||
}}api/v1/copilot/<copilot_id> -H "X-Api-Key: {{
|
||||
user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
|
@ -161,7 +161,7 @@
|
|||
<code></code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}/api/v1/copilot/ws/<string,
|
||||
>curl -X GET {{ request.base_url }}/api/v1/copilot/ws/<string,
|
||||
copilot_id>/<string, comment>/<string, gif name> -H
|
||||
"X-Api-Key: {{ user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
|
|
|
@ -7,6 +7,7 @@ from starlette.requests import Request
|
|||
|
||||
from lnbits.core.crud import get_user, get_wallet
|
||||
from lnbits.core.services import check_invoice_status, create_invoice
|
||||
from lnbits.core.views.api import api_payment
|
||||
from lnbits.decorators import WalletTypeInfo, get_key_type
|
||||
from lnbits.extensions.events.models import CreateEvent, CreateTicket
|
||||
|
||||
|
@ -43,21 +44,22 @@ async def api_events(
|
|||
|
||||
return [event.dict() for event in await get_events(wallet_ids)]
|
||||
|
||||
|
||||
@events_ext.post("/api/v1/events")
|
||||
@events_ext.put("/api/v1/events/{event_id}")
|
||||
async def api_event_create(data: CreateEvent, event_id=None, wallet: WalletTypeInfo = Depends(get_key_type)):
|
||||
async def api_event_create(
|
||||
data: CreateEvent, event_id=None, wallet: WalletTypeInfo = Depends(get_key_type)
|
||||
):
|
||||
if event_id:
|
||||
event = await get_event(event_id)
|
||||
if not event:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND,
|
||||
detail=f"Event does not exist."
|
||||
status_code=HTTPStatus.NOT_FOUND, detail=f"Event does not exist."
|
||||
)
|
||||
|
||||
if event.wallet != wallet.wallet.id:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.FORBIDDEN,
|
||||
detail=f"Not your event."
|
||||
status_code=HTTPStatus.FORBIDDEN, detail=f"Not your event."
|
||||
)
|
||||
event = await update_event(event_id, **data.dict())
|
||||
else:
|
||||
|
@ -70,16 +72,12 @@ async def api_event_create(data: CreateEvent, event_id=None, wallet: WalletTypeI
|
|||
async def api_form_delete(event_id, wallet: WalletTypeInfo = Depends(get_key_type)):
|
||||
event = await get_event(event_id)
|
||||
if not event:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND,
|
||||
detail=f"Event does not exist."
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND, detail=f"Event does not exist."
|
||||
)
|
||||
|
||||
if event.wallet != wallet.wallet.id:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.FORBIDDEN,
|
||||
detail=f"Not your event."
|
||||
)
|
||||
raise HTTPException(status_code=HTTPStatus.FORBIDDEN, detail=f"Not your event.")
|
||||
|
||||
await delete_event(event_id)
|
||||
await delete_event_tickets(event_id)
|
||||
|
@ -107,10 +105,9 @@ async def api_tickets(
|
|||
async def api_ticket_make_ticket(event_id, sats, data: CreateTicket):
|
||||
event = await get_event(event_id)
|
||||
if not event:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND,
|
||||
detail=f"Event does not exist."
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND, detail=f"Event does not exist."
|
||||
)
|
||||
try:
|
||||
payment_hash, payment_request = await create_invoice(
|
||||
wallet_id=event.wallet,
|
||||
|
@ -122,14 +119,17 @@ async def api_ticket_make_ticket(event_id, sats, data: CreateTicket):
|
|||
raise HTTPException(status_code=HTTPStatus.INTERNAL_SERVER_ERROR, detail=str(e))
|
||||
|
||||
ticket = await create_ticket(
|
||||
payment_hash=payment_hash, wallet=event.wallet, event=event_id, name=data.name, email=data.email
|
||||
payment_hash=payment_hash,
|
||||
wallet=event.wallet,
|
||||
event=event_id,
|
||||
name=data.name,
|
||||
email=data.email,
|
||||
)
|
||||
|
||||
if not ticket:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND,
|
||||
detail=f"Event could not be fetched."
|
||||
)
|
||||
status_code=HTTPStatus.NOT_FOUND, detail=f"Event could not be fetched."
|
||||
)
|
||||
|
||||
return {"payment_hash": payment_hash, "payment_request": payment_request}
|
||||
|
||||
|
@ -139,20 +139,12 @@ async def api_ticket_send_ticket(payment_hash):
|
|||
ticket = await get_ticket(payment_hash)
|
||||
|
||||
try:
|
||||
status = await check_invoice_status(ticket.wallet, payment_hash)
|
||||
is_paid = not status.pending
|
||||
|
||||
status = await api_payment(payment_hash)
|
||||
if status["paid"]:
|
||||
await set_ticket_paid(payment_hash=payment_hash)
|
||||
return {"paid": True, "ticket_id": ticket.id}
|
||||
except Exception:
|
||||
raise HTTPException(status_code=HTTPStatus.NOT_FOUND, detail="Not paid")
|
||||
|
||||
if is_paid:
|
||||
wallet = await get_wallet(ticket.wallet)
|
||||
payment = await wallet.get_payment(payment_hash)
|
||||
await payment.set_pending(False)
|
||||
ticket = await set_ticket_paid(payment_hash=payment_hash)
|
||||
|
||||
return {"paid": True, "ticket_id": ticket.id}
|
||||
|
||||
return {"paid": False}
|
||||
|
||||
|
||||
|
@ -160,33 +152,28 @@ async def api_ticket_send_ticket(payment_hash):
|
|||
async def api_ticket_delete(ticket_id, wallet: WalletTypeInfo = Depends(get_key_type)):
|
||||
ticket = await get_ticket(ticket_id)
|
||||
if not ticket:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND,
|
||||
detail=f"Ticket does not exist."
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND, detail=f"Ticket does not exist."
|
||||
)
|
||||
|
||||
if ticket.wallet != wallet.wallet.id:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.FORBIDDEN,
|
||||
detail=f"Not your ticket."
|
||||
status_code=HTTPStatus.FORBIDDEN, detail=f"Not your ticket."
|
||||
)
|
||||
|
||||
await delete_ticket(ticket_id)
|
||||
raise HTTPException(status_code=HTTPStatus.NO_CONTENT)
|
||||
|
||||
|
||||
|
||||
# Event Tickets
|
||||
|
||||
|
||||
@events_ext.get("/api/v1/eventtickets/{wallet_id}/{event_id}")
|
||||
async def api_event_tickets(wallet_id, event_id):
|
||||
return [
|
||||
ticket.dict()
|
||||
for ticket in await get_event_tickets(
|
||||
wallet_id=wallet_id, event_id=event_id
|
||||
)
|
||||
]
|
||||
ticket.dict()
|
||||
for ticket in await get_event_tickets(wallet_id=wallet_id, event_id=event_id)
|
||||
]
|
||||
|
||||
|
||||
@events_ext.get("/api/v1/register/ticket/{ticket_id}")
|
||||
|
@ -194,20 +181,17 @@ async def api_event_register_ticket(ticket_id):
|
|||
ticket = await get_ticket(ticket_id)
|
||||
if not ticket:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND,
|
||||
detail="Ticket does not exist."
|
||||
status_code=HTTPStatus.NOT_FOUND, detail="Ticket does not exist."
|
||||
)
|
||||
|
||||
if not ticket.paid:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.FORBIDDEN,
|
||||
detail="Ticket not paid for."
|
||||
status_code=HTTPStatus.FORBIDDEN, detail="Ticket not paid for."
|
||||
)
|
||||
|
||||
if ticket.registered == True:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.FORBIDDEN,
|
||||
detail="Ticket already registered"
|
||||
status_code=HTTPStatus.FORBIDDEN, detail="Ticket already registered"
|
||||
)
|
||||
|
||||
return [ticket.dict() for ticket in await reg_ticket(ticket_id)]
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<code>[<jukebox_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/jukebox -H "X-Api-Key: {{
|
||||
>curl -X GET {{ request.base_url }}api/v1/jukebox -H "X-Api-Key: {{
|
||||
user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -59,7 +59,7 @@
|
|||
<code><jukebox_object></code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/jukebox/<juke_id> -H
|
||||
>curl -X GET {{ request.base_url }}api/v1/jukebox/<juke_id> -H
|
||||
"X-Api-Key: {{ user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -86,7 +86,7 @@
|
|||
<code><jukbox_object></code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X POST {{ request.url_root }}api/v1/jukebox/ -d '{"user":
|
||||
>curl -X POST {{ request.base_url }}api/v1/jukebox/ -d '{"user":
|
||||
<string, user_id>, "title": <string>,
|
||||
"wallet":<string>, "sp_user": <string,
|
||||
spotify_user_account>, "sp_secret": <string,
|
||||
|
@ -116,7 +116,7 @@
|
|||
<code><jukebox_object></code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X DELETE {{ request.url_root }}api/v1/jukebox/<juke_id>
|
||||
>curl -X DELETE {{ request.base_url }}api/v1/jukebox/<juke_id>
|
||||
-H "X-Api-Key: {{ user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
|
|
@ -10,6 +10,7 @@ from starlette.exceptions import HTTPException
|
|||
from starlette.responses import HTMLResponse # type: ignore
|
||||
|
||||
from lnbits.core.crud import get_wallet
|
||||
from lnbits.core.views.api import api_payment
|
||||
from lnbits.core.services import check_invoice_status, create_invoice
|
||||
from lnbits.decorators import WalletTypeInfo, get_key_type, require_admin_key
|
||||
|
||||
|
@ -95,7 +96,9 @@ async def api_create_update_jukebox(
|
|||
|
||||
|
||||
@jukebox_ext.delete("/api/v1/jukebox/{juke_id}")
|
||||
async def api_delete_item(juke_id=None, wallet: WalletTypeInfo = Depends(require_admin_key)):
|
||||
async def api_delete_item(
|
||||
juke_id=None, wallet: WalletTypeInfo = Depends(require_admin_key)
|
||||
):
|
||||
await delete_jukebox(juke_id)
|
||||
try:
|
||||
return [{**jukebox} for jukebox in await get_jukeboxs(wallet.wallet.user)]
|
||||
|
@ -276,20 +279,17 @@ async def api_get_jukebox_invoice_check(
|
|||
pay_hash: str = Query(None), juke_id: str = Query(None)
|
||||
):
|
||||
try:
|
||||
jukebox = await get_jukebox(juke_id)
|
||||
await get_jukebox(juke_id)
|
||||
except:
|
||||
raise HTTPException(status_code=HTTPStatus.FORBIDDEN, detail="No jukebox")
|
||||
try:
|
||||
status = await check_invoice_status(jukebox.wallet, pay_hash)
|
||||
is_paid = not status.pending
|
||||
status = await api_payment(pay_hash)
|
||||
if status["paid"]:
|
||||
await update_jukebox_payment(pay_hash, paid=True)
|
||||
return {"paid": True}
|
||||
except:
|
||||
return {"paid": False}
|
||||
if is_paid:
|
||||
wallet = await get_wallet(jukebox.wallet)
|
||||
payment = await wallet.get_payment(pay_hash)
|
||||
await payment.set_pending(False)
|
||||
await update_jukebox_payment(pay_hash, paid=True)
|
||||
return {"paid": True}
|
||||
|
||||
return {"paid": False}
|
||||
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ from starlette.exceptions import HTTPException
|
|||
from starlette.requests import Request
|
||||
from starlette.responses import HTMLResponse, JSONResponse # type: ignore
|
||||
|
||||
from lnbits.core.views.api import api_payment
|
||||
from lnbits.core.crud import get_user, get_wallet
|
||||
from lnbits.core.services import check_invoice_status, create_invoice
|
||||
from lnbits.decorators import WalletTypeInfo, get_key_type
|
||||
|
@ -169,19 +170,15 @@ async def api_ticket_make_ticket(data: CreateTicketData, form_id):
|
|||
@lnticket_ext.get("/api/v1/tickets/{payment_hash}", status_code=HTTPStatus.OK)
|
||||
async def api_ticket_send_ticket(payment_hash):
|
||||
ticket = await get_ticket(payment_hash)
|
||||
|
||||
try:
|
||||
status = await check_invoice_status(ticket.wallet, payment_hash)
|
||||
is_paid = not status.pending
|
||||
status = await api_payment(payment_hash)
|
||||
if status["paid"]:
|
||||
await set_ticket_paid(payment_hash=payment_hash)
|
||||
return {"paid": True}
|
||||
except Exception:
|
||||
return {"paid": False}
|
||||
|
||||
if is_paid:
|
||||
wallet = await get_wallet(ticket.wallet)
|
||||
payment = await wallet.get_payment(payment_hash)
|
||||
await payment.set_pending(False)
|
||||
ticket = await set_ticket_paid(payment_hash=payment_hash)
|
||||
return {"paid": True}
|
||||
|
||||
return {"paid": False}
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<code>[<pay_link_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/links -H "X-Api-Key: {{
|
||||
>curl -X GET {{ request.base_url }}api/v1/links -H "X-Api-Key: {{
|
||||
user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -39,7 +39,7 @@
|
|||
<code>{"lnurl": <string>}</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/links/<pay_id> -H
|
||||
>curl -X GET {{ request.base_url }}api/v1/links/<pay_id> -H
|
||||
"X-Api-Key: {{ user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -68,7 +68,7 @@
|
|||
<code>{"lnurl": <string>}</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X POST {{ request.url_root }}api/v1/links -d '{"description":
|
||||
>curl -X POST {{ request.base_url }}api/v1/links -d '{"description":
|
||||
<string>, "amount": <integer>, "max": <integer>,
|
||||
"min": <integer>, "comment_chars": <integer>}' -H
|
||||
"Content-type: application/json" -H "X-Api-Key: {{
|
||||
|
@ -99,7 +99,7 @@
|
|||
<code>{"lnurl": <string>}</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X PUT {{ request.url_root }}api/v1/links/<pay_id> -d
|
||||
>curl -X PUT {{ request.base_url }}api/v1/links/<pay_id> -d
|
||||
'{"description": <string>, "amount": <integer>}' -H
|
||||
"Content-type: application/json" -H "X-Api-Key: {{
|
||||
user.wallets[0].adminkey }}"
|
||||
|
@ -126,7 +126,7 @@
|
|||
<code></code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X DELETE {{ request.url_root }}api/v1/links/<pay_id> -H
|
||||
>curl -X DELETE {{ request.base_url }}api/v1/links/<pay_id> -H
|
||||
"X-Api-Key: {{ user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
<code>[<lnurlpos_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X POST {{ request.url_root }}api/v1/lnurlpos -d '{"title":
|
||||
>curl -X POST {{ request.base_url }}api/v1/lnurlpos -d '{"title":
|
||||
<string>, "message":<string>, "currency":
|
||||
<integer>}' -H "Content-type: application/json" -H "X-Api-Key:
|
||||
{{user.wallets[0].adminkey }}"
|
||||
|
@ -70,7 +70,7 @@
|
|||
<code>[<lnurlpos_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X POST {{ request.url_root
|
||||
>curl -X POST {{ request.base_url
|
||||
}}api/v1/lnurlpos/<lnurlpos_id> -d ''{"title": <string>,
|
||||
"message":<string>, "currency": <integer>} -H
|
||||
"Content-type: application/json" -H "X-Api-Key:
|
||||
|
@ -98,7 +98,7 @@
|
|||
<code>[<lnurlpos_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root
|
||||
>curl -X GET {{ request.base_url
|
||||
}}api/v1/lnurlpos/<lnurlpos_id> -H "X-Api-Key: {{
|
||||
user.wallets[0].inkey }}"
|
||||
</code>
|
||||
|
@ -122,7 +122,7 @@
|
|||
<code>[<lnurlpos_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/lnurlposs -H "X-Api-Key:
|
||||
>curl -X GET {{ request.base_url }}api/v1/lnurlposs -H "X-Api-Key:
|
||||
{{ user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -147,7 +147,7 @@
|
|||
<code></code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X DELETE {{ request.url_root
|
||||
>curl -X DELETE {{ request.base_url
|
||||
}}api/v1/lnurlpos/<lnurlpos_id> -H "X-Api-Key: {{
|
||||
user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
|
|
|
@ -9,6 +9,7 @@ from lnbits.core.crud import get_standalone_payment
|
|||
import hashlib
|
||||
from lnbits.core.services import check_invoice_status
|
||||
from lnbits.core.crud import update_payment_status
|
||||
from lnbits.core.views.api import api_payment
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from starlette.exceptions import HTTPException
|
||||
|
@ -44,17 +45,13 @@ async def displaypin(request: Request, paymentid: str = Query(None)):
|
|||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND, detail="lnurlpos not found."
|
||||
)
|
||||
|
||||
status = await check_invoice_status(pos.wallet, lnurlpospayment.payhash)
|
||||
|
||||
is_paid = not status.pending
|
||||
if not is_paid:
|
||||
status = await api_payment(lnurlpospayment.payhash)
|
||||
if status["paid"]:
|
||||
await update_payment_status(checking_id=lnurlpospayment.payhash, pending=True)
|
||||
return lnurlpos_renderer().TemplateResponse(
|
||||
"lnurlpos/error.html",
|
||||
{"request": request, "pin": "filler", "not_paid": True},
|
||||
"lnurlpos/paid.html", {"request": request, "pin": lnurlpospayment.pin}
|
||||
)
|
||||
|
||||
await update_payment_status(checking_id=lnurlpospayment.payhash, pending=True)
|
||||
return lnurlpos_renderer().TemplateResponse(
|
||||
"lnurlpos/paid.html", {"request": request, "pin": lnurlpospayment.pin}
|
||||
"lnurlpos/error.html",
|
||||
{"request": request, "pin": "filler", "not_paid": True},
|
||||
)
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
<h5 class="text-caption q-mt-sm q-mb-none">Returns 201 OK</h5>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root
|
||||
>curl -X GET {{ request.base_url
|
||||
}}/offlineshop/api/v1/offlineshop/items -H "Content-Type:
|
||||
application/json" -H "X-Api-Key: {{ user.wallets[0].inkey }}" -d
|
||||
'{"name": <string>, "description": <string>, "image":
|
||||
|
@ -96,7 +96,7 @@
|
|||
>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}/offlineshop/api/v1/offlineshop -H
|
||||
>curl -X GET {{ request.base_url }}/offlineshop/api/v1/offlineshop -H
|
||||
"X-Api-Key: {{ user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -117,12 +117,12 @@
|
|||
<h5 class="text-caption q-mt-sm q-mb-none">Returns 200 OK</h5>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root
|
||||
>curl -X GET {{ request.base_url
|
||||
}}/offlineshop/api/v1/offlineshop/items/<item_id> -H
|
||||
"Content-Type: application/json" -H "X-Api-Key: {{
|
||||
user.wallets[0].inkey }}" -d '{"name": <string>,
|
||||
"description": <string>, "image": <data-uri string>,
|
||||
"price": <integer>, "unit": <"sat" or "USD">}'
|
||||
user.wallets[0].inkey }}" -d '{"name": <string>, "description":
|
||||
<string>, "image": <data-uri string>, "price":
|
||||
<integer>, "unit": <"sat" or "USD">}'
|
||||
</code>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
@ -137,7 +137,7 @@
|
|||
<h5 class="text-caption q-mt-sm q-mb-none">Returns 200 OK</h5>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root
|
||||
>curl -X GET {{ request.base_url
|
||||
}}/offlineshop/api/v1/offlineshop/items/<item_id> -H "X-Api-Key:
|
||||
{{ user.wallets[0].inkey }}"
|
||||
</code>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<code>[<satsdice_link_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/links -H "X-Api-Key: {{
|
||||
>curl -X GET {{ request.base_url }}api/v1/links -H "X-Api-Key: {{
|
||||
user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -44,7 +44,7 @@
|
|||
<code>{"lnurl": <string>}</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/links/<satsdice_id> -H
|
||||
>curl -X GET {{ request.base_url }}api/v1/links/<satsdice_id> -H
|
||||
"X-Api-Key: {{ user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -73,7 +73,7 @@
|
|||
<code>{"lnurl": <string>}</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X POST {{ request.url_root }}api/v1/links -d '{"title":
|
||||
>curl -X POST {{ request.base_url }}api/v1/links -d '{"title":
|
||||
<string>, "min_satsdiceable": <integer>,
|
||||
"max_satsdiceable": <integer>, "uses": <integer>,
|
||||
"wait_time": <integer>, "is_unique": <boolean>}' -H
|
||||
|
@ -109,7 +109,7 @@
|
|||
<code>{"lnurl": <string>}</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X PUT {{ request.url_root }}api/v1/links/<satsdice_id> -d
|
||||
>curl -X PUT {{ request.base_url }}api/v1/links/<satsdice_id> -d
|
||||
'{"title": <string>, "min_satsdiceable": <integer>,
|
||||
"max_satsdiceable": <integer>, "uses": <integer>,
|
||||
"wait_time": <integer>, "is_unique": <boolean>}' -H
|
||||
|
@ -137,7 +137,7 @@
|
|||
<code></code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X DELETE {{ request.url_root }}api/v1/links/<satsdice_id>
|
||||
>curl -X DELETE {{ request.base_url }}api/v1/links/<satsdice_id>
|
||||
-H "X-Api-Key: {{ user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -164,7 +164,7 @@
|
|||
<code>{"status": <bool>}</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root
|
||||
>curl -X GET {{ request.base_url
|
||||
}}api/v1/links/<the_hash>/<lnurl_id> -H "X-Api-Key: {{
|
||||
user.wallets[0].inkey }}"
|
||||
</code>
|
||||
|
@ -186,7 +186,7 @@
|
|||
>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}/satsdice/img/<lnurl_id>"
|
||||
>curl -X GET {{ request.base_url }}/satsdice/img/<lnurl_id>"
|
||||
</code>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
|
|
@ -15,6 +15,7 @@ from lnbits.core.crud import (
|
|||
delete_expired_invoices,
|
||||
get_balance_checks,
|
||||
)
|
||||
from lnbits.core.views.api import api_payment
|
||||
from lnbits.core.services import check_invoice_status
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.params import Depends
|
||||
|
@ -62,9 +63,7 @@ async def displaywin(
|
|||
HTTPStatus.NOT_FOUND, "satsdice link does not exist."
|
||||
)
|
||||
|
||||
status = await check_invoice_status(
|
||||
wallet_id=satsdicelink.wallet, payment_hash=payment_hash
|
||||
)
|
||||
await api_payment(payment_hash)
|
||||
|
||||
withdrawLink = await get_satsdice_withdraw(payment_hash)
|
||||
if withdrawLink:
|
||||
|
@ -86,7 +85,7 @@ async def displaywin(
|
|||
)
|
||||
|
||||
if payment.pending == 1:
|
||||
await check_invoice_status(payment.wallet_id, payment_hash)
|
||||
await api_payment(payment_hash)
|
||||
payment = await get_standalone_payment(payment_hash) or abort(
|
||||
HTTPStatus.NOT_FOUND, "satsdice link does not exist."
|
||||
)
|
||||
|
|
|
@ -9,7 +9,7 @@ from lnbits.helpers import urlsafe_short_hash
|
|||
import httpx
|
||||
from lnbits.core.services import create_invoice, check_invoice_status
|
||||
from ..watchonly.crud import get_watch_wallet, get_fresh_address, get_mempool
|
||||
|
||||
from lnbits.core.views.api import api_payment
|
||||
|
||||
###############CHARGES##########################
|
||||
|
||||
|
@ -110,10 +110,9 @@ async def check_address_balance(charge_id: str) -> List[Charges]:
|
|||
except Exception:
|
||||
pass
|
||||
if charge.lnbitswallet:
|
||||
invoice_status = await check_invoice_status(
|
||||
charge.lnbitswallet, charge.payment_hash
|
||||
)
|
||||
if invoice_status.paid:
|
||||
invoice_status = await api_payment(charge.payment_hash)
|
||||
|
||||
if invoice_status["paid"]:
|
||||
return await update_charge(charge_id=charge_id, balance=charge.amount)
|
||||
row = await db.fetchone("SELECT * FROM satspay.charges WHERE id = ?", (charge_id,))
|
||||
return Charges.from_row(row) if row else None
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<code>[<charge_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X POST {{ request.url_root }}api/v1/charge -d
|
||||
>curl -X POST {{ request.base_url }}api/v1/charge -d
|
||||
'{"onchainwallet": <string, watchonly_wallet_id>,
|
||||
"description": <string>, "webhook":<string>, "time":
|
||||
<integer>, "amount": <integer>, "lnbitswallet":
|
||||
|
@ -60,7 +60,7 @@
|
|||
<code>[<charge_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X POST {{ request.url_root }}api/v1/charge/<charge_id>
|
||||
>curl -X POST {{ request.base_url }}api/v1/charge/<charge_id>
|
||||
-d '{"onchainwallet": <string, watchonly_wallet_id>,
|
||||
"description": <string>, "webhook":<string>, "time":
|
||||
<integer>, "amount": <integer>, "lnbitswallet":
|
||||
|
@ -89,7 +89,7 @@
|
|||
<code>[<charge_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/charge/<charge_id>
|
||||
>curl -X GET {{ request.base_url }}api/v1/charge/<charge_id>
|
||||
-H "X-Api-Key: {{ user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -112,7 +112,7 @@
|
|||
<code>[<charge_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/charges -H "X-Api-Key: {{
|
||||
>curl -X GET {{ request.base_url }}api/v1/charges -H "X-Api-Key: {{
|
||||
user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -137,7 +137,7 @@
|
|||
<code></code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X DELETE {{ request.url_root
|
||||
>curl -X DELETE {{ request.base_url
|
||||
}}api/v1/charge/<charge_id> -H "X-Api-Key: {{
|
||||
user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
|
@ -160,7 +160,7 @@
|
|||
<code>[<charge_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root
|
||||
>curl -X GET {{ request.base_url
|
||||
}}api/v1/charges/balance/<charge_id> -H "X-Api-Key: {{
|
||||
user.wallets[0].inkey }}"
|
||||
</code>
|
||||
|
|
|
@ -7,7 +7,7 @@ from starlette.exceptions import HTTPException
|
|||
|
||||
from lnbits.decorators import WalletTypeInfo, get_key_type, require_admin_key
|
||||
from lnbits.extensions.satspay import satspay_ext
|
||||
|
||||
from lnbits.core.views.api import api_payment
|
||||
from .crud import (
|
||||
check_address_balance,
|
||||
create_charge,
|
||||
|
@ -24,7 +24,9 @@ from .models import CreateCharge
|
|||
@satspay_ext.post("/api/v1/charge")
|
||||
@satspay_ext.put("/api/v1/charge/{charge_id}")
|
||||
async def api_charge_create_or_update(
|
||||
data: CreateCharge, wallet: WalletTypeInfo = Depends(require_admin_key), charge_id=None
|
||||
data: CreateCharge,
|
||||
wallet: WalletTypeInfo = Depends(require_admin_key),
|
||||
charge_id=None,
|
||||
):
|
||||
if not charge_id:
|
||||
charge = await create_charge(user=wallet.wallet.user, data=data)
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/livestream -H "X-Api-Key: {{
|
||||
>curl -X GET {{ request.base_url }}api/v1/livestream -H "X-Api-Key: {{
|
||||
user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -78,7 +78,7 @@
|
|||
</h5>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X PUT {{ request.url_root }}api/v1/splitpayments/targets -H
|
||||
>curl -X PUT {{ request.base_url }}api/v1/splitpayments/targets -H
|
||||
"X-Api-Key: {{ user.wallets[0].adminkey }}" -H 'Content-Type:
|
||||
application/json' -d '{"targets": [{"wallet": <wallet id or invoice
|
||||
key>, "alias": <name to identify this>, "percent": <number
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<code>[<tpos_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/tposs -H "X-Api-Key:
|
||||
>curl -X GET {{ request.base_url }}api/v1/tposs -H "X-Api-Key:
|
||||
<invoice_key>"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -42,7 +42,7 @@
|
|||
>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X POST {{ request.url_root }}api/v1/tposs -d '{"name":
|
||||
>curl -X POST {{ request.base_url }}api/v1/tposs -d '{"name":
|
||||
<string>, "currency": <string>}' -H "Content-type:
|
||||
application/json" -H "X-Api-Key: <admin_key>"
|
||||
</code>
|
||||
|
@ -69,7 +69,7 @@
|
|||
<code></code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X DELETE {{ request.url_root }}api/v1/tposs/<tpos_id> -H
|
||||
>curl -X DELETE {{ request.base_url }}api/v1/tposs/<tpos_id> -H
|
||||
"X-Api-Key: <admin_key>"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
|
|
@ -29,6 +29,7 @@ async def tpos(request: Request, tpos_id):
|
|||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND, detail="TPoS does not exist."
|
||||
)
|
||||
print(request.base_url)
|
||||
|
||||
return tpos_renderer().TemplateResponse(
|
||||
"tpos/tpos.html", {"request": request, "tpos": tpos}
|
||||
|
|
|
@ -7,7 +7,8 @@ from starlette.exceptions import HTTPException
|
|||
from lnbits.core.crud import get_user, get_wallet
|
||||
from lnbits.core.services import check_invoice_status, create_invoice
|
||||
from lnbits.decorators import WalletTypeInfo, get_key_type, require_admin_key
|
||||
|
||||
from lnbits.core.views.api import api_payment
|
||||
from lnbits.core.models import Wallet
|
||||
from . import tpos_ext
|
||||
from .crud import create_tpos, delete_tpos, get_tpos, get_tposs
|
||||
from .models import CreateTposData
|
||||
|
@ -33,7 +34,9 @@ async def api_tpos_create(
|
|||
|
||||
|
||||
@tpos_ext.delete("/api/v1/tposs/{tpos_id}")
|
||||
async def api_tpos_delete(tpos_id: str, wallet: WalletTypeInfo = Depends(require_admin_key)):
|
||||
async def api_tpos_delete(
|
||||
tpos_id: str, wallet: WalletTypeInfo = Depends(require_admin_key)
|
||||
):
|
||||
tpos = await get_tpos(tpos_id)
|
||||
|
||||
if not tpos:
|
||||
|
@ -84,20 +87,9 @@ async def api_tpos_check_invoice(tpos_id: str, payment_hash: str):
|
|||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND, detail="TPoS does not exist."
|
||||
)
|
||||
# return {"message": "TPoS does not exist."}, HTTPStatus.NOT_FOUND
|
||||
|
||||
try:
|
||||
status = await check_invoice_status(tpos.wallet, payment_hash)
|
||||
is_paid = not status.pending
|
||||
status = await api_payment(payment_hash)
|
||||
except Exception as exc:
|
||||
print(exc)
|
||||
return {"paid": False}
|
||||
|
||||
if is_paid:
|
||||
wallet = await get_wallet(tpos.wallet)
|
||||
payment = await wallet.get_payment(payment_hash)
|
||||
await payment.set_pending(False)
|
||||
|
||||
return {"paid": True}
|
||||
|
||||
return {"paid": False}
|
||||
return status
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
<code>JSON list of users</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}usermanager/api/v1/users -H
|
||||
>curl -X GET {{ request.base_url }}usermanager/api/v1/users -H
|
||||
"X-Api-Key: {{ user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -62,7 +62,7 @@
|
|||
<code>JSON list of users</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root
|
||||
>curl -X GET {{ request.base_url
|
||||
}}usermanager/api/v1/users/<user_id> -H "X-Api-Key: {{
|
||||
user.wallets[0].inkey }}"
|
||||
</code>
|
||||
|
@ -85,7 +85,7 @@
|
|||
<code>JSON wallet data</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root
|
||||
>curl -X GET {{ request.base_url
|
||||
}}usermanager/api/v1/wallets/<user_id> -H "X-Api-Key: {{
|
||||
user.wallets[0].inkey }}"
|
||||
</code>
|
||||
|
@ -108,7 +108,7 @@
|
|||
<code>JSON a wallets transactions</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root
|
||||
>curl -X GET {{ request.base_url
|
||||
}}usermanager/api/v1/wallets<wallet_id> -H "X-Api-Key: {{
|
||||
user.wallets[0].inkey }}"
|
||||
</code>
|
||||
|
@ -150,7 +150,7 @@
|
|||
>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X POST {{ request.url_root }}usermanager/api/v1/users -d
|
||||
>curl -X POST {{ request.base_url }}usermanager/api/v1/users -d
|
||||
'{"admin_id": "{{ user.id }}", "wallet_name": <string>,
|
||||
"user_name": <string>, "email": <Optional string>,
|
||||
"password": < Optional string>}' -H "X-Api-Key: {{
|
||||
|
@ -188,7 +188,7 @@
|
|||
>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X POST {{ request.url_root }}usermanager/api/v1/wallets -d
|
||||
>curl -X POST {{ request.base_url }}usermanager/api/v1/wallets -d
|
||||
'{"user_id": <string>, "wallet_name": <string>,
|
||||
"admin_id": "{{ user.id }}"}' -H "X-Api-Key: {{ user.wallets[0].inkey
|
||||
}}" -H "Content-type: application/json"
|
||||
|
@ -212,7 +212,7 @@
|
|||
<code>{"X-Api-Key": <string>}</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X DELETE {{ request.url_root
|
||||
>curl -X DELETE {{ request.base_url
|
||||
}}usermanager/api/v1/users/<user_id> -H "X-Api-Key: {{
|
||||
user.wallets[0].inkey }}"
|
||||
</code>
|
||||
|
@ -230,7 +230,7 @@
|
|||
<code>{"X-Api-Key": <string>}</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X DELETE {{ request.url_root
|
||||
>curl -X DELETE {{ request.base_url
|
||||
}}usermanager/api/v1/wallets/<wallet_id> -H "X-Api-Key: {{
|
||||
user.wallets[0].inkey }}"
|
||||
</code>
|
||||
|
@ -253,7 +253,7 @@
|
|||
<code>{"X-Api-Key": <string>}</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X POST {{ request.url_root }}usermanager/api/v1/extensions -d
|
||||
>curl -X POST {{ request.base_url }}usermanager/api/v1/extensions -d
|
||||
'{"userid": <string>, "extension": <string>, "active":
|
||||
<integer>}' -H "X-Api-Key: {{ user.wallets[0].inkey }}" -H
|
||||
"Content-type: application/json"
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<code>[<wallets_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/wallet -H "X-Api-Key: {{
|
||||
>curl -X GET {{ request.base_url }}api/v1/wallet -H "X-Api-Key: {{
|
||||
user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -66,7 +66,7 @@
|
|||
<code>[<wallet_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/wallet/<wallet_id>
|
||||
>curl -X GET {{ request.base_url }}api/v1/wallet/<wallet_id>
|
||||
-H "X-Api-Key: {{ user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -89,7 +89,7 @@
|
|||
<code>[<wallet_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X POST {{ request.url_root }}api/v1/wallet -d '{"title":
|
||||
>curl -X POST {{ request.base_url }}api/v1/wallet -d '{"title":
|
||||
<string>, "masterpub": <string>}' -H "Content-type:
|
||||
application/json" -H "X-Api-Key: {{ user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
|
@ -115,7 +115,7 @@
|
|||
<code></code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X DELETE {{ request.url_root
|
||||
>curl -X DELETE {{ request.base_url
|
||||
}}api/v1/wallet/<wallet_id> -H "X-Api-Key: {{
|
||||
user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
|
@ -141,7 +141,7 @@
|
|||
<code>[<address_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root
|
||||
>curl -X GET {{ request.base_url
|
||||
}}api/v1/addresses/<wallet_id> -H "X-Api-Key: {{
|
||||
user.wallets[0].inkey }}"
|
||||
</code>
|
||||
|
@ -173,7 +173,7 @@
|
|||
<code>[<address_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/address/<wallet_id>
|
||||
>curl -X GET {{ request.base_url }}api/v1/address/<wallet_id>
|
||||
-H "X-Api-Key: {{ user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -202,7 +202,7 @@
|
|||
<code>[<mempool_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/mempool -H "X-Api-Key: {{
|
||||
>curl -X GET {{ request.base_url }}api/v1/mempool -H "X-Api-Key: {{
|
||||
user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -233,7 +233,7 @@
|
|||
<code>[<mempool_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X PUT {{ request.url_root }}api/v1/mempool -d '{"endpoint":
|
||||
>curl -X PUT {{ request.base_url }}api/v1/mempool -d '{"endpoint":
|
||||
<string>}' -H "Content-type: application/json" -H "X-Api-Key:
|
||||
{{ user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<code>[<withdraw_link_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/links -H "X-Api-Key: {{
|
||||
>curl -X GET {{ request.base_url }}api/v1/links -H "X-Api-Key: {{
|
||||
user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -49,7 +49,7 @@
|
|||
<code>{"lnurl": <string>}</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/links/<withdraw_id> -H
|
||||
>curl -X GET {{ request.base_url }}api/v1/links/<withdraw_id> -H
|
||||
"X-Api-Key: {{ user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -78,7 +78,7 @@
|
|||
<code>{"lnurl": <string>}</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X POST {{ request.url_root }}api/v1/links -d '{"title":
|
||||
>curl -X POST {{ request.base_url }}api/v1/links -d '{"title":
|
||||
<string>, "min_withdrawable": <integer>,
|
||||
"max_withdrawable": <integer>, "uses": <integer>,
|
||||
"wait_time": <integer>, "is_unique": <boolean>}' -H
|
||||
|
@ -114,7 +114,7 @@
|
|||
<code>{"lnurl": <string>}</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X PUT {{ request.url_root }}api/v1/links/<withdraw_id> -d
|
||||
>curl -X PUT {{ request.base_url }}api/v1/links/<withdraw_id> -d
|
||||
'{"title": <string>, "min_withdrawable": <integer>,
|
||||
"max_withdrawable": <integer>, "uses": <integer>,
|
||||
"wait_time": <integer>, "is_unique": <boolean>}' -H
|
||||
|
@ -142,7 +142,7 @@
|
|||
<code></code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X DELETE {{ request.url_root }}api/v1/links/<withdraw_id>
|
||||
>curl -X DELETE {{ request.base_url }}api/v1/links/<withdraw_id>
|
||||
-H "X-Api-Key: {{ user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@ -169,7 +169,7 @@
|
|||
<code>{"status": <bool>}</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root
|
||||
>curl -X GET {{ request.base_url
|
||||
}}api/v1/links/<the_hash>/<lnurl_id> -H "X-Api-Key: {{
|
||||
user.wallets[0].inkey }}"
|
||||
</code>
|
||||
|
@ -191,7 +191,7 @@
|
|||
>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}/withdraw/img/<lnurl_id>"
|
||||
>curl -X GET {{ request.base_url }}/withdraw/img/<lnurl_id>"
|
||||
</code>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
|
Loading…
Add table
Reference in a new issue