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