From 0a05f6d9030b5a2ce201a98553fa4e6ff13eb907 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 22 Aug 2023 16:37:27 +0200 Subject: [PATCH] wallet-core: always use batch withdrawal --- packages/taler-harness/src/bench1.ts | 5 +- packages/taler-harness/src/bench3.ts | 6 +- .../src/integrationtests/testrunner.ts | 2 + packages/taler-wallet-cli/src/index.ts | 1 - .../src/operations/withdraw.ts | 55 ------------------- .../taler-wallet-core/src/wallet-api-types.ts | 1 - packages/taler-wallet-core/src/wallet.ts | 1 - .../src/hooks/useSettings.ts | 1 - .../src/platform/api.ts | 1 - .../src/wallet/Settings.tsx | 4 -- .../src/wxBackend.ts | 1 - 11 files changed, 4 insertions(+), 74 deletions(-) diff --git a/packages/taler-harness/src/bench1.ts b/packages/taler-harness/src/bench1.ts index fb7cc9e1f..6aa444e0a 100644 --- a/packages/taler-harness/src/bench1.ts +++ b/packages/taler-harness/src/bench1.ts @@ -68,7 +68,6 @@ export async function runBench1(configJson: any): Promise { } else { logger.info("not trusting exchange (validating signatures)"); } - const batchWithdrawal = !!process.env["TALER_WALLET_BATCH_WITHDRAWAL"]; let wallet = {} as Wallet; let getDbStats: () => AccessStats; @@ -91,9 +90,7 @@ export async function runBench1(configJson: any): Promise { testing: { insecureTrustExchange: trustExchange, }, - features: { - batchWithdrawal, - }, + features: {}, }, }); wallet = res.wallet; diff --git a/packages/taler-harness/src/bench3.ts b/packages/taler-harness/src/bench3.ts index ffafc75d2..c7eca90a8 100644 --- a/packages/taler-harness/src/bench3.ts +++ b/packages/taler-harness/src/bench3.ts @@ -76,8 +76,6 @@ export async function runBench3(configJson: any): Promise { } else { logger.info("not trusting exchange (validating signatures)"); } - const batchWithdrawal = !!process.env["TALER_WALLET_BATCH_WITHDRAWAL"]; - let wallet = {} as Wallet; let getDbStats: () => AccessStats; @@ -96,9 +94,7 @@ export async function runBench3(configJson: any): Promise { persistentStoragePath: undefined, httpLib: myHttpLib, config: { - features: { - batchWithdrawal, - }, + features: {}, testing: { insecureTrustExchange: trustExchange, }, diff --git a/packages/taler-harness/src/integrationtests/testrunner.ts b/packages/taler-harness/src/integrationtests/testrunner.ts index 67572f0f7..58e2a20f7 100644 --- a/packages/taler-harness/src/integrationtests/testrunner.ts +++ b/packages/taler-harness/src/integrationtests/testrunner.ts @@ -103,6 +103,7 @@ import { runPaymentTemplateTest } from "./test-payment-template.js"; import { runExchangeDepositTest } from "./test-exchange-deposit.js"; import { runPeerRepairTest } from "./test-peer-repair.js"; import { runPaymentShareTest } from "./test-payment-share.js"; +import { runSimplePaymentTest } from "./test-simple-payment.js"; /** * Test runner. @@ -129,6 +130,7 @@ const allTests: TestMainFunction[] = [ runClauseSchnorrTest, runDenomUnofferedTest, runDepositTest, + runSimplePaymentTest, runExchangeManagementTest, runExchangeTimetravelTest, runFeeRegressionTest, diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts index e2787db66..9d840e5bb 100644 --- a/packages/taler-wallet-cli/src/index.ts +++ b/packages/taler-wallet-cli/src/index.ts @@ -258,7 +258,6 @@ async function createLocalWallet( cryptoWorkerType: walletCliArgs.wallet.cryptoWorker as any, config: { features: { - batchWithdrawal: checkEnvFlag("TALER_WALLET_BATCH_WITHDRAWAL"), }, testing: { devModeActive: checkEnvFlag("TALER_WALLET_DEV_MODE"), diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts index a1cb29e07..673129928 100644 --- a/packages/taler-wallet-core/src/operations/withdraw.ts +++ b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -710,12 +710,6 @@ async function processPlanchetGenerate( } interface WithdrawalRequestBatchArgs { - /** - * Use the batched request on the network level. - * Not supported by older exchanges. - */ - useBatchRequest: boolean; - coinStartIndex: number; batchSize: number; @@ -923,7 +917,6 @@ async function processPlanchetExchangeBatchRequest( // FIXME: handle individual error codes better! - if (args.useBatchRequest) { const reqUrl = new URL( `reserves/${withdrawalGroup.reservePub}/batch-withdraw`, withdrawalGroup.exchangeBaseUrl, @@ -949,53 +942,6 @@ async function processPlanchetExchangeBatchRequest( coinIdxs: [], }; } - } else { - // We emulate the batch response here by making multiple individual requests - const responses: ExchangeWithdrawBatchResponse = { - ev_sigs: [], - }; - const responseCoinIdxs: number[] = []; - for (let i = 0; i < batchReq.planchets.length; i++) { - try { - const p = batchReq.planchets[i]; - const reqUrl = new URL( - `reserves/${withdrawalGroup.reservePub}/withdraw`, - withdrawalGroup.exchangeBaseUrl, - ).href; - const resp = await ws.http.fetch(reqUrl, { method: "POST", body: p }); - if (resp.status === HttpStatusCode.UnavailableForLegalReasons) { - await handleKycRequired( - ws, - withdrawalGroup, - resp, - i, - requestCoinIdxs, - ); - // We still return blinded coins that we could actually withdraw. - return { - coinIdxs: responseCoinIdxs, - batchResp: responses, - }; - } - const r = await readSuccessResponseJsonOrThrow( - resp, - codecForWithdrawResponse(), - ); - responses.ev_sigs.push(r); - responseCoinIdxs.push(requestCoinIdxs[i]); - } catch (e) { - if (e instanceof TalerError) { - logger.warn(`withdrawing planchet failed: ${j2s(e.errorDetail)}`); - logger.warn(`planchet denom pub hash: ${batchReq.planchets[i].denom_pub_hash}`); - } - await storeCoinError(e, requestCoinIdxs[i]); - } - } - return { - coinIdxs: responseCoinIdxs, - batchResp: responses, - }; - } } async function processPlanchetVerifyAndStoreCoin( @@ -1548,7 +1494,6 @@ async function processWithdrawalGroupPendingReady( const resp = await processPlanchetExchangeBatchRequest(ws, wgContext, { batchSize: maxBatchSize, coinStartIndex: i, - useBatchRequest: ws.config.features.batchWithdrawal, }); let work: Promise[] = []; work = []; diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts index 36c4809af..2a7c96ad1 100644 --- a/packages/taler-wallet-core/src/wallet-api-types.ts +++ b/packages/taler-wallet-core/src/wallet-api-types.ts @@ -272,7 +272,6 @@ export interface WalletConfig { * Configurations values that may be safe to show to the user */ features: { - batchWithdrawal: boolean; allowHttp: boolean; }; } diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index 8cd9bb8c3..b967571d0 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -1696,7 +1696,6 @@ export class Wallet { ], }, features: { - batchWithdrawal: false, allowHttp: false, }, testing: { diff --git a/packages/taler-wallet-webextension/src/hooks/useSettings.ts b/packages/taler-wallet-webextension/src/hooks/useSettings.ts index 5c1ed7924..7332c15bb 100644 --- a/packages/taler-wallet-webextension/src/hooks/useSettings.ts +++ b/packages/taler-wallet-webextension/src/hooks/useSettings.ts @@ -34,7 +34,6 @@ function parse_json_or_undefined(str: string | undefined): T | undefined { export const codecForSettings = (): Codec => buildCodecForObject() .property("walletAllowHttp", codecForBoolean()) - .property("walletBatchWithdrawal", codecForBoolean()) .property("injectTalerSupport", codecForBoolean()) .property("advanceMode", codecForBoolean()) .property("backup", codecForBoolean()) diff --git a/packages/taler-wallet-webextension/src/platform/api.ts b/packages/taler-wallet-webextension/src/platform/api.ts index 2537b16c2..ae57b8faf 100644 --- a/packages/taler-wallet-webextension/src/platform/api.ts +++ b/packages/taler-wallet-webextension/src/platform/api.ts @@ -119,7 +119,6 @@ export const defaultSettings: Settings = { showJsonOnError: false, extendedAccountTypes: false, walletAllowHttp: false, - walletBatchWithdrawal: false, }; /** diff --git a/packages/taler-wallet-webextension/src/wallet/Settings.tsx b/packages/taler-wallet-webextension/src/wallet/Settings.tsx index 4098fd55b..071d2a594 100644 --- a/packages/taler-wallet-webextension/src/wallet/Settings.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Settings.tsx @@ -316,10 +316,6 @@ function AdvanceSettings(): VNode { label: i18n.str`Allow HTTP connections`, description: i18n.str`Using HTTP connection may be faster but unsafe (wallet restart required)`, }, - walletBatchWithdrawal: { - label: i18n.str`Allow batch withdrawals`, - description: i18n.str`Using the batch withdrawal API allows faster withdrawals (wallet restart required)`, - }, langSelector: { label: i18n.str`Lang selector`, description: i18n.str`Allows to manually change the language of the UI. Otherwise it will be automatically selected by your browser configuration.`, diff --git a/packages/taler-wallet-webextension/src/wxBackend.ts b/packages/taler-wallet-webextension/src/wxBackend.ts index dfdb1b0d5..95af1a3a4 100644 --- a/packages/taler-wallet-webextension/src/wxBackend.ts +++ b/packages/taler-wallet-webextension/src/wxBackend.ts @@ -332,7 +332,6 @@ async function reinitWallet(): Promise { { features: { allowHttp: settings.walletAllowHttp, - batchWithdrawal: settings.walletBatchWithdrawal, }, }, );