aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/wallet.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/wallet.ts')
-rw-r--r--packages/taler-wallet-core/src/wallet.ts42
1 files changed, 42 insertions, 0 deletions
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
index 7a69fcb21..2a84d912d 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -103,6 +103,7 @@ import {
codecForGetBalanceDetailRequest,
codecForGetContractTermsDetails,
codecForGetCurrencyInfoRequest,
+ codecForGetDepositWireTypesForCurrencyRequest,
codecForGetExchangeEntryByUrlRequest,
codecForGetExchangeResourcesRequest,
codecForGetExchangeTosRequest,
@@ -215,6 +216,7 @@ import {
getExchangeDetailedInfo,
getExchangeResources,
getExchangeTos,
+ getExchangeWireDetailsInTx,
listExchanges,
lookupExchangeByUri,
} from "./exchanges.js";
@@ -1316,6 +1318,46 @@ async function dispatchRequestInternal(
const dbDump = await exportDb(wex.ws.idb);
return dbDump;
}
+ case WalletApiOperation.GetDepositWireTypesForCurrency: {
+ const req =
+ codecForGetDepositWireTypesForCurrencyRequest().decode(payload);
+ const wtSet: Set<string> = new Set();
+ await wex.db.runReadOnlyTx(
+ { storeNames: ["exchanges", "exchangeDetails"] },
+ async (tx) => {
+ const exchanges = await tx.exchanges.getAll();
+ for (const exchange of exchanges) {
+ const det = await getExchangeWireDetailsInTx(tx, exchange.baseUrl);
+ if (!det) {
+ continue;
+ }
+ if (det.currency !== req.currency) {
+ continue;
+ }
+ for (const acc of det.wireInfo.accounts) {
+ let usable = true;
+ for (const dr of acc.debit_restrictions) {
+ if (dr.type === "deny") {
+ usable = false;
+ break;
+ }
+ }
+ if (!usable) {
+ break;
+ }
+ const parsedPayto = parsePaytoUri(acc.payto_uri);
+ if (!parsedPayto) {
+ continue;
+ }
+ wtSet.add(parsedPayto.targetType);
+ }
+ }
+ },
+ );
+ return {
+ wireTypes: [...wtSet],
+ };
+ }
case WalletApiOperation.ListGlobalCurrencyExchanges: {
const resp: ListGlobalCurrencyExchangesResponse = {
exchanges: [],