diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-12-09 13:29:11 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-12-09 13:29:11 +0100 |
commit | 1fea75bca3951d39c0a45faf3e903fcec77f9c4f (patch) | |
tree | 8d582e26a7e583871e0c9c223976e67b93ef2059 /src/wallet-impl/tip.ts | |
parent | 396bb61db70f654599256e512bfec4c008ee8269 (diff) | |
download | wallet-core-1fea75bca3951d39c0a45faf3e903fcec77f9c4f.tar.xz |
throttling / allow non-json requests
Diffstat (limited to 'src/wallet-impl/tip.ts')
-rw-r--r-- | src/wallet-impl/tip.ts | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/wallet-impl/tip.ts b/src/wallet-impl/tip.ts index e11eb3b42..41463ab18 100644 --- a/src/wallet-impl/tip.ts +++ b/src/wallet-impl/tip.ts @@ -41,10 +41,12 @@ export async function getTipStatus( tipStatusUrl.searchParams.set("tip_id", res.merchantTipId); console.log("checking tip status from", tipStatusUrl.href); const merchantResp = await ws.http.get(tipStatusUrl.href); - console.log("resp:", merchantResp.responseJson); - const tipPickupStatus = TipPickupGetResponse.checked( - merchantResp.responseJson, - ); + if (merchantResp.status !== 200) { + throw Error(`unexpected status ${merchantResp.status} for tip-pickup`); + } + const respJson = await merchantResp.json(); + console.log("resp:", respJson); + const tipPickupStatus = TipPickupGetResponse.checked(respJson); console.log("status", tipPickupStatus); @@ -208,13 +210,16 @@ async function processTipImpl( try { const req = { planchets: planchetsDetail, tip_id: tipRecord.merchantTipId }; merchantResp = await ws.http.postJson(tipStatusUrl.href, req); + if (merchantResp.status !== 200) { + throw Error(`unexpected status ${merchantResp.status} for tip-pickup`); + } console.log("got merchant resp:", merchantResp); } catch (e) { console.log("tipping failed", e); throw e; } - const response = TipResponse.checked(merchantResp.responseJson); + const response = TipResponse.checked(await merchantResp.json()); if (response.reserve_sigs.length !== tipRecord.planchets.length) { throw Error("number of tip responses does not match requested planchets"); |