diff options
Diffstat (limited to 'packages/taler-wallet-core/src/operations')
-rw-r--r-- | packages/taler-wallet-core/src/operations/balance.ts | 50 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/deposits.ts | 1 |
2 files changed, 42 insertions, 9 deletions
diff --git a/packages/taler-wallet-core/src/operations/balance.ts b/packages/taler-wallet-core/src/operations/balance.ts index 27b801804..50613d0aa 100644 --- a/packages/taler-wallet-core/src/operations/balance.ts +++ b/packages/taler-wallet-core/src/operations/balance.ts @@ -48,14 +48,12 @@ */ import { AmountJson, - BalancesResponse, Amounts, - Logger, - AuditorHandle, - ExchangeHandle, + BalancesResponse, canonicalizeBaseUrl, + GetBalanceDetailRequest, + Logger, parsePaytoUri, - TalerErrorCode, } from "@gnu-taler/taler-util"; import { AllowedAuditorInfo, @@ -63,11 +61,10 @@ import { RefreshGroupRecord, WalletStoresV1, } from "../db.js"; -import { GetReadOnlyAccess } from "../util/query.js"; import { InternalWalletState } from "../internal-wallet-state.js"; -import { getExchangeDetails } from "./exchanges.js"; import { checkLogicInvariant } from "../util/invariants.js"; -import { TalerError } from "../errors.js"; +import { GetReadOnlyAccess } from "../util/query.js"; +import { getExchangeDetails } from "./exchanges.js"; /** * Logger. @@ -429,6 +426,43 @@ export async function getMerchantPaymentBalanceDetails( return d; } +export async function getBalanceDetail( + ws: InternalWalletState, + req: GetBalanceDetailRequest, +): Promise<MerchantPaymentBalanceDetails> { + const exchanges: { exchangeBaseUrl: string; exchangePub: string }[] = []; + const wires = new Array<string>(); + await ws.db + .mktx((x) => [x.exchanges, x.exchangeDetails]) + .runReadOnly(async (tx) => { + const allExchanges = await tx.exchanges.iter().toArray(); + for (const e of allExchanges) { + const details = await getExchangeDetails(tx, e.baseUrl); + if (!details || req.currency !== details.currency) { + continue; + } + details.wireInfo.accounts.forEach((a) => { + const payto = parsePaytoUri(a.payto_uri); + if (payto && !wires.includes(payto.targetType)) { + wires.push(payto.targetType); + } + }); + exchanges.push({ + exchangePub: details.masterPublicKey, + exchangeBaseUrl: e.baseUrl, + }); + } + }); + + return await getMerchantPaymentBalanceDetails(ws, { + currency: req.currency, + acceptedAuditors: [], + acceptedExchanges: exchanges, + acceptedWireMethods: wires, + minAge: 0, + }); +} + export interface PeerPaymentRestrictionsForBalance { currency: string; restrictExchangeTo?: string; diff --git a/packages/taler-wallet-core/src/operations/deposits.ts b/packages/taler-wallet-core/src/operations/deposits.ts index f3ec81686..e97738b55 100644 --- a/packages/taler-wallet-core/src/operations/deposits.ts +++ b/packages/taler-wallet-core/src/operations/deposits.ts @@ -457,7 +457,6 @@ export async function prepareDepositGroup( }; } - export async function createDepositGroup( ws: InternalWalletState, req: CreateDepositGroupRequest, |