diff options
author | Florian Dold <florian@dold.me> | 2022-08-23 11:29:45 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-08-23 20:35:11 +0200 |
commit | f3ff5a72257dda27cab555f8b8d921d45bfc3e4b (patch) | |
tree | 708494a3aa2346fead51931fe4bfc41cc0249659 /packages/taler-wallet-core/src/wallet.ts | |
parent | 4ca38113abee2c0ca17b26aa55cf6a0ecafe49c9 (diff) | |
download | wallet-core-f3ff5a72257dda27cab555f8b8d921d45bfc3e4b.tar.gz wallet-core-f3ff5a72257dda27cab555f8b8d921d45bfc3e4b.tar.bz2 wallet-core-f3ff5a72257dda27cab555f8b8d921d45bfc3e4b.zip |
peer-to-peer pull payments MVP
p2p pull wip
Diffstat (limited to 'packages/taler-wallet-core/src/wallet.ts')
-rw-r--r-- | packages/taler-wallet-core/src/wallet.ts | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index 593d2e0ff..0d5918886 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -32,6 +32,7 @@ import { codecForAcceptBankIntegratedWithdrawalRequest, codecForAcceptExchangeTosRequest, codecForAcceptManualWithdrawalRequet, + codecForAcceptPeerPullPaymentRequest, codecForAcceptPeerPushPaymentRequest, codecForAcceptTipRequest, codecForAddExchangeRequest, @@ -50,6 +51,7 @@ import { codecForGetWithdrawalDetailsForAmountRequest, codecForGetWithdrawalDetailsForUri, codecForImportDbRequest, + codecForInitiatePeerPullPaymentRequest, codecForInitiatePeerPushPaymentRequest, codecForIntegrationTestArgs, codecForListKnownBankAccounts, @@ -150,6 +152,7 @@ import { import { acceptPeerPushPayment, checkPeerPushPayment, + initiatePeerRequestForPay, initiatePeerToPeerPush, } from "./operations/peer-to-peer.js"; import { getPendingOperations } from "./operations/pending.js"; @@ -455,11 +458,20 @@ async function fillDefaults(ws: InternalWalletState): Promise<void> { for (const c of builtinAuditors) { await tx.auditorTrustStore.put(c); } - for (const url of builtinExchanges) { - await updateExchangeFromUrl(ws, url, { forceNow: true }); - } } + // FIXME: make sure exchanges are added transactionally to + // DB in first-time default application }); + + for (const url of builtinExchanges) { + try { + await updateExchangeFromUrl(ws, url, { forceNow: true }); + } catch (e) { + logger.warn( + `could not update builtin exchange ${url} during wallet initialization`, + ); + } + } } async function getExchangeTos( @@ -568,8 +580,9 @@ async function getExchanges( continue; } - const denominations = await tx.denominations.indexes - .byExchangeBaseUrl.iter(r.baseUrl).toArray(); + const denominations = await tx.denominations.indexes.byExchangeBaseUrl + .iter(r.baseUrl) + .toArray(); if (!denominations) { continue; @@ -1030,6 +1043,10 @@ async function dispatchRequestInternal( await acceptPeerPushPayment(ws, req); return {}; } + case "initiatePeerPullPayment": { + const req = codecForInitiatePeerPullPaymentRequest().decode(payload); + return await initiatePeerRequestForPay(ws, req); + } } throw TalerError.fromDetail( TalerErrorCode.WALLET_CORE_API_OPERATION_UNKNOWN, |