taler-typescript-core

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

commit 97c435dd720a1d45118e566368711c14e5da14f3
parent f0aa4d7173ec0f3afda622d916a9913314223a95
Author: Florian Dold <dold@taler.net>
Date:   Wed, 25 Nov 2026 18:19:46 +0100

wallet-core: read a single refresh field directly

Comparing a coin's old and new status took two RefreshInput objects.
Read the indexed field directly when a caller only needs the status or
the refund request.

Diffstat:
Mpackages/taler-wallet-core/src/pay-merchant.ts | 6+++---
Mpackages/taler-wallet-core/src/refresh-input.ts | 2+-
Mpackages/taler-wallet-core/src/refresh.ts | 20++++++++------------
3 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/packages/taler-wallet-core/src/pay-merchant.ts b/packages/taler-wallet-core/src/pay-merchant.ts @@ -6013,19 +6013,19 @@ export function classifyMerchantAbortRecoveryEvidence( ) { return "failed"; } - const refundInput = new RefreshInput(refundRefresh, refundCoinIndex); + const refundStatus = refundRefresh.statusPerCoin[refundCoinIndex]; const refundRecovery = classifyRecoveryRefresh( refundRefresh.operationStatus, ); if ( refundRecovery === "pending" || - refundInput.status === RefreshCoinStatus.Pending + refundStatus === RefreshCoinStatus.Pending ) { return "pending"; } if ( refundRecovery !== "recovered" || - refundInput.status !== RefreshCoinStatus.Finished + refundStatus !== RefreshCoinStatus.Finished ) { return "failed"; } diff --git a/packages/taler-wallet-core/src/refresh-input.ts b/packages/taler-wallet-core/src/refresh-input.ts @@ -102,6 +102,6 @@ export function finishedRefreshOutputs( group: WalletRefreshGroup, ): AmountString[] { return group.expectedOutputPerCoin.filter( - (_, i) => new RefreshInput(group, i).status === RefreshCoinStatus.Finished, + (_, i) => group.statusPerCoin[i] === RefreshCoinStatus.Finished, ); } diff --git a/packages/taler-wallet-core/src/refresh.ts b/packages/taler-wallet-core/src/refresh.ts @@ -1735,7 +1735,7 @@ export async function handleRefreshMeltConflict( )} failed in refresh group ${ctx.refreshGroupId} due to conflict`, ); - const request = new RefreshInput(refreshGroup, coinIndex).refundRequest; + const request = refreshGroup.refundRequests?.[coinIndex]; if (request) { const result = await reconcileRefreshRefund( ctx.wex, @@ -2375,8 +2375,8 @@ export async function processRefreshGroup( if (isPurseChange(rg)) { const settled = rg.oldCoinPubs.filter( (_, i) => - isPendingRefreshCoin(new RefreshInput(refreshGroup, i).status) && - !isPendingRefreshCoin(new RefreshInput(rg, i).status), + isPendingRefreshCoin(refreshGroup.statusPerCoin[i]) && + !isPendingRefreshCoin(rg.statusPerCoin[i]), ); await wakePurseResiduals(wex, tx, rg, settled); } @@ -2476,10 +2476,7 @@ export async function bindRefreshesToRecoup( }[] = []; for (const group of await tx.listAllRefreshGroups()) { const index = group.oldCoinPubs.indexOf(coin.coinPub); - if ( - index < 0 || - !isPendingRefreshCoin(new RefreshInput(group, index).status) - ) + if (index < 0 || !isPendingRefreshCoin(group.statusPerCoin[index])) continue; const session = await tx.getRefreshSession(group.refreshGroupId, index); result.push({ group, index, session }); @@ -2488,20 +2485,19 @@ export async function bindRefreshesToRecoup( }); const unaccepted: typeof candidates = []; for (const candidate of candidates) { - const refundRequest = new RefreshInput(candidate.group, candidate.index) - .refundRequest; + const { group, index, session } = candidate; + const refundRequest = group.refundRequests?.[index]; if (refundRequest) { const result = await reconcileRefreshRefund( wex, - candidate.group, - candidate.index, + group, + index, coin, refundRequest, ); // A granted refund changes the residual. Read a fresh history next time. if (result !== "refused") return false; } - const { session } = candidate; if (session?.norevealIndex != null) continue; if (session?.sessionPublicSeed) { if (