commit 53c68a5b42f3b2d16413091f044515f253f825f2
parent 26ca131778b7032699e95a0fa91af1fe05638db3
Author: Iván Ávalos <avalos@disroot.org>
Date: Thu, 19 Sep 2024 13:35:12 +0200
wallet-core: ensure that exchange entry gets added in preparePeerPushCredit!
Diffstat:
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/packages/taler-wallet-core/src/pay-peer-push-credit.ts b/packages/taler-wallet-core/src/pay-peer-push-credit.ts
@@ -594,6 +594,10 @@ export async function preparePeerPushCredit(
throw Error("got invalid taler://pay-push URI");
}
+ // add exchange entry if it doesn't exist already!
+ const exchangeBaseUrl = uri.exchangeBaseUrl;
+ await fetchFreshExchange(wex, exchangeBaseUrl);
+
const existing = await wex.db.runReadOnlyTx(
{ storeNames: ["contractTerms", "peerPushCredit"] },
async (tx) => {
@@ -635,20 +639,6 @@ export async function preparePeerPushCredit(
};
}
- const exchangeBaseUrl = uri.exchangeBaseUrl;
-
- try {
- // If the exchange entry doesn't exist yet,
- // it'll be created as an ephemeral entry.
- await fetchFreshExchange(wex, exchangeBaseUrl);
- } catch (e) {
- // We still continued if it failed, as other exchanges might be available.
- // We don't want to fail if the p2p payment exchange is broken/offline.
- logger.trace(
- `querying p2p payment exchange (${exchangeBaseUrl}) failed`,
- );
- }
-
const contractPriv = uri.contractPriv;
const contractPub = encodeCrock(eddsaGetPublic(decodeCrock(contractPriv)));