From 7523dcab95f6b5fe0c0f3f8f6b9bede67297bc8a Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 25 Dec 2019 21:47:57 +0100 Subject: comments --- src/operations/pay.ts | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'src/operations/pay.ts') diff --git a/src/operations/pay.ts b/src/operations/pay.ts index 8fed54aa4..43bdb2f44 100644 --- a/src/operations/pay.ts +++ b/src/operations/pay.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) Taler Systems S.A. + (C) 2019 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -62,6 +62,11 @@ import { InternalWalletState } from "./state"; import { getTimestampNow, timestampAddDuration } from "../util/time"; import { strcmp, canonicalJson } from "../util/helpers"; +/** + * Logger. + */ +const logger = new Logger("pay.ts"); + /** * Result of selecting coins, contains the exchange, and selected * coins with their denomination. @@ -93,17 +98,39 @@ export interface PayCoinSelection { customerDepositFees: AmountJson; } +/** + * Structure to describe a coin that is available to be + * used in a payment. + */ export interface AvailableCoinInfo { + /** + * Public key of the coin. + */ coinPub: string; + + /** + * Coin's denomination public key. + */ denomPub: string; + + /** + * Amount still remaining (typically the full amount, + * as coins are always refreshed after use.) + */ availableAmount: AmountJson; + + /** + * Deposit fee for the coin. + */ feeDeposit: AmountJson; } -const logger = new Logger("pay.ts"); - /** * Compute the total cost of a payment to the customer. + * + * This includes the amount taken by the merchant, fees (wire/deposit) contributed + * by the customer, refreshing fees, fees for withdraw-after-refresh and "trimmings" + * of coins that are too small to spend. */ export async function getTotalPaymentCost( ws: InternalWalletState, @@ -147,8 +174,6 @@ export async function getTotalPaymentCost( * constraints. * * This function is only exported for the sake of unit tests. - * - * @param denoms all available denoms, used to compute refresh fees */ export function selectPayCoins( acis: AvailableCoinInfo[], -- cgit v1.2.3