diff options
Diffstat (limited to 'packages/taler-wallet-core/src/operations/refresh.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/refresh.ts | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts index d49c9a1cf..974eb1619 100644 --- a/packages/taler-wallet-core/src/operations/refresh.ts +++ b/packages/taler-wallet-core/src/operations/refresh.ts @@ -80,6 +80,7 @@ import { } from "../db.js"; import { getCandidateWithdrawalDenomsTx, + RefreshGroupPerExchangeInfo, RefreshSessionRecord, timestampPreciseToDb, timestampProtocolFromDb, @@ -1107,6 +1108,7 @@ async function processRefreshSession( export interface RefreshOutputInfo { outputPerCoin: AmountJson[]; + perExchangeInfo: Record<string, RefreshGroupPerExchangeInfo>; } export async function calculateRefreshOutput( @@ -1124,6 +1126,8 @@ export async function calculateRefreshOutput( const denomsPerExchange: Record<string, DenominationRecord[]> = {}; + const infoPerExchange: Record<string, RefreshGroupPerExchangeInfo> = {}; + // FIXME: Use denom groups instead of querying all denominations! const getDenoms = async ( exchangeBaseUrl: string, @@ -1163,11 +1167,21 @@ export async function calculateRefreshOutput( ws.config.testing.denomselAllowLate, ); const output = Amounts.sub(refreshAmount, cost).amount; + let exchInfo = infoPerExchange[coin.exchangeBaseUrl]; + if (!exchInfo) { + infoPerExchange[coin.exchangeBaseUrl] = exchInfo = { + outputEffective: Amounts.stringify(Amounts.zeroOfAmount(cost)), + }; + } + exchInfo.outputEffective = Amounts.stringify( + Amounts.add(exchInfo.outputEffective, output).amount, + ); estimatedOutputPerCoin.push(output); } return { outputPerCoin: estimatedOutputPerCoin, + perExchangeInfo: infoPerExchange, }; } @@ -1234,6 +1248,10 @@ async function applyRefresh( } } +export interface CreateRefreshGroupResult { + refreshGroupId: string; +} + /** * Create a refresh group for a list of coins. * @@ -1252,7 +1270,7 @@ export async function createRefreshGroup( oldCoinPubs: CoinRefreshRequest[], reason: RefreshReason, reasonDetails?: RefreshReasonDetails, -): Promise<RefreshGroupId> { +): Promise<CreateRefreshGroupResult> { const refreshGroupId = encodeCrock(getRandomBytes(32)); const outInfo = await calculateRefreshOutput(ws, tx, currency, oldCoinPubs); |