abort exchange update if version does not match
This commit is contained in:
parent
7ba1f91823
commit
bf1b350d44
@ -39,8 +39,12 @@ import {
|
|||||||
OperationFailedAndReportedError,
|
OperationFailedAndReportedError,
|
||||||
guardOperationException,
|
guardOperationException,
|
||||||
} from "./errors";
|
} from "./errors";
|
||||||
import { WALLET_CACHE_BREAKER_CLIENT_VERSION } from "./versions";
|
import {
|
||||||
|
WALLET_CACHE_BREAKER_CLIENT_VERSION,
|
||||||
|
WALLET_EXCHANGE_PROTOCOL_VERSION,
|
||||||
|
} from "./versions";
|
||||||
import { getTimestampNow } from "../util/time";
|
import { getTimestampNow } from "../util/time";
|
||||||
|
import { compare } from "../util/libtoolVersion";
|
||||||
|
|
||||||
async function denominationRecordFromKeys(
|
async function denominationRecordFromKeys(
|
||||||
ws: InternalWalletState,
|
ws: InternalWalletState,
|
||||||
@ -161,6 +165,20 @@ async function updateExchangeWithKeys(
|
|||||||
throw new OperationFailedAndReportedError(m);
|
throw new OperationFailedAndReportedError(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const versionRes = compare(WALLET_EXCHANGE_PROTOCOL_VERSION, protocolVersion);
|
||||||
|
if (versionRes?.compatible != true) {
|
||||||
|
const m = "exchange protocol version not compatible with wallet";
|
||||||
|
await setExchangeError(ws, baseUrl, {
|
||||||
|
type: "protocol-incompatible",
|
||||||
|
details: {
|
||||||
|
exchangeProtocolVersion: protocolVersion,
|
||||||
|
walletProtocolVersion: WALLET_EXCHANGE_PROTOCOL_VERSION,
|
||||||
|
},
|
||||||
|
message: m,
|
||||||
|
});
|
||||||
|
throw new OperationFailedAndReportedError(m);
|
||||||
|
}
|
||||||
|
|
||||||
const currency = Amounts.parseOrThrow(exchangeKeysJson.denoms[0].value)
|
const currency = Amounts.parseOrThrow(exchangeKeysJson.denoms[0].value)
|
||||||
.currency;
|
.currency;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user