fix: onchain wallet deleted for charge

This commit is contained in:
Vlad Stan 2022-12-23 22:15:32 +02:00
parent d0ed93aec8
commit 8a447ecc4f
2 changed files with 14 additions and 7 deletions

View File

@ -24,6 +24,8 @@ async def create_charge(user: str, data: CreateCharge) -> Charges:
{"mempool_endpoint": config.mempool_endpoint, "network": config.network}
)
onchain = await get_fresh_address(data.onchainwallet)
if not onchain:
raise Exception(f"Wallet '{data.onchainwallet}' can no longer be accessed.")
onchainaddress = onchain.address
else:
onchainaddress = None

View File

@ -37,13 +37,18 @@ from .models import CreateCharge, SatsPayThemes
async def api_charge_create(
data: CreateCharge, wallet: WalletTypeInfo = Depends(require_invoice_key)
):
charge = await create_charge(user=wallet.wallet.user, data=data)
return {
**charge.dict(),
**{"time_elapsed": charge.time_elapsed},
**{"time_left": charge.time_left},
**{"paid": charge.paid},
}
try:
charge = await create_charge(user=wallet.wallet.user, data=data)
return {
**charge.dict(),
**{"time_elapsed": charge.time_elapsed},
**{"time_left": charge.time_left},
**{"paid": charge.paid},
}
except Exception as ex:
raise HTTPException(
status_code=HTTPStatus.INTERNAL_SERVER_ERROR, detail=str(ex)
)
@satspay_ext.put("/api/v1/charge/{charge_id}")