fix 404 response for missing wallet

This commit is contained in:
Mononaut 2025-03-31 07:39:34 +00:00
parent 8303f4df41
commit 77569a2531
No known key found for this signature in database
GPG key ID: A3F058E41374C04E
2 changed files with 11 additions and 3 deletions

View file

@ -17,7 +17,11 @@ class ServicesRoutes {
res.setHeader('Expires', new Date(Date.now() + 1000 * 5).toUTCString());
const walletId = req.params.walletId;
const wallet = await WalletApi.getWallet(walletId);
res.status(200).send(wallet);
if (wallet === null) {
res.status(404).send('No such wallet');
} else {
res.status(200).send(wallet);
}
} catch (e) {
handleError(req, res, 500, 'Failed to get wallet');
}

View file

@ -118,8 +118,12 @@ class WalletApi {
}
}
public getWallet(wallet: string): Record<string, WalletAddress> {
return this.wallets?.[wallet]?.addresses || {};
public getWallet(wallet: string): Record<string, WalletAddress> | null {
if (wallet in this.wallets) {
return this.wallets?.[wallet]?.addresses || {};
} else {
return null;
}
}
// resync wallet addresses from the services backend