From 7ba1d1f3351e58a331e99337afea0fbedb6eb828 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 6 Mar 2024 21:15:30 +0100 Subject: refactor coin selection, report maxEffectiveSpendAmount --- packages/taler-util/src/wallet-types.ts | 39 ++++++++++++--------------------- 1 file changed, 14 insertions(+), 25 deletions(-) (limited to 'packages/taler-util/src') diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts index 9fe114b3d..cb4374648 100644 --- a/packages/taler-util/src/wallet-types.ts +++ b/packages/taler-util/src/wallet-types.ts @@ -868,21 +868,15 @@ export interface PayMerchantInsufficientBalanceDetails { balanceMerchantDepositable: AmountString; /** - * If the payment would succeed without fees - * (i.e. balanceMerchantDepositable >= amountRequested), - * this field contains an estimate of the amount that would additionally - * be required to cover the fees. - * - * It is not possible to give an exact value here, since it depends - * on the coin selection for the amount that would be additionally withdrawn. + * Maximum effective amount that the wallet can spend, + * when all fees are paid by the wallet. */ - feeGapEstimate: AmountString; + maxEffectiveSpendAmount: AmountString; perExchange: { [url: string]: { balanceAvailable: AmountString; balanceMaterial: AmountString; - feeGapEstimate: AmountString; }; }; } @@ -896,8 +890,8 @@ export const codecForPayMerchantInsufficientBalanceDetails = .property("balanceMaterial", codecForAmountString()) .property("balanceMerchantAcceptable", codecForAmountString()) .property("balanceMerchantDepositable", codecForAmountString()) - .property("feeGapEstimate", codecForAmountString()) .property("perExchange", codecForAny()) + .property("maxEffectiveSpendAmount", codecForAmountString()) .build("PayMerchantInsufficientBalanceDetails"); export const codecForPreparePayResultInsufficientBalance = @@ -2623,7 +2617,15 @@ export interface ForcedCoinSel { } export interface TestPayResult { - payCoinSelection: PayCoinSelection; + /** + * Number of coins used for the payment. + */ + numCoins: number; +} + +export interface SelectedCoin { + coinPub: string; + contribution: AmountString; } /** @@ -2631,20 +2633,7 @@ export interface TestPayResult { * coins with their denomination. */ export interface PayCoinSelection { - /** - * Amount requested by the merchant. - */ - paymentAmount: AmountString; - - /** - * Public keys of the coins that were selected. - */ - coinPubs: string[]; - - /** - * Amount that each coin contributes. - */ - coinContributions: AmountString[]; + coins: SelectedCoin[]; /** * How much of the wire fees is the customer paying? -- cgit v1.2.3