mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-02-23 14:40:47 +01:00
Merge pull request #1235 from motorina0/fix_wallet_deleted_for_charge
fix: onchain wallet deleted for charge
This commit is contained in:
commit
b655b9959d
2 changed files with 15 additions and 7 deletions
|
@ -24,6 +24,8 @@ async def create_charge(user: str, data: CreateCharge) -> Charges:
|
||||||
{"mempool_endpoint": config.mempool_endpoint, "network": config.network}
|
{"mempool_endpoint": config.mempool_endpoint, "network": config.network}
|
||||||
)
|
)
|
||||||
onchain = await get_fresh_address(data.onchainwallet)
|
onchain = await get_fresh_address(data.onchainwallet)
|
||||||
|
if not onchain:
|
||||||
|
raise Exception(f"Wallet '{data.onchainwallet}' can no longer be accessed.")
|
||||||
onchainaddress = onchain.address
|
onchainaddress = onchain.address
|
||||||
else:
|
else:
|
||||||
onchainaddress = None
|
onchainaddress = None
|
||||||
|
|
|
@ -37,13 +37,19 @@ from .models import CreateCharge, SatsPayThemes
|
||||||
async def api_charge_create(
|
async def api_charge_create(
|
||||||
data: CreateCharge, wallet: WalletTypeInfo = Depends(require_invoice_key)
|
data: CreateCharge, wallet: WalletTypeInfo = Depends(require_invoice_key)
|
||||||
):
|
):
|
||||||
charge = await create_charge(user=wallet.wallet.user, data=data)
|
try:
|
||||||
return {
|
charge = await create_charge(user=wallet.wallet.user, data=data)
|
||||||
**charge.dict(),
|
return {
|
||||||
**{"time_elapsed": charge.time_elapsed},
|
**charge.dict(),
|
||||||
**{"time_left": charge.time_left},
|
**{"time_elapsed": charge.time_elapsed},
|
||||||
**{"paid": charge.paid},
|
**{"time_left": charge.time_left},
|
||||||
}
|
**{"paid": charge.paid},
|
||||||
|
}
|
||||||
|
except Exception as ex:
|
||||||
|
logger.debug(f"Satspay error: {str}")
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=HTTPStatus.INTERNAL_SERVER_ERROR, detail=str(ex)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@satspay_ext.put("/api/v1/charge/{charge_id}")
|
@satspay_ext.put("/api/v1/charge/{charge_id}")
|
||||||
|
|
Loading…
Add table
Reference in a new issue