wallet-core: return numCoins in checkPeerPullCredit response

This commit is contained in:
Florian Dold 2023-06-26 12:57:00 +02:00
parent eae3571607
commit 4b61945f6b
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
2 changed files with 12 additions and 0 deletions

View File

@ -2474,6 +2474,12 @@ export interface CheckPeerPullCreditResponse {
exchangeBaseUrl: string;
amountRaw: AmountString;
amountEffective: AmountString;
/**
* Number of coins that will be used,
* can be used by the UI to warn if excessively large.
*/
numCoins: number;
}
export interface InitiatePeerPullCreditRequest {
exchangeBaseUrl?: string;

View File

@ -649,10 +649,16 @@ export async function checkPeerPullPaymentInitiation(
logger.trace(`got withdrawal info`);
let numCoins = 0;
for (let i = 0; i < wi.selectedDenoms.selectedDenoms.length; i++) {
numCoins += wi.selectedDenoms.selectedDenoms[i].count;
}
return {
exchangeBaseUrl: exchangeUrl,
amountEffective: wi.withdrawalAmountEffective,
amountRaw: req.amount,
numCoins,
};
}