mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-30 14:06:28 +02:00
Started watchonly
This commit is contained in:
@@ -17,7 +17,7 @@ from .models import TPoS
|
|||||||
|
|
||||||
@tpos_ext.get("/api/v1/tposs")
|
@tpos_ext.get("/api/v1/tposs")
|
||||||
@api_check_wallet_key("invoice")
|
@api_check_wallet_key("invoice")
|
||||||
async def api_tposs(all_wallets: boolean = Query(None)):
|
async def api_tposs(all_wallets: bool = Query(None)):
|
||||||
wallet_ids = [g.wallet.id]
|
wallet_ids = [g.wallet.id]
|
||||||
if all_wallets:
|
if all_wallets:
|
||||||
wallet_ids = wallet_ids = (await get_user(g.wallet.user)).wallet_ids(await get_user(g.wallet.user)).wallet_ids
|
wallet_ids = wallet_ids = (await get_user(g.wallet.user)).wallet_ids(await get_user(g.wallet.user)).wallet_ids
|
||||||
@@ -27,6 +27,10 @@ async def api_tposs(all_wallets: boolean = Query(None)):
|
|||||||
return [tpos._asdict() for tpos in await get_tposs(wallet_ids)], HTTPStatus.OK
|
return [tpos._asdict() for tpos in await get_tposs(wallet_ids)], HTTPStatus.OK
|
||||||
|
|
||||||
|
|
||||||
|
class CreateData(BaseModel):
|
||||||
|
name: str
|
||||||
|
currency: str
|
||||||
|
|
||||||
@tpos_ext.post("/api/v1/tposs")
|
@tpos_ext.post("/api/v1/tposs")
|
||||||
@api_check_wallet_key("invoice")
|
@api_check_wallet_key("invoice")
|
||||||
# @api_validate_post_request(
|
# @api_validate_post_request(
|
||||||
@@ -35,8 +39,8 @@ async def api_tposs(all_wallets: boolean = Query(None)):
|
|||||||
# "currency": {"type": "string", "empty": False, "required": True},
|
# "currency": {"type": "string", "empty": False, "required": True},
|
||||||
# }
|
# }
|
||||||
# )
|
# )
|
||||||
async def api_tpos_create(name: str = Query(...), currency: str = Query(...)):
|
async def api_tpos_create(data: CreateData):
|
||||||
tpos = await create_tpos(wallet_id=g.wallet.id, **g.data)
|
tpos = await create_tpos(wallet_id=g.wallet.id, **data)
|
||||||
return tpos._asdict(), HTTPStatus.CREATED
|
return tpos._asdict(), HTTPStatus.CREATED
|
||||||
|
|
||||||
|
|
||||||
@@ -60,7 +64,7 @@ async def api_tpos_delete(tpos_id: str):
|
|||||||
# @api_validate_post_request(
|
# @api_validate_post_request(
|
||||||
# schema={"amount": {"type": "integer", "min": 1, "required": True}}
|
# schema={"amount": {"type": "integer", "min": 1, "required": True}}
|
||||||
# )
|
# )
|
||||||
async def api_tpos_create_invoice(amount: int = Query(..., ge=1), tpos_id: str):
|
async def api_tpos_create_invoice(amount: int = Query(..., ge=1), tpos_id: str = None):
|
||||||
tpos = await get_tpos(tpos_id)
|
tpos = await get_tpos(tpos_id)
|
||||||
|
|
||||||
if not tpos:
|
if not tpos:
|
||||||
@@ -76,7 +80,7 @@ async def api_tpos_create_invoice(amount: int = Query(..., ge=1), tpos_id: str):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return {"message": str(e)}, HTTPStatus.INTERNAL_SERVER_ERROR
|
return {"message": str(e)}, HTTPStatus.INTERNAL_SERVER_ERROR
|
||||||
|
|
||||||
return {"payment_hash": payment_hash, "payment_request": payment_request}), HTTPStatus.CREATED
|
return {"payment_hash": payment_hash, "payment_request": payment_request}, HTTPStatus.CREATED
|
||||||
|
|
||||||
|
|
||||||
@tpos_ext.get("/api/v1/tposs/{tpos_id}/invoices/{payment_hash}")
|
@tpos_ext.get("/api/v1/tposs/{tpos_id}/invoices/{payment_hash}")
|
||||||
|
@@ -24,15 +24,13 @@ from .crud import (
|
|||||||
###################WALLETS#############################
|
###################WALLETS#############################
|
||||||
|
|
||||||
|
|
||||||
@watchonly_ext.route("/api/v1/wallet", methods=["GET"])
|
@watchonly_ext.get("/api/v1/wallet")
|
||||||
@api_check_wallet_key("invoice")
|
@api_check_wallet_key("invoice")
|
||||||
async def api_wallets_retrieve():
|
async def api_wallets_retrieve():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return (
|
return (
|
||||||
jsonify(
|
[wallet._asdict() for wallet in await get_watch_wallets(g.wallet.user)],
|
||||||
[wallet._asdict() for wallet in await get_watch_wallets(g.wallet.user)]
|
|
||||||
),
|
|
||||||
HTTPStatus.OK,
|
HTTPStatus.OK,
|
||||||
)
|
)
|
||||||
except:
|
except:
|
||||||
|
Reference in New Issue
Block a user