mirror of
https://github.com/mempool/mempool.git
synced 2026-08-18 13:08:44 +02:00
fix 404 response for missing wallet
This commit is contained in:
parent
8303f4df41
commit
77569a2531
2 changed files with 11 additions and 3 deletions
|
|
@ -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');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue