taler-typescript-core

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

commit e9683e5ae9d3f7e6f3e16d01a280592075861548
parent 6f2b03021d7946a61d6b8e53dbba7fc10e5f9a4d
Author: Florian Dold <florian@dold.me>
Date:   Mon,  8 Jan 2024 21:43:02 +0100

wallet-core: properly filter possible exchanges for withdrawals

Diffstat:
Mpackages/taler-wallet-core/src/operations/withdraw.ts | 14++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -35,6 +35,7 @@ import { Duration, ExchangeBatchWithdrawRequest, ExchangeListItem, + ExchangeUpdateStatus, ExchangeWireAccount, ExchangeWithdrawBatchResponse, ExchangeWithdrawRequest, @@ -1945,12 +1946,21 @@ export async function getWithdrawalDetailsForUri( } } - const possibleExchangesResp = await listExchanges(ws); + const currency = Amounts.currencyOf(info.amount); + + const listExchangesResp = await listExchanges(ws); + const possibleExchanges = listExchangesResp.exchanges.filter((x) => { + return ( + x.currency === currency && + (x.exchangeUpdateStatus === ExchangeUpdateStatus.Ready || + x.exchangeUpdateStatus === ExchangeUpdateStatus.ReadyUpdate) + ); + }); return { amount: Amounts.stringify(info.amount), defaultExchangeBaseUrl: info.suggestedExchange, - possibleExchanges: possibleExchangesResp.exchanges, + possibleExchanges, }; }