aboutsummaryrefslogtreecommitdiff
path: root/src/wallet-impl/withdraw.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-12-09 13:29:11 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-12-09 13:29:11 +0100
commit1fea75bca3951d39c0a45faf3e903fcec77f9c4f (patch)
tree8d582e26a7e583871e0c9c223976e67b93ef2059 /src/wallet-impl/withdraw.ts
parent396bb61db70f654599256e512bfec4c008ee8269 (diff)
throttling / allow non-json requests
Diffstat (limited to 'src/wallet-impl/withdraw.ts')
-rw-r--r--src/wallet-impl/withdraw.ts13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/wallet-impl/withdraw.ts b/src/wallet-impl/withdraw.ts
index 96055c9c5..cd3989972 100644
--- a/src/wallet-impl/withdraw.ts
+++ b/src/wallet-impl/withdraw.ts
@@ -117,8 +117,12 @@ export async function getWithdrawalInfo(
throw Error("can't parse URL");
}
const resp = await ws.http.get(uriResult.statusUrl);
- console.log("resp:", resp.responseJson);
- const status = WithdrawOperationStatusResponse.checked(resp.responseJson);
+ if (resp.status !== 200) {
+ throw Error(`unexpected status (${resp.status}) from bank for ${uriResult.statusUrl}`);
+ }
+ const respJson = await resp.json();
+ console.log("resp:", respJson);
+ const status = WithdrawOperationStatusResponse.checked(respJson);
return {
amount: Amounts.parseOrThrow(status.amount),
confirmTransferUrl: status.confirm_transfer_url,
@@ -228,8 +232,11 @@ async function processPlanchet(
wd.coin_ev = planchet.coinEv;
const reqUrl = new URL("reserve/withdraw", exchange.baseUrl).href;
const resp = await ws.http.postJson(reqUrl, wd);
+ if (resp.status !== 200) {
+ throw Error(`unexpected status ${resp.status} for withdraw`);
+ }
- const r = resp.responseJson;
+ const r = await resp.json();
const denomSig = await ws.cryptoApi.rsaUnblind(
r.ev_sig,