wallet-core: add wire method check in new coin selection

This commit is contained in:
Florian Dold 2022-09-19 11:28:47 +02:00
parent ba5f8ad386
commit cffc4347a0
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
2 changed files with 15 additions and 7 deletions

View File

@ -21,10 +21,8 @@ import { Duration, PreparePayResultType } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js";
import {
BankService,
ExchangeService,
FakebankService,
getPayto,
getRandomIban,
GlobalTestState,
MerchantPrivateApi,
@ -32,11 +30,7 @@ import {
setupDb,
WalletCli,
} from "../harness/harness.js";
import {
createSimpleTestkudosEnvironment,
withdrawViaBank,
makeTestPayment,
} from "../harness/helpers.js";
import { withdrawViaBank } from "../harness/helpers.js";
/**
* Test for wallet balance error messages / different types of insufficient balance.

View File

@ -47,6 +47,7 @@ import {
j2s,
Logger,
NotificationType,
parsePaytoUri,
parsePayUri,
PayCoinSelection,
PreparePayResult,
@ -898,6 +899,19 @@ export async function selectCandidates(
if (exchangeDetails?.currency !== req.contractTermsAmount.currency) {
continue;
}
let wireMethodSupported = false;
for (const acc of exchangeDetails.wireInfo.accounts) {
const pp = parsePaytoUri(acc.payto_uri);
checkLogicInvariant(!!pp);
if (pp.targetType === req.wireMethod) {
wireMethodSupported = true;
break;
}
}
if (!wireMethodSupported) {
break;
}
exchangeDetails.wireInfo.accounts;
let accepted = false;
for (const allowedExchange of req.exchanges) {
if (allowedExchange.exchangePub === exchangeDetails.masterPublicKey) {