aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/taler-wallet-core/src/operations/exchanges.ts8
-rw-r--r--packages/taler-wallet-core/src/operations/pay.ts8
-rw-r--r--packages/taler-wallet-core/src/operations/refresh.ts8
-rw-r--r--packages/taler-wallet-core/src/operations/refund.ts21
-rw-r--r--packages/taler-wallet-core/src/operations/reserves.ts8
-rw-r--r--packages/taler-wallet-core/src/operations/tip.ts15
-rw-r--r--packages/taler-wallet-core/src/operations/withdraw.ts8
-rw-r--r--packages/taler-wallet-core/src/types/dbTypes.ts27
-rw-r--r--packages/taler-wallet-core/src/wallet.ts32
9 files changed, 37 insertions, 98 deletions
diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts b/packages/taler-wallet-core/src/operations/exchanges.ts
index 7bf07ab2a..d598e3987 100644
--- a/packages/taler-wallet-core/src/operations/exchanges.ts
+++ b/packages/taler-wallet-core/src/operations/exchanges.ts
@@ -222,7 +222,7 @@ async function updateExchangeWithKeys(
for (const newDenom of newDenominations) {
const oldDenom = await tx.get(Stores.denominations, [
baseUrl,
- newDenom.denomPub,
+ newDenom.denomPubHash,
]);
if (oldDenom) {
// FIXME: Do consistency check
@@ -236,10 +236,10 @@ async function updateExchangeWithKeys(
const newlyRevokedCoinPubs: string[] = [];
logger.trace("recoup list from exchange", recoupDenomList);
for (const recoupInfo of recoupDenomList) {
- const oldDenom = await tx.getIndexed(
- Stores.denominations.denomPubHashIndex,
+ const oldDenom = await tx.get(Stores.denominations, [
+ r.baseUrl,
recoupInfo.h_denom_pub,
- );
+ ]);
if (!oldDenom) {
// We never even knew about the revoked denomination, all good.
continue;
diff --git a/packages/taler-wallet-core/src/operations/pay.ts b/packages/taler-wallet-core/src/operations/pay.ts
index a6f941ff1..3dc5e1600 100644
--- a/packages/taler-wallet-core/src/operations/pay.ts
+++ b/packages/taler-wallet-core/src/operations/pay.ts
@@ -131,7 +131,7 @@ export async function getTotalPaymentCost(
}
const denom = await ws.db.get(Stores.denominations, [
coin.exchangeBaseUrl,
- coin.denomPub,
+ coin.denomPubHash,
]);
if (!denom) {
throw Error(
@@ -332,7 +332,7 @@ async function getCoinsForPayment(
// coins have the same currency
const firstDenom = await ws.db.get(Stores.denominations, [
exchange.baseUrl,
- coins[0].denomPub,
+ coins[0].denomPubHash,
]);
if (!firstDenom) {
throw Error("db inconsistent");
@@ -342,7 +342,7 @@ async function getCoinsForPayment(
for (const coin of coins) {
const denom = await ws.db.get(Stores.denominations, [
exchange.baseUrl,
- coin.denomPub,
+ coin.denomPubHash,
]);
if (!denom) {
throw Error("db inconsistent");
@@ -1148,7 +1148,7 @@ export async function confirmPay(
}
const denom = await ws.db.get(Stores.denominations, [
coin.exchangeBaseUrl,
- coin.denomPub,
+ coin.denomPubHash,
]);
if (!denom) {
throw Error(
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts
index a6917c285..c92ce9209 100644
--- a/packages/taler-wallet-core/src/operations/refresh.ts
+++ b/packages/taler-wallet-core/src/operations/refresh.ts
@@ -134,7 +134,7 @@ async function refreshCreateSession(
const oldDenom = await ws.db.get(Stores.denominations, [
exchange.baseUrl,
- coin.denomPub,
+ coin.denomPubHash,
]);
if (!oldDenom) {
@@ -367,7 +367,7 @@ async function refreshReveal(
for (let i = 0; i < reveal.ev_sigs.length; i++) {
const denom = await ws.db.get(Stores.denominations, [
refreshSession.exchangeBaseUrl,
- refreshSession.newDenoms[i],
+ refreshSession.newDenomHashes[i],
]);
if (!denom) {
console.error("denom not found");
@@ -598,7 +598,7 @@ export async function createRefreshGroup(
checkDbInvariant(!!coin, "coin must be in database");
const denom = await tx.get(Stores.denominations, [
coin.exchangeBaseUrl,
- coin.denomPub,
+ coin.denomPubHash,
]);
checkDbInvariant(
!!denom,
@@ -701,7 +701,7 @@ export async function autoRefresh(
}
const denom = await tx.get(Stores.denominations, [
exchangeBaseUrl,
- coin.denomPub,
+ coin.denomPubHash,
]);
if (!denom) {
logger.warn("denomination not in database");
diff --git a/packages/taler-wallet-core/src/operations/refund.ts b/packages/taler-wallet-core/src/operations/refund.ts
index 097e20863..e15a27b3a 100644
--- a/packages/taler-wallet-core/src/operations/refund.ts
+++ b/packages/taler-wallet-core/src/operations/refund.ts
@@ -104,10 +104,10 @@ async function applySuccessfulRefund(
console.warn("coin not found, can't apply refund");
return;
}
- const denom = await tx.getIndexed(
- Stores.denominations.denomPubHashIndex,
+ const denom = await tx.get(Stores.denominations, [
+ coin.exchangeBaseUrl,
coin.denomPubHash,
- );
+ ]);
if (!denom) {
throw Error("inconsistent database");
}
@@ -161,10 +161,10 @@ async function storePendingRefund(
console.warn("coin not found, can't apply refund");
return;
}
- const denom = await tx.getIndexed(
- Stores.denominations.denomPubHashIndex,
+ const denom = await tx.get(Stores.denominations, [
+ coin.exchangeBaseUrl,
coin.denomPubHash,
- );
+ ]);
if (!denom) {
throw Error("inconsistent database");
@@ -211,10 +211,10 @@ async function storeFailedRefund(
console.warn("coin not found, can't apply refund");
return;
}
- const denom = await tx.getIndexed(
- Stores.denominations.denomPubHashIndex,
+ const denom = await tx.get(Stores.denominations, [
+ coin.exchangeBaseUrl,
coin.denomPubHash,
- );
+ ]);
if (!denom) {
throw Error("inconsistent database");
@@ -294,7 +294,8 @@ async function acceptRefunds(
// Still pending.
if (
- refundStatus.type === "failure" && !isPermanentFailure &&
+ refundStatus.type === "failure" &&
+ !isPermanentFailure &&
existingRefundInfo?.type === RefundState.Pending
) {
continue;
diff --git a/packages/taler-wallet-core/src/operations/reserves.ts b/packages/taler-wallet-core/src/operations/reserves.ts
index 6db203472..cced6a1d5 100644
--- a/packages/taler-wallet-core/src/operations/reserves.ts
+++ b/packages/taler-wallet-core/src/operations/reserves.ts
@@ -172,14 +172,6 @@ export async function createReserve(
expectedAmount: req.amount,
});
- const senderWire = req.senderWire;
- if (senderWire) {
- const rec = {
- paytoUri: senderWire,
- };
- await ws.db.put(Stores.senderWires, rec);
- }
-
const exchangeInfo = await updateExchangeFromUrl(ws, req.exchange);
const exchangeDetails = exchangeInfo.details;
if (!exchangeDetails) {
diff --git a/packages/taler-wallet-core/src/operations/tip.ts b/packages/taler-wallet-core/src/operations/tip.ts
index 7b914568f..08f45eb89 100644
--- a/packages/taler-wallet-core/src/operations/tip.ts
+++ b/packages/taler-wallet-core/src/operations/tip.ts
@@ -104,10 +104,11 @@ export async function prepareTip(
planchets: undefined,
createdTimestamp: getTimestampNow(),
merchantTipId: res.merchantTipId,
- tipAmountEffective: Amounts.sub(amount, Amounts.add(
- withdrawDetails.overhead,
- withdrawDetails.withdrawFee,
- ).amount).amount,
+ tipAmountEffective: Amounts.sub(
+ amount,
+ Amounts.add(withdrawDetails.overhead, withdrawDetails.withdrawFee)
+ .amount,
+ ).amount,
retryInfo: initRetryInfo(),
lastError: undefined,
denomsSel: denomSelectionInfoToState(selectedDenoms),
@@ -200,10 +201,10 @@ async function processTipImpl(
const planchets: TipPlanchet[] = [];
for (const sd of denomsForWithdraw.selectedDenoms) {
- const denom = await ws.db.getIndexed(
- Stores.denominations.denomPubHashIndex,
+ const denom = await ws.db.get(Stores.denominations, [
+ tipRecord.exchangeBaseUrl,
sd.denomPubHash,
- );
+ ]);
if (!denom) {
throw Error("denom does not exist anymore");
}
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts
index fd472fdfe..e44ac7cf2 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -233,10 +233,10 @@ async function processPlanchetGenerate(
if (!denomPubHash) {
throw Error("invariant violated");
}
- const denom = await ws.db.getIndexed(
- Stores.denominations.denomPubHashIndex,
+ const denom = await ws.db.get(Stores.denominations, [
+ withdrawalGroup.exchangeBaseUrl,
denomPubHash,
- );
+ ]);
if (!denom) {
throw Error("invariant violated");
}
@@ -325,7 +325,7 @@ async function processPlanchetExchangeRequest(
const denom = await ws.db.get(Stores.denominations, [
withdrawalGroup.exchangeBaseUrl,
- planchet.denomPub,
+ planchet.denomPubHash,
]);
if (!denom) {
diff --git a/packages/taler-wallet-core/src/types/dbTypes.ts b/packages/taler-wallet-core/src/types/dbTypes.ts
index 62eadc78b..12a89a43e 100644
--- a/packages/taler-wallet-core/src/types/dbTypes.ts
+++ b/packages/taler-wallet-core/src/types/dbTypes.ts
@@ -1384,13 +1384,6 @@ export interface PurchaseRecord {
}
/**
- * Information about wire information for bank accounts we withdrew coins from.
- */
-export interface SenderWireRecord {
- paytoUri: string;
-}
-
-/**
* Configuration key/value entries to configure
* the wallet.
*/
@@ -1589,25 +1582,14 @@ class DenominationsStore extends Store<DenominationRecord> {
constructor() {
// cast needed because of bug in type annotations
super("denominations", {
- keyPath: (["exchangeBaseUrl", "denomPub"] as any) as IDBKeyPath,
+ keyPath: (["exchangeBaseUrl", "denomPubHash"] as any) as IDBKeyPath,
});
}
-
- denomPubHashIndex = new Index<string, DenominationRecord>(
- this,
- "denomPubHashIndex",
- "denomPubHash",
- );
exchangeBaseUrlIndex = new Index<string, DenominationRecord>(
this,
"exchangeBaseUrlIndex",
"exchangeBaseUrl",
);
- denomPubIndex = new Index<string, DenominationRecord>(
- this,
- "denomPubIndex",
- "denomPub",
- );
}
class CurrenciesStore extends Store<CurrencyRecord> {
@@ -1640,12 +1622,6 @@ class TipsStore extends Store<TipRecord> {
}
}
-class SenderWiresStore extends Store<SenderWireRecord> {
- constructor() {
- super("senderWires", { keyPath: "paytoUri" });
- }
-}
-
class WithdrawalGroupsStore extends Store<WithdrawalGroupRecord> {
constructor() {
super("withdrawals", { keyPath: "withdrawalGroupId" });
@@ -1698,7 +1674,6 @@ export const Stores = {
reserveHistory: new ReserveHistoryStore(),
purchases: new PurchasesStore(),
tips: new TipsStore(),
- senderWires: new SenderWiresStore(),
withdrawalGroups: new WithdrawalGroupsStore(),
planchets: new PlanchetsStore(),
bankWithdrawUris: new BankWithdrawUrisStore(),
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
index cd9646339..e91d74efb 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -709,36 +709,6 @@ export class Wallet {
this.ws.cryptoApi.stop();
}
- async getSenderWireInfos(): Promise<SenderWireInfos> {
- const m: { [url: string]: Set<string> } = {};
-
- await this.db.iter(Stores.exchanges).forEach((x) => {
- const wi = x.wireInfo;
- if (!wi) {
- return;
- }
- const s = (m[x.baseUrl] = m[x.baseUrl] || new Set());
- Object.keys(wi.feesForType).map((k) => s.add(k));
- });
-
- const exchangeWireTypes: { [url: string]: string[] } = {};
- Object.keys(m).map((e) => {
- exchangeWireTypes[e] = Array.from(m[e]);
- });
-
- const senderWiresSet: Set<string> = new Set();
- await this.db.iter(Stores.senderWires).forEach((x) => {
- senderWiresSet.add(x.paytoUri);
- });
-
- const senderWires: string[] = Array.from(senderWiresSet);
-
- return {
- exchangeWireTypes,
- senderWires,
- };
- }
-
/**
* Trigger paying coins back into the user's account.
*/
@@ -894,7 +864,7 @@ export class Wallet {
for (const c of coins) {
const denom = await this.db.get(Stores.denominations, [
c.exchangeBaseUrl,
- c.denomPub,
+ c.denomPubHash,
]);
if (!denom) {
console.error("no denom session found for coin");