summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/taler-util/src/ReserveStatus.ts2
-rw-r--r--packages/taler-util/src/ReserveTransaction.ts2
-rw-r--r--packages/taler-util/src/amounts.ts2
-rw-r--r--packages/taler-util/src/backup-types.ts (renamed from packages/taler-util/src/backupTypes.ts)2
-rw-r--r--packages/taler-util/src/bitcoin.ts2
-rw-r--r--packages/taler-util/src/contract-terms.test.ts (renamed from packages/taler-util/src/contractTerms.test.ts)2
-rw-r--r--packages/taler-util/src/contract-terms.ts (renamed from packages/taler-util/src/contractTerms.ts)2
-rw-r--r--packages/taler-util/src/index.ts12
-rw-r--r--packages/taler-util/src/notifications.ts2
-rw-r--r--packages/taler-util/src/taler-crypto.test.ts (renamed from packages/taler-util/src/talerCrypto.test.ts)2
-rw-r--r--packages/taler-util/src/taler-crypto.ts (renamed from packages/taler-util/src/talerCrypto.ts)2
-rw-r--r--packages/taler-util/src/taler-types.ts (renamed from packages/taler-util/src/talerTypes.ts)2
-rw-r--r--packages/taler-util/src/transactions-types.ts (renamed from packages/taler-util/src/transactionsTypes.ts)10
-rw-r--r--packages/taler-util/src/types-test.ts2
-rw-r--r--packages/taler-util/src/wallet-types.ts (renamed from packages/taler-util/src/walletTypes.ts)18
-rw-r--r--packages/taler-wallet-core/src/db.ts26
-rw-r--r--packages/taler-wallet-core/src/operations/backup/import.ts5
-rw-r--r--packages/taler-wallet-core/src/operations/common.ts4
-rw-r--r--packages/taler-wallet-core/src/operations/pay-merchant.ts31
19 files changed, 64 insertions, 66 deletions
diff --git a/packages/taler-util/src/ReserveStatus.ts b/packages/taler-util/src/ReserveStatus.ts
index eb147da2d..be9fa9e8e 100644
--- a/packages/taler-util/src/ReserveStatus.ts
+++ b/packages/taler-util/src/ReserveStatus.ts
@@ -27,7 +27,7 @@ import {
codecForList,
Codec,
} from "./codec.js";
-import { AmountString } from "./talerTypes.js";
+import { AmountString } from "./taler-types.js";
import {
ReserveTransaction,
codecForReserveTransaction,
diff --git a/packages/taler-util/src/ReserveTransaction.ts b/packages/taler-util/src/ReserveTransaction.ts
index 8f3e16da2..5d3f86b1a 100644
--- a/packages/taler-util/src/ReserveTransaction.ts
+++ b/packages/taler-util/src/ReserveTransaction.ts
@@ -37,7 +37,7 @@ import {
EddsaSignatureString,
EddsaPublicKeyString,
CoinPublicKeyString,
-} from "./talerTypes.js";
+} from "./taler-types.js";
import {
AbsoluteTime,
codecForTimestamp,
diff --git a/packages/taler-util/src/amounts.ts b/packages/taler-util/src/amounts.ts
index d4de4ca53..337f342a3 100644
--- a/packages/taler-util/src/amounts.ts
+++ b/packages/taler-util/src/amounts.ts
@@ -27,7 +27,7 @@ import {
codecForNumber,
Codec,
} from "./codec.js";
-import { AmountString } from "./talerTypes.js";
+import { AmountString } from "./taler-types.js";
/**
* Number of fractional units that one value unit represents.
diff --git a/packages/taler-util/src/backupTypes.ts b/packages/taler-util/src/backup-types.ts
index 0270f2586..6c7b203b5 100644
--- a/packages/taler-util/src/backupTypes.ts
+++ b/packages/taler-util/src/backup-types.ts
@@ -62,7 +62,7 @@
/**
* Imports.
*/
-import { DenominationPubKey, UnblindedSignature } from "./talerTypes.js";
+import { DenominationPubKey, UnblindedSignature } from "./taler-types.js";
import { TalerProtocolDuration, TalerProtocolTimestamp } from "./time.js";
export const BACKUP_TAG = "gnu-taler-wallet-backup-content" as const;
diff --git a/packages/taler-util/src/bitcoin.ts b/packages/taler-util/src/bitcoin.ts
index ede3cbcdc..8c22ba522 100644
--- a/packages/taler-util/src/bitcoin.ts
+++ b/packages/taler-util/src/bitcoin.ts
@@ -23,7 +23,7 @@
* Imports.
*/
import { AmountJson, Amounts } from "./amounts.js";
-import { decodeCrock } from "./talerCrypto.js";
+import { decodeCrock } from "./taler-crypto.js";
import * as segwit from "./segwit_addr.js";
function buf2hex(buffer: Uint8Array) {
diff --git a/packages/taler-util/src/contractTerms.test.ts b/packages/taler-util/src/contract-terms.test.ts
index d021495d0..fc0920501 100644
--- a/packages/taler-util/src/contractTerms.test.ts
+++ b/packages/taler-util/src/contract-terms.test.ts
@@ -19,7 +19,7 @@
*/
import test from "ava";
import { initNodePrng } from "./prng-node.js";
-import { ContractTermsUtil } from "./contractTerms.js";
+import { ContractTermsUtil } from "./contract-terms.js";
// Since we import nacl-fast directly (and not via index.node.ts), we need to
// init the PRNG manually.
diff --git a/packages/taler-util/src/contractTerms.ts b/packages/taler-util/src/contract-terms.ts
index aa6bf7baf..3567b50d8 100644
--- a/packages/taler-util/src/contractTerms.ts
+++ b/packages/taler-util/src/contract-terms.ts
@@ -23,7 +23,7 @@ import {
getRandomBytes,
hash,
stringToBytes,
-} from "./talerCrypto.js";
+} from "./taler-crypto.js";
const logger = new Logger("contractTerms.ts");
diff --git a/packages/taler-util/src/index.ts b/packages/taler-util/src/index.ts
index cf48ba803..1d55da068 100644
--- a/packages/taler-util/src/index.ts
+++ b/packages/taler-util/src/index.ts
@@ -3,7 +3,7 @@ import { TalerErrorCode } from "./taler-error-codes.js";
export { TalerErrorCode };
export * from "./amounts.js";
-export * from "./backupTypes.js";
+export * from "./backup-types.js";
export * from "./codec.js";
export * from "./helpers.js";
export * from "./libtool-version.js";
@@ -11,17 +11,17 @@ export * from "./notifications.js";
export * from "./payto.js";
export * from "./ReserveStatus.js";
export * from "./ReserveTransaction.js";
-export * from "./talerTypes.js";
+export * from "./taler-types.js";
export * from "./taleruri.js";
export * from "./time.js";
-export * from "./transactionsTypes.js";
-export * from "./walletTypes.js";
+export * from "./transactions-types.js";
+export * from "./wallet-types.js";
export * from "./i18n.js";
export * from "./logging.js";
export * from "./url.js";
export { fnutil } from "./fnutils.js";
export * from "./kdf.js";
-export * from "./talerCrypto.js";
+export * from "./taler-crypto.js";
export * from "./http-status-codes.js";
export * from "./bitcoin.js";
export {
@@ -32,4 +32,4 @@ export {
} from "./nacl-fast.js";
export { RequestThrottler } from "./RequestThrottler.js";
export * from "./CancellationToken.js";
-export * from "./contractTerms.js";
+export * from "./contract-terms.js";
diff --git a/packages/taler-util/src/notifications.ts b/packages/taler-util/src/notifications.ts
index b3d9ad1dc..17019237a 100644
--- a/packages/taler-util/src/notifications.ts
+++ b/packages/taler-util/src/notifications.ts
@@ -22,7 +22,7 @@
/**
* Imports.
*/
-import { TalerErrorDetail } from "./walletTypes.js";
+import { TalerErrorDetail } from "./wallet-types.js";
export enum NotificationType {
CoinWithdrawn = "coin-withdrawn",
diff --git a/packages/taler-util/src/talerCrypto.test.ts b/packages/taler-util/src/taler-crypto.test.ts
index 29458ac37..e90516cc4 100644
--- a/packages/taler-util/src/talerCrypto.test.ts
+++ b/packages/taler-util/src/taler-crypto.test.ts
@@ -38,7 +38,7 @@ import {
getRandomBytes,
bigintToNaclArr,
bigintFromNaclArr,
-} from "./talerCrypto.js";
+} from "./taler-crypto.js";
import { sha512, kdf } from "./kdf.js";
import * as nacl from "./nacl-fast.js";
import { initNodePrng } from "./prng-node.js";
diff --git a/packages/taler-util/src/talerCrypto.ts b/packages/taler-util/src/taler-crypto.ts
index 84842a69f..d7e9a0c06 100644
--- a/packages/taler-util/src/talerCrypto.ts
+++ b/packages/taler-util/src/taler-crypto.ts
@@ -30,7 +30,7 @@ import {
DenominationPubKey,
DenomKeyType,
HashCodeString,
-} from "./talerTypes.js";
+} from "./taler-types.js";
import { Logger } from "./logging.js";
import { secretbox } from "./nacl-fast.js";
import * as fflate from "fflate";
diff --git a/packages/taler-util/src/talerTypes.ts b/packages/taler-util/src/taler-types.ts
index 1cb4e2bde..de88fef69 100644
--- a/packages/taler-util/src/talerTypes.ts
+++ b/packages/taler-util/src/taler-types.ts
@@ -41,7 +41,7 @@ import {
codecOptional,
} from "./codec.js";
import { strcmp } from "./helpers.js";
-import { AgeCommitmentProof, Edx25519PublicKeyEnc } from "./talerCrypto.js";
+import { AgeCommitmentProof, Edx25519PublicKeyEnc } from "./taler-crypto.js";
import {
codecForAbsoluteTime,
codecForDuration,
diff --git a/packages/taler-util/src/transactionsTypes.ts b/packages/taler-util/src/transactions-types.ts
index 5fd01448c..c1870e2e0 100644
--- a/packages/taler-util/src/transactionsTypes.ts
+++ b/packages/taler-util/src/transactions-types.ts
@@ -34,7 +34,7 @@ import {
codecForMerchantInfo,
codecForProduct,
Location,
-} from "./talerTypes.js";
+} from "./taler-types.js";
import {
Codec,
buildCodecForObject,
@@ -43,7 +43,11 @@ import {
codecForList,
codecForAny,
} from "./codec.js";
-import { RefreshReason, TalerErrorDetail } from "./walletTypes.js";
+import {
+ RefreshReason,
+ TalerErrorDetail,
+ TransactionIdStr,
+} from "./wallet-types.js";
export interface TransactionsRequest {
/**
@@ -68,7 +72,7 @@ export interface TransactionsResponse {
export interface TransactionCommon {
// opaque unique ID for the transaction, used as a starting point for paginating queries
// and for invoking actions on the transaction (e.g. deleting/hiding it from the history)
- transactionId: string;
+ transactionId: TransactionIdStr;
// the type of the transaction; different types might provide additional information
type: TransactionType;
diff --git a/packages/taler-util/src/types-test.ts b/packages/taler-util/src/types-test.ts
index e8af13119..2915106c2 100644
--- a/packages/taler-util/src/types-test.ts
+++ b/packages/taler-util/src/types-test.ts
@@ -15,7 +15,7 @@
*/
import test from "ava";
-import { codecForContractTerms } from "./talerTypes.js";
+import { codecForContractTerms } from "./taler-types.js";
test("contract terms validation", (t) => {
const c = {
diff --git a/packages/taler-util/src/walletTypes.ts b/packages/taler-util/src/wallet-types.ts
index 0b2ef1d5f..cd6c2202e 100644
--- a/packages/taler-util/src/walletTypes.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -62,15 +62,25 @@ import {
DenomKeyType,
ExchangeAuditor,
UnblindedSignature,
-} from "./talerTypes.js";
-import { OrderShortInfo, codecForOrderShortInfo } from "./transactionsTypes.js";
-import { BackupRecovery } from "./backupTypes.js";
+} from "./taler-types.js";
+import { OrderShortInfo, codecForOrderShortInfo } from "./transactions-types.js";
+import { BackupRecovery } from "./backup-types.js";
import { PaytoUri } from "./payto.js";
import { TalerErrorCode } from "./taler-error-codes.js";
-import { AgeCommitmentProof } from "./talerCrypto.js";
+import { AgeCommitmentProof } from "./taler-crypto.js";
import { VersionMatchResult } from "./libtool-version.js";
/**
+ * Identifier for a transaction in the wallet.
+ */
+export type TransactionIdStr = `tx:${string}:${string}`;
+
+/**
+ * Identifier for a pending task in the wallet.
+ */
+export type PendingIdStr = `pd:${string}:string`;
+
+/**
* Response for the create reserve request to the wallet.
*/
export class CreateReserveResponse {
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts
index 304efd852..72dd0dc9c 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -48,6 +48,7 @@ import {
GlobalFees,
ExchangeGlobalFees,
DenomSelectionState,
+ TransactionIdStr,
} from "@gnu-taler/taler-util";
import { RetryInfo, RetryTags } from "./util/retries.js";
import { Event, IDBDatabase } from "@gnu-taler/idb-bridge";
@@ -765,8 +766,10 @@ export interface CoinRecord {
* Coin allocation, i.e. what a coin has been used for.
*/
export interface CoinAllocation {
- // FIXME: Specify format!
- id: string;
+ /**
+ * ID of the allocation, should be the ID of the transaction that
+ */
+ id: TransactionIdStr;
amount: AmountString;
}
@@ -1065,6 +1068,9 @@ export enum PurchaseStatus {
*/
Paying = 11,
+ /**
+ * Currently in the process of aborting with a refund.
+ */
AbortingWithRefund = 12,
/**
@@ -1118,7 +1124,7 @@ export enum PurchaseStatus {
* Only contains data that is relevant for indexing on the
* "purchases" object stores.
*/
-export interface ProposalDownload {
+export interface ProposalDownloadInfo {
contractTermsHash: string;
fulfillmentUrl?: string;
currency: string;
@@ -1129,15 +1135,6 @@ export interface PurchasePayInfo {
payCoinSelection: PayCoinSelection;
totalPayCost: AmountJson;
payCoinSelectionUid: string;
-
- /**
- * Deposit permissions, available once the user has accepted the payment.
- *
- * This value is cached and derived from payCoinSelection.
- *
- * FIXME: Should probably be cached somewhere else, maybe not even in DB!
- */
- coinDepositPermissions: CoinDepositPermission[] | undefined;
}
/**
@@ -1191,11 +1188,8 @@ export interface PurchaseRecord {
/**
* Downloaded and parsed proposal data.
- *
- * FIXME: Move this into another object store,
- * to improve read/write perf on purchases.
*/
- download: ProposalDownload | undefined;
+ download: ProposalDownloadInfo | undefined;
payInfo: PurchasePayInfo | undefined;
diff --git a/packages/taler-wallet-core/src/operations/backup/import.ts b/packages/taler-wallet-core/src/operations/backup/import.ts
index 599b02dea..775a8ac42 100644
--- a/packages/taler-wallet-core/src/operations/backup/import.ts
+++ b/packages/taler-wallet-core/src/operations/backup/import.ts
@@ -45,7 +45,7 @@ import {
DenominationRecord,
DenominationVerificationStatus,
OperationStatus,
- ProposalDownload,
+ ProposalDownloadInfo,
PurchaseStatus,
PurchasePayInfo,
RefreshCoinStatus,
@@ -649,7 +649,7 @@ export async function importBackup(
} else {
maxWireFee = Amounts.getZero(amount.currency);
}
- const download: ProposalDownload = {
+ const download: ProposalDownloadInfo = {
contractTermsHash,
contractTermsMerchantSig: backupPurchase.merchant_sig!,
currency: amount.currency,
@@ -665,7 +665,6 @@ export async function importBackup(
let payInfo: PurchasePayInfo | undefined = undefined;
if (backupPurchase.pay_info) {
payInfo = {
- coinDepositPermissions: undefined,
payCoinSelection: await recoverPayCoinSelection(
tx,
contractData,
diff --git a/packages/taler-wallet-core/src/operations/common.ts b/packages/taler-wallet-core/src/operations/common.ts
index 9f235c9b4..d69bc09f8 100644
--- a/packages/taler-wallet-core/src/operations/common.ts
+++ b/packages/taler-wallet-core/src/operations/common.ts
@@ -25,6 +25,7 @@ import {
RefreshReason,
TalerErrorCode,
TalerErrorDetail,
+ TransactionIdStr,
TransactionType,
} from "@gnu-taler/taler-util";
import { WalletStoresV1, CoinStatus, CoinRecord } from "../db.js";
@@ -37,7 +38,6 @@ import {
OperationAttemptResultType,
RetryInfo,
} from "../util/retries.js";
-import { createRefreshGroup } from "./refresh.js";
const logger = new Logger("operations/common.ts");
@@ -48,7 +48,7 @@ export interface CoinsSpendInfo {
/**
* Identifier for what the coin has been spent for.
*/
- allocationId: string;
+ allocationId: TransactionIdStr;
}
export async function makeCoinAvailable(
diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts b/packages/taler-wallet-core/src/operations/pay-merchant.ts
index d45a93056..233038997 100644
--- a/packages/taler-wallet-core/src/operations/pay-merchant.ts
+++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts
@@ -80,9 +80,8 @@ import {
CoinRecord,
CoinStatus,
DenominationRecord,
- ProposalDownload,
- PurchaseStatus,
PurchaseRecord,
+ PurchaseStatus,
RefundReason,
RefundState,
WalletContractData,
@@ -115,7 +114,6 @@ import {
throwUnexpectedRequestError,
} from "../util/http.js";
import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js";
-import { GetReadOnlyAccess } from "../util/query.js";
import {
OperationAttemptResult,
OperationAttemptResultType,
@@ -124,10 +122,10 @@ import {
scheduleRetry,
} from "../util/retries.js";
import {
+ makeEventId,
spendCoins,
- storeOperationPending,
storeOperationError,
- makeEventId,
+ storeOperationPending,
} from "./common.js";
import { getExchangeDetails } from "./exchanges.js";
import { createRefreshGroup, getTotalRefreshCost } from "./refresh.js";
@@ -858,10 +856,9 @@ async function handleInsufficientFunds(
payInfo.payCoinSelection = res;
payInfo.payCoinSelection = res;
payInfo.payCoinSelectionUid = encodeCrock(getRandomBytes(32));
- payInfo.coinDepositPermissions = undefined;
await tx.purchases.put(p);
await spendCoins(ws, tx, {
- allocationId: `proposal:${p.proposalId}`,
+ allocationId: `tx:proposal:${p.proposalId}`,
coinPubs: payInfo.payCoinSelection.coinPubs,
contributions: payInfo.payCoinSelection.coinContributions,
refreshReason: RefreshReason.PayMerchant,
@@ -1732,14 +1729,13 @@ export async function confirmPay(
payCoinSelection: coinSelection,
payCoinSelectionUid: encodeCrock(getRandomBytes(16)),
totalPayCost: payCostInfo,
- coinDepositPermissions: depositPermissions,
};
p.lastSessionId = sessionId;
p.timestampAccept = TalerProtocolTimestamp.now();
p.purchaseStatus = PurchaseStatus.Paying;
await tx.purchases.put(p);
await spendCoins(ws, tx, {
- allocationId: `proposal:${p.proposalId}`,
+ allocationId: `tx:proposal:${p.proposalId}`,
coinPubs: coinSelection.coinPubs,
contributions: coinSelection.coinContributions,
refreshReason: RefreshReason.PayMerchant,
@@ -1856,17 +1852,12 @@ export async function processPurchasePay(
).href;
let depositPermissions: CoinDepositPermission[];
-
- if (purchase.payInfo?.coinDepositPermissions) {
- depositPermissions = purchase.payInfo.coinDepositPermissions;
- } else {
- // FIXME: also cache!
- depositPermissions = await generateDepositPermissions(
- ws,
- payInfo.payCoinSelection,
- download.contractData,
- );
- }
+ // FIXME: Cache!
+ depositPermissions = await generateDepositPermissions(
+ ws,
+ payInfo.payCoinSelection,
+ download.contractData,
+ );
const reqBody = {
coins: depositPermissions,