diff options
| author | Florian Dold <florian@dold.me> | 2022-09-05 15:38:47 +0200 | 
|---|---|---|
| committer | Florian Dold <florian@dold.me> | 2022-09-05 15:38:47 +0200 | 
| commit | 43b893b8c4538f66b7f0161a85277e4db82bb192 (patch) | |
| tree | 7a8ae8a978b2f05e493bfe73c9ef5555bc8f9116 /packages/taler-wallet-core/src | |
| parent | b37fbdb59dc54794a96269aa432078abf36d3a09 (diff) | |
consider supported wire types when selecting coins
Also add an integration test to check for the correct wallet behavior.
Diffstat (limited to 'packages/taler-wallet-core/src')
| -rw-r--r-- | packages/taler-wallet-core/src/db.ts | 4 | ||||
| -rw-r--r-- | packages/taler-wallet-core/src/operations/pay.ts | 17 | 
2 files changed, 20 insertions, 1 deletions
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<string>(); +        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;  }  /**  | 
