aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-03-09 16:37:46 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-03-09 16:37:46 +0530
commit26d961ad633027f50ee402b9a7e7fa383c2b33c3 (patch)
treecfaa7a80d4c38980ddb62bd39ea61b3f87916688
parentbf1b350d4410cfc7c3e9ae3a717343c9ef19625a (diff)
support exchange API version 7:0:0
-rw-r--r--src/operations/exchanges.ts1
-rw-r--r--src/operations/refresh.ts19
-rw-r--r--src/operations/refund.ts2
-rw-r--r--src/operations/reserves.ts5
-rw-r--r--src/operations/versions.ts2
-rw-r--r--src/operations/withdraw.ts2
6 files changed, 21 insertions, 10 deletions
diff --git a/src/operations/exchanges.ts b/src/operations/exchanges.ts
index 89f89ec10..cf6b06868 100644
--- a/src/operations/exchanges.ts
+++ b/src/operations/exchanges.ts
@@ -77,6 +77,7 @@ async function setExchangeError(
baseUrl: string,
err: OperationError,
): Promise<void> {
+ console.log(`last error for exchange ${baseUrl}:`, err);
const mut = (exchange: ExchangeRecord) => {
exchange.lastError = err;
return exchange;
diff --git a/src/operations/refresh.ts b/src/operations/refresh.ts
index b53baf390..6dd16d61a 100644
--- a/src/operations/refresh.ts
+++ b/src/operations/refresh.ts
@@ -229,7 +229,10 @@ async function refreshMelt(
return;
}
- const reqUrl = new URL("refresh/melt", refreshSession.exchangeBaseUrl);
+ const reqUrl = new URL(
+ `coins/${coin.coinPub}/melt`,
+ refreshSession.exchangeBaseUrl,
+ );
const meltReq = {
coin_pub: coin.coinPub,
confirm_sig: refreshSession.confirmSig,
@@ -244,7 +247,10 @@ async function refreshMelt(
console.log(`got status ${resp.status} for refresh/melt`);
try {
const respJson = await resp.json();
- console.log(`body of refresh/melt error response:`, JSON.stringify(respJson, undefined, 2));
+ console.log(
+ `body of refresh/melt error response:`,
+ JSON.stringify(respJson, undefined, 2),
+ );
} catch (e) {
console.log(`body of refresh/melt error response is not JSON`);
}
@@ -344,7 +350,10 @@ async function refreshReveal(
link_sigs: linkSigs,
};
- const reqUrl = new URL("refresh/reveal", refreshSession.exchangeBaseUrl);
+ const reqUrl = new URL(
+ `refreshes/${refreshSession.hash}/reveal`,
+ refreshSession.exchangeBaseUrl,
+ );
logger.trace("reveal request:", req);
let resp;
@@ -523,7 +532,9 @@ async function processRefreshSession(
refreshGroupId: string,
coinIndex: number,
) {
- logger.trace(`processing refresh session for coin ${coinIndex} of group ${refreshGroupId}`);
+ logger.trace(
+ `processing refresh session for coin ${coinIndex} of group ${refreshGroupId}`,
+ );
let refreshGroup = await ws.db.get(Stores.refreshGroups, refreshGroupId);
if (!refreshGroup) {
return;
diff --git a/src/operations/refund.ts b/src/operations/refund.ts
index 2fb3a2390..9d1c5308e 100644
--- a/src/operations/refund.ts
+++ b/src/operations/refund.ts
@@ -423,7 +423,7 @@ async function processPurchaseApplyRefundImpl(
console.log("sending refund permission", perm);
// FIXME: not correct once we support multiple exchanges per payment
const exchangeUrl = purchase.payReq.coins[0].exchange_url;
- const reqUrl = new URL("refund", exchangeUrl);
+ const reqUrl = new URL(`coins/${perm.coin_pub}/refund`, exchangeUrl);
const resp = await ws.http.postJson(reqUrl.href, req);
console.log("sent refund permission");
switch (resp.status) {
diff --git a/src/operations/reserves.ts b/src/operations/reserves.ts
index 463b57b6c..1f9cc3053 100644
--- a/src/operations/reserves.ts
+++ b/src/operations/reserves.ts
@@ -402,12 +402,11 @@ async function updateReserve(
return;
}
- const reqUrl = new URL("reserve/status", reserve.exchangeBaseUrl);
- reqUrl.searchParams.set("reserve_pub", reservePub);
+ const reqUrl = new URL(`reserves/${reservePub}`, reserve.exchangeBaseUrl);
let resp;
try {
resp = await ws.http.get(reqUrl.href);
- console.log("got reserve/status response", await resp.json());
+ console.log("got reserves/${RESERVE_PUB} response", await resp.json());
if (resp.status === 404) {
const m = "reserve not known to the exchange yet"
throw new OperationFailedError(m, {
diff --git a/src/operations/versions.ts b/src/operations/versions.ts
index 393bdd887..6ac78f013 100644
--- a/src/operations/versions.ts
+++ b/src/operations/versions.ts
@@ -20,7 +20,7 @@
*
* Uses libtool's current:revision:age versioning.
*/
-export const WALLET_EXCHANGE_PROTOCOL_VERSION = "6";
+export const WALLET_EXCHANGE_PROTOCOL_VERSION = "7:0:0";
/**
* Cache breaker that is appended to queries such as /keys and /wire
diff --git a/src/operations/withdraw.ts b/src/operations/withdraw.ts
index 3a1f3cf06..0c58f5f2f 100644
--- a/src/operations/withdraw.ts
+++ b/src/operations/withdraw.ts
@@ -197,7 +197,7 @@ async function processPlanchet(
wd.reserve_pub = planchet.reservePub;
wd.reserve_sig = planchet.withdrawSig;
wd.coin_ev = planchet.coinEv;
- const reqUrl = new URL("reserve/withdraw", exchange.baseUrl).href;
+ const reqUrl = new URL(`reserves/${planchet.reservePub}/withdraw`, exchange.baseUrl).href;
const resp = await ws.http.postJson(reqUrl, wd);
if (resp.status !== 200) {
throw Error(`unexpected status ${resp.status} for withdraw`);