taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 4144609f2619c558f642a1e4c847f6ceae1235f4
parent ebf29b9549b3c660111de409bf04fbd6102f9200
Author: Florian Dold <florian@dold.me>
Date:   Thu, 11 Dec 2025 12:40:57 +0100

wallet-core: new dev experiment for faking the exchange master public key

Diffstat:
Mpackages/taler-wallet-core/src/dev-experiments.ts | 18++++++++++++++++++
Mpackages/taler-wallet-core/src/exchanges.ts | 20++++++++++++++++++++
Mpackages/taler-wallet-core/src/wallet.ts | 9++++++++-
3 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/packages/taler-wallet-core/src/dev-experiments.ts b/packages/taler-wallet-core/src/dev-experiments.ts @@ -188,6 +188,24 @@ export async function applyDevExperiment( }); return; } + case "start-fakemasterpub": { + const baseUrl = parsedUri.query?.get("base_url"); + if (!baseUrl) { + throw Error("base_url required"); + } + const fakePub = parsedUri.query?.get("fake_pub"); + if (!fakePub) { + throw Error("fake_pub required"); + } + let fakeSt = wex.ws.devExperimentState.fakeMasterPub; + if (!fakeSt) { + fakeSt = wex.ws.devExperimentState.fakeMasterPub = new Map(); + } + fakeSt.set(baseUrl, { + fakeMasterPub: fakePub, + }); + return; + } case "rebuild-transactions": { await wex.db.runAllStoresReadWriteTx({}, async (tx) => { // Re-build / fix up info about exchanges for purchase transactions. diff --git a/packages/taler-wallet-core/src/exchanges.ts b/packages/taler-wallet-core/src/exchanges.ts @@ -1514,6 +1514,17 @@ export async function waitReadyExchange( if (!options.forceUpdate) { ready = true; } + if (retryInfo && !options.noBail) { + const reason = retryInfo?.lastError ?? exchange.unavailableReason; + if (reason) { + throw TalerError.fromUncheckedDetail(reason); + } else { + // Unlikely, but could happen. + throw Error( + "updating exchange failed, error code unavailable (internal error, check logs)", + ); + } + } break; case ExchangeEntryDbUpdateStatus.UnavailableUpdate: { if (!options.noBail) { @@ -1838,6 +1849,15 @@ export async function updateExchangeFromUrlHandler( ); } + { + const fakePub = + wex.ws.devExperimentState.fakeMasterPub?.get(exchangeBaseUrl); + if (fakePub) { + logger.warn("devexperiment: faking exchange pub"); + keysInfoRes.res.masterPublicKey = fakePub.fakeMasterPub; + } + } + const keysInfo = keysInfoRes.res; if (keysInfo.baseUrl != exchangeBaseUrl) { diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts @@ -256,7 +256,6 @@ import { codecForUserAttentionsRequest, codecForValidateIbanRequest, codecForWithdrawTestBalance, - constructIban, convertHUF_BBANtoIBAN, encodeCrock, getErrorDetailFromException, @@ -2939,6 +2938,14 @@ export interface DevExperimentState { } >; + /** Map from base URL to faked version for /config or /keys */ + fakeMasterPub?: Map< + string, + { + fakeMasterPub: string; + } + >; + fakeShoppingUrl?: string; flagDisablePeerPayments?: boolean;