From 43b893b8c4538f66b7f0161a85277e4db82bb192 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 5 Sep 2022 15:38:47 +0200 Subject: consider supported wire types when selecting coins Also add an integration test to check for the correct wallet behavior. --- packages/taler-wallet-core/src/db.ts | 4 ++++ packages/taler-wallet-core/src/operations/pay.ts | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'packages/taler-wallet-core') diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index 903dfa47d..9c57a79c1 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -361,11 +361,15 @@ export interface ExchangeDetailsRecord { * Terms of service text or undefined if not downloaded yet. * * This is just used as a cache of the last downloaded ToS. + * + * FIXME: Put in separate object store! */ termsOfServiceText: string | undefined; /** * content-type of the last downloaded termsOfServiceText. + * + * * FIXME: Put in separate object store! */ termsOfServiceContentType: string | undefined; diff --git a/packages/taler-wallet-core/src/operations/pay.ts b/packages/taler-wallet-core/src/operations/pay.ts index d41a20e71..8193bf86a 100644 --- a/packages/taler-wallet-core/src/operations/pay.ts +++ b/packages/taler-wallet-core/src/operations/pay.ts @@ -47,6 +47,7 @@ import { j2s, Logger, NotificationType, + parsePaytoUri, parsePayUri, PayCoinSelection, PreparePayResult, @@ -241,6 +242,20 @@ export async function getCandidatePayCoins( continue; } + const wireTypes = new Set(); + for (const acc of exchangeDetails.wireInfo.accounts) { + const p = parsePaytoUri(acc.payto_uri); + if (p) { + wireTypes.add(p.targetType); + } + } + + if (!wireTypes.has(req.wireMethod)) { + // Exchange can't be used, because it doesn't support + // the wire type that the merchant requested. + continue; + } + // is the exchange explicitly allowed? for (const allowedExchange of req.allowedExchanges) { if (allowedExchange.exchangePub === exchangeDetails.masterPublicKey) { @@ -1338,7 +1353,7 @@ export async function getContractTermsDetails( throw Error("proposal is in invalid state"); } - return proposal.download.contractData + return proposal.download.contractData; } /** -- cgit v1.2.3