wallet-core: always use batch withdrawal
This commit is contained in:
parent
b9f908db58
commit
0a05f6d903
@ -68,7 +68,6 @@ export async function runBench1(configJson: any): Promise<void> {
|
||||
} 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<void> {
|
||||
testing: {
|
||||
insecureTrustExchange: trustExchange,
|
||||
},
|
||||
features: {
|
||||
batchWithdrawal,
|
||||
},
|
||||
features: {},
|
||||
},
|
||||
});
|
||||
wallet = res.wallet;
|
||||
|
@ -76,8 +76,6 @@ export async function runBench3(configJson: any): Promise<void> {
|
||||
} 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<void> {
|
||||
persistentStoragePath: undefined,
|
||||
httpLib: myHttpLib,
|
||||
config: {
|
||||
features: {
|
||||
batchWithdrawal,
|
||||
},
|
||||
features: {},
|
||||
testing: {
|
||||
insecureTrustExchange: trustExchange,
|
||||
},
|
||||
|
@ -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,
|
||||
|
@ -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"),
|
||||
|
@ -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<void>[] = [];
|
||||
work = [];
|
||||
|
@ -272,7 +272,6 @@ export interface WalletConfig {
|
||||
* Configurations values that may be safe to show to the user
|
||||
*/
|
||||
features: {
|
||||
batchWithdrawal: boolean;
|
||||
allowHttp: boolean;
|
||||
};
|
||||
}
|
||||
|
@ -1696,7 +1696,6 @@ export class Wallet {
|
||||
],
|
||||
},
|
||||
features: {
|
||||
batchWithdrawal: false,
|
||||
allowHttp: false,
|
||||
},
|
||||
testing: {
|
||||
|
@ -34,7 +34,6 @@ function parse_json_or_undefined<T>(str: string | undefined): T | undefined {
|
||||
export const codecForSettings = (): Codec<Settings> =>
|
||||
buildCodecForObject<Settings>()
|
||||
.property("walletAllowHttp", codecForBoolean())
|
||||
.property("walletBatchWithdrawal", codecForBoolean())
|
||||
.property("injectTalerSupport", codecForBoolean())
|
||||
.property("advanceMode", codecForBoolean())
|
||||
.property("backup", codecForBoolean())
|
||||
|
@ -119,7 +119,6 @@ export const defaultSettings: Settings = {
|
||||
showJsonOnError: false,
|
||||
extendedAccountTypes: false,
|
||||
walletAllowHttp: false,
|
||||
walletBatchWithdrawal: false,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -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.`,
|
||||
|
@ -332,7 +332,6 @@ async function reinitWallet(): Promise<void> {
|
||||
{
|
||||
features: {
|
||||
allowHttp: settings.walletAllowHttp,
|
||||
batchWithdrawal: settings.walletBatchWithdrawal,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user