aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/exchanges.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-12-08 16:23:00 +0100
committerFlorian Dold <florian@dold.me>2021-12-08 16:23:00 +0100
commit684c53e105e2d4b4e07811423e409ff4735e7297 (patch)
tree1497074e01b101d106ecfb8195f67fe45fc84c21 /packages/taler-wallet-core/src/operations/exchanges.ts
parent09aeaf753af3234462d42c1cc96037e726312a81 (diff)
downloadwallet-core-684c53e105e2d4b4e07811423e409ff4735e7297.tar.xz
wallet-core: trust exchange for exchange benchmark
Diffstat (limited to 'packages/taler-wallet-core/src/operations/exchanges.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/exchanges.ts46
1 files changed, 28 insertions, 18 deletions
diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts b/packages/taler-wallet-core/src/operations/exchanges.ts
index 16e37fd3e..987031810 100644
--- a/packages/taler-wallet-core/src/operations/exchanges.ts
+++ b/packages/taler-wallet-core/src/operations/exchanges.ts
@@ -218,19 +218,24 @@ export async function acceptExchangeTermsOfService(
}
async function validateWireInfo(
+ ws: InternalWalletState,
versionCurrent: number,
wireInfo: ExchangeWireJson,
masterPublicKey: string,
- cryptoApi: CryptoApi,
): Promise<WireInfo> {
for (const a of wireInfo.accounts) {
logger.trace("validating exchange acct");
- const isValid = await cryptoApi.isValidWireAccount(
- versionCurrent,
- a.payto_uri,
- a.master_sig,
- masterPublicKey,
- );
+ let isValid = false;
+ if (ws.insecureTrustExchange) {
+ isValid = true;
+ } else {
+ isValid = await ws.cryptoApi.isValidWireAccount(
+ versionCurrent,
+ a.payto_uri,
+ a.master_sig,
+ masterPublicKey,
+ );
+ }
if (!isValid) {
throw Error("exchange acct signature invalid");
}
@@ -248,11 +253,16 @@ async function validateWireInfo(
startStamp,
wireFee: Amounts.parseOrThrow(x.wire_fee),
};
- const isValid = await cryptoApi.isValidWireFee(
- wireMethod,
- fee,
- masterPublicKey,
- );
+ let isValid = false;
+ if (ws.insecureTrustExchange) {
+ isValid = true;
+ } else {
+ isValid = await ws.cryptoApi.isValidWireFee(
+ wireMethod,
+ fee,
+ masterPublicKey,
+ );
+ }
if (!isValid) {
throw Error("exchange wire fee signature invalid");
}
@@ -488,10 +498,10 @@ async function updateExchangeFromUrlImpl(
}
const wireInfo = await validateWireInfo(
+ ws,
version.current,
wireInfoDownload,
keysInfo.masterPublicKey,
- ws.cryptoApi,
);
logger.info("finished validating exchange /wire info");
@@ -516,11 +526,11 @@ async function updateExchangeFromUrlImpl(
tosFound !== undefined
? tosFound
: await downloadExchangeWithTermsOfService(
- baseUrl,
- ws.http,
- timeout,
- "text/plain",
- );
+ baseUrl,
+ ws.http,
+ timeout,
+ "text/plain",
+ );
let recoupGroupId: string | undefined = undefined;