summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/exchanges.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/operations/exchanges.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/exchanges.ts19
1 files changed, 18 insertions, 1 deletions
diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts b/packages/taler-wallet-core/src/operations/exchanges.ts
index 69f708364..bf7d4424a 100644
--- a/packages/taler-wallet-core/src/operations/exchanges.ts
+++ b/packages/taler-wallet-core/src/operations/exchanges.ts
@@ -821,6 +821,10 @@ export async function waitExchangeEntryUpdated(
*
* If an exchange entry for the database doesn't exist in the
* DB, it will be added ephemerally.
+ *
+ * If the expectedMasterPub is given and does not match the actual
+ * master pub, an exception will be thrown. However, the exchange
+ * will still have been added as an ephemeral exchange entry.
*/
export async function fetchFreshExchange(
ws: InternalWalletState,
@@ -828,6 +832,7 @@ export async function fetchFreshExchange(
options: {
cancellationToken?: CancellationToken;
forceUpdate?: boolean;
+ expectedMasterPub?: string;
} = {},
): Promise<{
exchange: ExchangeEntryRecord;
@@ -837,7 +842,19 @@ export async function fetchFreshExchange(
await startUpdateExchangeEntry(ws, canonUrl, {
forceUpdate: options.forceUpdate,
});
- return waitExchangeEntryUpdated(ws, canonUrl, options.cancellationToken);
+ const res = await waitExchangeEntryUpdated(
+ ws,
+ canonUrl,
+ options.cancellationToken,
+ );
+ if (options.expectedMasterPub) {
+ if (res.exchangeDetails.masterPublicKey !== options.expectedMasterPub) {
+ throw Error(
+ "public key of the exchange does not match expected public key",
+ );
+ }
+ }
+ return res;
}
/**