commit 7ff6ebfe8e2300ae720587f192922c70f7c38377
parent 9c684ecde01f11b9d1721c1c31b63e202b9d8ba1
Author: Florian Dold <dold@taler.net>
Date: Tue, 24 Nov 2026 14:24:14 +0100
wallet-core: load exchange keys when opening a peer invoice
The invoice can be the payer’s first contact with the exchange. Fetch
its keys before requesting purse status so the wallet can authenticate
the reply and proceed to coin selection.
Issue: https://bugs.taler.net/n/12166
Diffstat:
2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/packages/taler-harness/src/integrationtests/test-peer-pull.ts b/packages/taler-harness/src/integrationtests/test-peer-pull.ts
@@ -18,6 +18,7 @@ import {
AbsoluteTime,
AmountString,
Duration,
+ ExchangeUpdateStatus,
TalerErrorCode,
TalerProtocolTimestamp,
TransactionMajorState,
@@ -182,14 +183,31 @@ export async function runPeerPullTest(t: GlobalTestState) {
}
const tx = await initPeerPullCredit("confirm", "TESTKUDOS:1000");
- const insufficient_balance = await t.assertThrowsTalerErrorAsync(async () =>
- wallet1.call(WalletApiOperation.PreparePeerPullDebit, {
- talerUri: tx.talerUri!,
- }),
+ const { walletClient: freshWallet } = await createWalletDaemonWithClient(
+ t,
+ {
+ name: "first-contact",
+ },
);
- t.assertTrue(
- insufficient_balance.errorDetail.code ===
+ for (const payer of [wallet1, freshWallet]) {
+ const error = await t.assertThrowsTalerErrorAsync(() =>
+ payer.call(WalletApiOperation.PreparePeerPullDebit, {
+ talerUri: tx.talerUri!,
+ }),
+ );
+ t.assertDeepEqual(
+ error.errorDetail.code,
TalerErrorCode.WALLET_PEER_PULL_PAYMENT_INSUFFICIENT_BALANCE,
+ );
+ }
+ const { exchanges } = await freshWallet.call(
+ WalletApiOperation.ListExchanges,
+ {},
+ );
+ t.assertDeepEqual(
+ exchanges.find((e) => e.exchangeBaseUrl === exchange.baseUrl)
+ ?.exchangeUpdateStatus,
+ ExchangeUpdateStatus.Ready,
);
const unknown_purse = await t.assertThrowsTalerErrorAsync(async () =>
diff --git a/packages/taler-wallet-core/src/pay-peer-pull-debit.ts b/packages/taler-wallet-core/src/pay-peer-pull-debit.ts
@@ -84,6 +84,7 @@ import {
timestampPreciseToDb,
} from "./db/records.js";
import {
+ fetchFreshExchangeWithRetryNow,
getExchangeScopeInfo,
getLegacyScopesForTransaction,
getScopeForAllExchanges,
@@ -1498,6 +1499,9 @@ async function internalPreparePeerPullDebit(
const contractTermsHash = ContractTermsUtil.hashContractTerms(contractTerms);
+ // Opening this invoice can be the wallet's first contact with the exchange.
+ await fetchFreshExchangeWithRetryNow(wex, exchangeBaseUrl);
+
// FIXME: Authenticate the target and contract hash before spending once the
// exchange supplies signed purse metadata on GET. See issue #11828.