commit ed8cd5e545ec8a035c309aad8fedf9343c6ff362
parent 1d6e189d7a715561dadb73fcd25cacbf126f8506
Author: Florian Dold <florian@dold.me>
Date: Fri, 20 Mar 2026 14:31:55 +0100
wallet-core: rename to distinguish user abort/fail transition vs system abort/fail
Diffstat:
13 files changed, 114 insertions(+), 99 deletions(-)
diff --git a/packages/taler-wallet-core/src/common.ts b/packages/taler-wallet-core/src/common.ts
@@ -822,11 +822,36 @@ export namespace TaskIdentifiers {
export interface TransactionContext {
get taskId(): TaskIdStr | undefined;
get transactionId(): TransactionIdStr;
- abortTransaction(reason?: TalerErrorDetail): Promise<void>;
- suspendTransaction(): Promise<void>;
- resumeTransaction(): Promise<void>;
- failTransaction(reason?: TalerErrorDetail): Promise<void>;
- deleteTransaction(): Promise<void>;
+ /**
+ * Handle a user request to abort a transaction.
+ * Only has an effect if the the transaction is
+ * in a state that allows the user to abort.
+ */
+ userAbortTransaction(): Promise<void>;
+ /**
+ * Handle a user request to abort a transaction.
+ * Only has an effect if the the transaction is
+ * in a state that allows the user to suspend.
+ */
+ userSuspendTransaction(): Promise<void>;
+ /**
+ * Handle a user request to abort a transaction.
+ * Only has an effect if the the transaction is
+ * in a state that allows the user to resume.
+ */
+ userResumeTransaction(): Promise<void>;
+ /**
+ * Handle a user request to abort a transaction.
+ * Only has an effect if the the transaction is
+ * in a state that allows the user to fail.
+ */
+ userFailTransaction(): Promise<void>;
+ /**
+ * Handle a user request to abort a transaction.
+ * Only has an effect if the the transaction is
+ * in a state that allows the user to delete.
+ */
+ userDeleteTransaction(): Promise<void>;
lookupFullTransaction(
tx: WalletIndexedDbTransaction,
args?: LookupFullTransactionOpts,
@@ -1100,4 +1125,4 @@ export async function getGenericRecordHandle<T>(
});
};
return [rec, { rec, update }];
-}
-\ No newline at end of file
+}
diff --git a/packages/taler-wallet-core/src/deposits.ts b/packages/taler-wallet-core/src/deposits.ts
@@ -351,7 +351,7 @@ export class DepositTransactionContext implements TransactionContext {
);
}
- async deleteTransaction(): Promise<void> {
+ async userDeleteTransaction(): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
await this.deleteTransactionInTx(tx);
});
@@ -365,7 +365,7 @@ export class DepositTransactionContext implements TransactionContext {
await h.update(undefined);
}
- async suspendTransaction(): Promise<void> {
+ async userSuspendTransaction(): Promise<void> {
const { wex, depositGroupId, transactionId, taskId: retryTag } = this;
await wex.runLegacyWalletDbTx(async (tx) => {
const [dg, h] = await this.getRecordHandle(tx);
@@ -422,7 +422,7 @@ export class DepositTransactionContext implements TransactionContext {
wex.taskScheduler.stopShepherdTask(retryTag);
}
- async abortTransaction(reason?: TalerErrorDetail): Promise<void> {
+ async userAbortTransaction(reason?: TalerErrorDetail): Promise<void> {
const { wex, depositGroupId, transactionId, taskId: retryTag } = this;
await wex.runLegacyWalletDbTx(async (tx) => {
const dg = await tx.depositGroups.get(depositGroupId);
@@ -476,7 +476,7 @@ export class DepositTransactionContext implements TransactionContext {
wex.taskScheduler.startShepherdTask(retryTag);
}
- async resumeTransaction(): Promise<void> {
+ async userResumeTransaction(): Promise<void> {
const { wex, depositGroupId, transactionId, taskId: retryTag } = this;
await wex.runLegacyWalletDbTx(async (tx) => {
const dg = await tx.depositGroups.get(depositGroupId);
@@ -543,7 +543,7 @@ export class DepositTransactionContext implements TransactionContext {
wex.taskScheduler.startShepherdTask(retryTag);
}
- async failTransaction(reason?: TalerErrorDetail): Promise<void> {
+ async userFailTransaction(reason?: TalerErrorDetail): Promise<void> {
const { wex, depositGroupId, transactionId, taskId } = this;
await wex.runLegacyWalletDbTx(async (tx) => {
const dg = await tx.depositGroups.get(depositGroupId);
diff --git a/packages/taler-wallet-core/src/exchanges.ts b/packages/taler-wallet-core/src/exchanges.ts
@@ -2504,23 +2504,23 @@ export class DenomLossTransactionContext implements TransactionContext {
});
}
- abortTransaction(): Promise<void> {
+ userAbortTransaction(): Promise<void> {
throw new Error("Method not implemented.");
}
- suspendTransaction(): Promise<void> {
+ userSuspendTransaction(): Promise<void> {
throw new Error("Method not implemented.");
}
- resumeTransaction(): Promise<void> {
+ userResumeTransaction(): Promise<void> {
throw new Error("Method not implemented.");
}
- failTransaction(): Promise<void> {
+ userFailTransaction(): Promise<void> {
throw new Error("Method not implemented.");
}
- async deleteTransaction(): Promise<void> {
+ async userDeleteTransaction(): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
const rec = await tx.denomLossEvents.get(this.denomLossEventId);
if (!rec) {
diff --git a/packages/taler-wallet-core/src/pay-merchant.ts b/packages/taler-wallet-core/src/pay-merchant.ts
@@ -373,7 +373,7 @@ export class PayMerchantTransactionContext implements TransactionContext {
};
}
- async deleteTransaction(): Promise<void> {
+ async userDeleteTransaction(): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
return this.deleteTransactionInTx(tx);
});
@@ -418,7 +418,7 @@ export class PayMerchantTransactionContext implements TransactionContext {
await h.update(undefined);
}
- async suspendTransaction(): Promise<void> {
+ async userSuspendTransaction(): Promise<void> {
const { wex } = this;
wex.taskScheduler.stopShepherdTask(this.taskId);
await wex.runLegacyWalletDbTx(async (tx) => {
@@ -435,7 +435,7 @@ export class PayMerchantTransactionContext implements TransactionContext {
});
}
- async abortTransaction(reason?: TalerErrorDetail): Promise<void> {
+ async userAbortTransaction(reason?: TalerErrorDetail): Promise<void> {
const { wex } = this;
await wex.runLegacyWalletDbTx(async (tx) => {
const [purchase, h] = await this.getRecordHandle(tx);
@@ -474,7 +474,7 @@ export class PayMerchantTransactionContext implements TransactionContext {
wex.taskScheduler.startShepherdTask(this.taskId);
}
- async resumeTransaction(): Promise<void> {
+ async userResumeTransaction(): Promise<void> {
const { wex } = this;
await wex.runLegacyWalletDbTx(async (tx) => {
const [purchase, h] = await this.getRecordHandle(tx);
@@ -491,7 +491,7 @@ export class PayMerchantTransactionContext implements TransactionContext {
wex.taskScheduler.startShepherdTask(this.taskId);
}
- async failTransaction(reason?: TalerErrorDetail): Promise<void> {
+ async userFailTransaction(reason?: TalerErrorDetail): Promise<void> {
const { wex } = this;
await wex.runLegacyWalletDbTx(async (tx) => {
const [purchase, h] = await this.getRecordHandle(tx);
@@ -685,7 +685,7 @@ export class RefundTransactionContext implements TransactionContext {
};
}
- async deleteTransaction(): Promise<void> {
+ async userDeleteTransaction(): Promise<void> {
const { wex } = this;
const res = await wex.runLegacyWalletDbTx(async (tx) => {
@@ -718,19 +718,19 @@ export class RefundTransactionContext implements TransactionContext {
return { notifs };
}
- suspendTransaction(): Promise<void> {
+ userSuspendTransaction(): Promise<void> {
throw new Error("Unsupported operation");
}
- abortTransaction(): Promise<void> {
+ userAbortTransaction(): Promise<void> {
throw new Error("Unsupported operation");
}
- resumeTransaction(): Promise<void> {
+ userResumeTransaction(): Promise<void> {
throw new Error("Unsupported operation");
}
- failTransaction(): Promise<void> {
+ userFailTransaction(): Promise<void> {
throw new Error("Unsupported operation");
}
}
@@ -1668,7 +1668,7 @@ async function handleInsufficientFunds(
logger.trace("got exchange error reply (see below)");
logger.trace(j2s(exchangeReply));
}
- await ctx.abortTransaction({
+ await ctx.userAbortTransaction({
code: TalerErrorCode.WALLET_TRANSACTION_PROTOCOL_VIOLATION,
message: `unable to handle /pay exchange error response (${exchangeReply.code})`,
exchangeReply,
@@ -1680,7 +1680,7 @@ async function handleInsufficientFunds(
logger.trace(`excluded broken coin pub=${brokenCoinPub}`);
if (!brokenCoinPub) {
- await ctx.abortTransaction({
+ await ctx.userAbortTransaction({
code: TalerErrorCode.WALLET_TRANSACTION_PROTOCOL_VIOLATION,
message: "Exchange claimed bad coin, but coin was not used.",
brokenCoinPub,
@@ -1692,7 +1692,7 @@ async function handleInsufficientFunds(
TalerErrorCode.MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_KEY_NOT_FOUND
) {
// We might support this in the future.
- await ctx.abortTransaction({
+ await ctx.userAbortTransaction({
code: TalerErrorCode.WALLET_TRANSACTION_PROTOCOL_VIOLATION,
message: "Denomination used in payment became invalid.",
errorDetails: err,
@@ -3317,7 +3317,7 @@ async function processPurchasePay(
case TalerErrorCode.EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN:
// We might want to handle this in the future by re-denomination,
// for now we just abort.
- await ctx.abortTransaction({
+ await ctx.userAbortTransaction({
code: TalerErrorCode.WALLET_TRANSACTION_PROTOCOL_VIOLATION,
message: "Denomination used in payment became invalid.",
errorDetails: err,
@@ -3333,7 +3333,7 @@ async function processPurchasePay(
if (resp.status === HttpStatusCode.UnavailableForLegalReasons) {
logger.warn(`pay transaction aborted, merchant has KYC problems`);
- await ctx.abortTransaction(
+ await ctx.userAbortTransaction(
makeTalerErrorDetail(TalerErrorCode.WALLET_PAY_MERCHANT_KYC_MISSING, {
exchangeResponse: await resp.json(),
}),
@@ -3343,7 +3343,7 @@ async function processPurchasePay(
if (resp.status === HttpStatusCode.Gone) {
logger.warn(`pay transaction aborted, order expired`);
- await ctx.abortTransaction(
+ await ctx.userAbortTransaction(
makeTalerErrorDetail(TalerErrorCode.WALLET_PAY_MERCHANT_ORDER_GONE, {}),
);
return TaskRunResult.progress();
diff --git a/packages/taler-wallet-core/src/pay-peer-pull-credit.ts b/packages/taler-wallet-core/src/pay-peer-pull-credit.ts
@@ -303,13 +303,13 @@ export class PeerPullCreditTransactionContext implements TransactionContext {
);
}
- async deleteTransaction(): Promise<void> {
+ async userDeleteTransaction(): Promise<void> {
const res = await this.wex.runLegacyWalletDbTx(async (tx) => {
await this.deleteTransactionInTx(tx);
});
}
- async suspendTransaction(): Promise<void> {
+ async userSuspendTransaction(): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [rec, h] = await this.getRecordHandle(tx);
if (!rec) {
@@ -357,7 +357,7 @@ export class PeerPullCreditTransactionContext implements TransactionContext {
this.wex.taskScheduler.stopShepherdTask(this.taskId);
}
- async failTransaction(reason?: TalerErrorDetail): Promise<void> {
+ async userFailTransaction(reason?: TalerErrorDetail): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [rec, h] = await this.getRecordHandle(tx);
if (!rec) {
@@ -394,7 +394,7 @@ export class PeerPullCreditTransactionContext implements TransactionContext {
this.wex.taskScheduler.stopShepherdTask(this.taskId);
}
- async resumeTransaction(): Promise<void> {
+ async userResumeTransaction(): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [rec, h] = await this.getRecordHandle(tx);
if (!rec) {
@@ -442,7 +442,7 @@ export class PeerPullCreditTransactionContext implements TransactionContext {
this.wex.taskScheduler.startShepherdTask(this.taskId);
}
- async abortTransaction(reason?: TalerErrorDetail): Promise<void> {
+ async userAbortTransaction(reason?: TalerErrorDetail): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [rec, h] = await this.getRecordHandle(tx);
if (!rec) {
@@ -517,7 +517,7 @@ async function queryPurseForPeerPullCredit(
});
return TaskRunResult.finished();
case HttpStatusCode.NotFound:
- await ctx.failTransaction(resp.detail);
+ await ctx.userFailTransaction(resp.detail);
return TaskRunResult.finished();
default:
assertUnreachable(resp);
@@ -663,7 +663,7 @@ async function processPeerPullCreditAbortingDeletePurse(
});
return TaskRunResult.finished();
case HttpStatusCode.Forbidden:
- await ctx.failTransaction(resp.detail);
+ await ctx.userFailTransaction(resp.detail);
return TaskRunResult.finished();
case HttpStatusCode.Conflict:
// FIXME check if done ?
@@ -848,15 +848,15 @@ async function processPeerPullCreditCreatePurse(
}
case HttpStatusCode.Forbidden:
case HttpStatusCode.NotFound:
- await ctx.failTransaction(resp.detail);
+ await ctx.userFailTransaction(resp.detail);
return TaskRunResult.finished();
case HttpStatusCode.Conflict:
- await ctx.failTransaction({ code: resp.body.code });
+ await ctx.userFailTransaction({ code: resp.body.code });
return TaskRunResult.finished();
case HttpStatusCode.PaymentRequired:
throw Error(`unexpected reserve merge response ${resp.case}`);
case TalerErrorCode.EXCHANGE_RESERVES_PURSE_EXPIRATION_BEFORE_NOW:
- await ctx.failTransaction(
+ await ctx.userFailTransaction(
resp.detail ? { code: resp.detail?.code } : undefined,
);
return TaskRunResult.finished();
diff --git a/packages/taler-wallet-core/src/pay-peer-pull-debit.ts b/packages/taler-wallet-core/src/pay-peer-pull-debit.ts
@@ -201,7 +201,7 @@ export class PeerPullDebitTransactionContext implements TransactionContext {
);
}
- async deleteTransaction(): Promise<void> {
+ async userDeleteTransaction(): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
await this.deleteTransactionInTx(tx);
});
@@ -217,7 +217,7 @@ export class PeerPullDebitTransactionContext implements TransactionContext {
h.update(undefined);
}
- async suspendTransaction(): Promise<void> {
+ async userSuspendTransaction(): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [rec, h] = await this.getRecordHandle(tx);
if (!rec) {
@@ -245,7 +245,7 @@ export class PeerPullDebitTransactionContext implements TransactionContext {
this.wex.taskScheduler.stopShepherdTask(this.taskId);
}
- async resumeTransaction(): Promise<void> {
+ async userResumeTransaction(): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [rec, h] = await this.getRecordHandle(tx);
if (!rec) {
@@ -271,7 +271,7 @@ export class PeerPullDebitTransactionContext implements TransactionContext {
this.wex.taskScheduler.startShepherdTask(this.taskId);
}
- async failTransaction(reason?: TalerErrorDetail): Promise<void> {
+ async userFailTransaction(reason?: TalerErrorDetail): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [rec, h] = await this.getRecordHandle(tx);
if (!rec) {
@@ -294,7 +294,7 @@ export class PeerPullDebitTransactionContext implements TransactionContext {
this.wex.taskScheduler.stopShepherdTask(this.taskId);
}
- async abortTransaction(reason?: TalerErrorDetail): Promise<void> {
+ async userAbortTransaction(reason?: TalerErrorDetail): Promise<void> {
const oldRec = await this.wex.runLegacyWalletDbTx(async (tx) => {
const [rec, _] = await this.getRecordHandle(tx);
return rec;
@@ -356,7 +356,7 @@ async function handlePurseCreationConflict(
conflict: PurseConflict,
): Promise<TaskRunResult> {
if (conflict.code !== TalerErrorCode.EXCHANGE_GENERIC_INSUFFICIENT_FUNDS) {
- await ctx.failTransaction();
+ await ctx.userFailTransaction();
return TaskRunResult.finished();
}
@@ -470,7 +470,7 @@ async function processPeerPullDebitDialogProposed(
});
return TaskRunResult.finished();
case HttpStatusCode.NotFound:
- await ctx.failTransaction(resp.detail);
+ await ctx.userFailTransaction(resp.detail);
return TaskRunResult.finished();
default:
assertUnreachable(resp);
@@ -612,7 +612,7 @@ async function processPeerPullDebitPendingDeposit(
case "ok":
continue;
case HttpStatusCode.Gone: {
- await ctx.abortTransaction(
+ await ctx.userAbortTransaction(
makeTalerErrorDetail(
TalerErrorCode.WALLET_PEER_PULL_DEBIT_PURSE_GONE,
{},
@@ -624,7 +624,7 @@ async function processPeerPullDebitPendingDeposit(
return handlePurseCreationConflict(ctx, peerPullInc, resp.body);
case HttpStatusCode.Forbidden:
case HttpStatusCode.NotFound:
- await ctx.failTransaction(resp.detail);
+ await ctx.userFailTransaction(resp.detail);
return TaskRunResult.finished();
default:
assertUnreachable(resp);
diff --git a/packages/taler-wallet-core/src/pay-peer-push-credit.ts b/packages/taler-wallet-core/src/pay-peer-push-credit.ts
@@ -277,7 +277,7 @@ export class PeerPushCreditTransactionContext implements TransactionContext {
);
}
- async deleteTransaction(): Promise<void> {
+ async userDeleteTransaction(): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) =>
this.deleteTransactionInTx(tx),
);
@@ -301,7 +301,7 @@ export class PeerPushCreditTransactionContext implements TransactionContext {
}
}
- async suspendTransaction(): Promise<void> {
+ async userSuspendTransaction(): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [rec, h] = await this.getRecordHandle(tx);
if (!rec) {
@@ -343,7 +343,7 @@ export class PeerPushCreditTransactionContext implements TransactionContext {
this.wex.taskScheduler.stopShepherdTask(this.taskId);
}
- async abortTransaction(): Promise<void> {
+ async userAbortTransaction(): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [rec, h] = await this.getRecordHandle(tx);
if (!rec) {
@@ -376,7 +376,7 @@ export class PeerPushCreditTransactionContext implements TransactionContext {
this.wex.taskScheduler.stopShepherdTask(this.taskId);
}
- async resumeTransaction(): Promise<void> {
+ async userResumeTransaction(): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [rec, h] = await this.getRecordHandle(tx);
if (!rec) {
@@ -418,7 +418,7 @@ export class PeerPushCreditTransactionContext implements TransactionContext {
this.wex.taskScheduler.startShepherdTask(this.taskId);
}
- async failTransaction(reason?: TalerErrorDetail): Promise<void> {
+ async userFailTransaction(reason?: TalerErrorDetail): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [rec, h] = await this.getRecordHandle(tx);
if (!rec) {
@@ -888,7 +888,7 @@ async function processPendingMerge(
return TaskRunResult.finished();
case HttpStatusCode.Forbidden:
case HttpStatusCode.NotFound:
- await ctx.failTransaction(mergeResp.detail);
+ await ctx.userFailTransaction(mergeResp.detail);
return TaskRunResult.finished();
default:
assertUnreachable(mergeResp);
@@ -1039,7 +1039,7 @@ async function processPeerPushDebitDialogProposed(
});
return TaskRunResult.finished();
case HttpStatusCode.NotFound:
- await ctx.failTransaction(resp.detail);
+ await ctx.userFailTransaction(resp.detail);
return TaskRunResult.finished();
default:
assertUnreachable(resp);
diff --git a/packages/taler-wallet-core/src/pay-peer-push-debit.ts b/packages/taler-wallet-core/src/pay-peer-push-debit.ts
@@ -213,7 +213,7 @@ export class PeerPushDebitTransactionContext implements TransactionContext {
);
}
- async deleteTransaction(): Promise<void> {
+ async userDeleteTransaction(): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
await this.deleteTransactionInTx(tx);
});
@@ -229,7 +229,7 @@ export class PeerPushDebitTransactionContext implements TransactionContext {
await h.update(undefined);
}
- async suspendTransaction(): Promise<void> {
+ async userSuspendTransaction(): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [rec, h] = await this.getRecordHandle(tx);
if (!rec) {
@@ -262,7 +262,7 @@ export class PeerPushDebitTransactionContext implements TransactionContext {
this.wex.taskScheduler.stopShepherdTask(this.taskId);
}
- async abortTransaction(reason?: TalerErrorDetail): Promise<void> {
+ async userAbortTransaction(reason?: TalerErrorDetail): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [rec, h] = await this.getRecordHandle(tx);
if (!rec) {
@@ -297,7 +297,7 @@ export class PeerPushDebitTransactionContext implements TransactionContext {
this.wex.taskScheduler.startShepherdTask(this.taskId);
}
- async resumeTransaction(): Promise<void> {
+ async userResumeTransaction(): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [rec, h] = await this.getRecordHandle(tx);
if (!rec) {
@@ -330,7 +330,7 @@ export class PeerPushDebitTransactionContext implements TransactionContext {
this.wex.taskScheduler.startShepherdTask(this.taskId);
}
- async failTransaction(reason?: TalerErrorDetail): Promise<void> {
+ async userFailTransaction(reason?: TalerErrorDetail): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [rec, h] = await this.getRecordHandle(tx);
if (!rec) {
@@ -477,7 +477,7 @@ async function handlePurseCreationConflict(
const pursePub = peerPushInitiation.pursePub;
const ctx = new PeerPushDebitTransactionContext(wex, pursePub);
if (conflict.code !== TalerErrorCode.EXCHANGE_GENERIC_INSUFFICIENT_FUNDS) {
- await ctx.failTransaction();
+ await ctx.userFailTransaction();
return TaskRunResult.finished();
}
@@ -700,7 +700,7 @@ async function processPeerPushDebitCreateReserve(
continue;
case HttpStatusCode.Forbidden:
case HttpStatusCode.NotFound:
- await ctx.failTransaction(resp.detail);
+ await ctx.userFailTransaction(resp.detail);
return TaskRunResult.finished();
case HttpStatusCode.Conflict:
return handlePurseCreationConflict(
@@ -752,7 +752,7 @@ async function processPeerPushDebitCreateReserve(
);
case HttpStatusCode.Forbidden:
case HttpStatusCode.NotFound:
- await ctx.failTransaction(resp.detail);
+ await ctx.userFailTransaction(resp.detail);
return TaskRunResult.finished();
default:
assertUnreachable(resp);
@@ -799,7 +799,7 @@ async function processPeerPushDebitCreateReserve(
});
return TaskRunResult.progress();
case HttpStatusCode.NotFound:
- await ctx.failTransaction(resp.detail);
+ await ctx.userFailTransaction(resp.detail);
return TaskRunResult.finished();
default:
assertUnreachable(resp);
@@ -825,7 +825,7 @@ async function processPeerPushDebitAbortingDeletePurse(
case HttpStatusCode.Conflict:
throw Error("purse deletion conflict");
case HttpStatusCode.Forbidden:
- await ctx.failTransaction(resp.detail);
+ await ctx.userFailTransaction(resp.detail);
return TaskRunResult.finished();
}
diff --git a/packages/taler-wallet-core/src/recoup.ts b/packages/taler-wallet-core/src/recoup.ts
@@ -440,23 +440,23 @@ export class RecoupTransactionContext implements TransactionContext {
});
}
- abortTransaction(): Promise<void> {
+ userAbortTransaction(): Promise<void> {
throw new Error("Method not implemented.");
}
- suspendTransaction(): Promise<void> {
+ userSuspendTransaction(): Promise<void> {
throw new Error("Method not implemented.");
}
- resumeTransaction(): Promise<void> {
+ userResumeTransaction(): Promise<void> {
throw new Error("Method not implemented.");
}
- failTransaction(): Promise<void> {
+ userFailTransaction(): Promise<void> {
throw new Error("Method not implemented.");
}
- async deleteTransaction(): Promise<void> {
+ async userDeleteTransaction(): Promise<void> {
const res = await this.wex.runLegacyWalletDbTx(async (tx) => {
return this.deleteTransactionInTx(tx);
});
diff --git a/packages/taler-wallet-core/src/refresh.ts b/packages/taler-wallet-core/src/refresh.ts
@@ -236,7 +236,7 @@ export class RefreshTransactionContext implements TransactionContext {
);
}
- async deleteTransaction(): Promise<void> {
+ async userDeleteTransaction(): Promise<void> {
const res = await this.wex.runLegacyWalletDbTx(async (tx) => {
return this.deleteTransactionInTx(tx);
});
@@ -260,7 +260,7 @@ export class RefreshTransactionContext implements TransactionContext {
await tx.refreshGroups.delete(rg.refreshGroupId);
}
- async suspendTransaction(): Promise<void> {
+ async userSuspendTransaction(): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [rec, h] = await this.getRecordHandle(tx);
if (!rec) {
@@ -288,12 +288,12 @@ export class RefreshTransactionContext implements TransactionContext {
});
}
- async abortTransaction(): Promise<void> {
+ async userAbortTransaction(): Promise<void> {
// Refresh transactions only support fail, not abort.
throw new Error("refresh transactions cannot be aborted");
}
- async resumeTransaction(): Promise<void> {
+ async userResumeTransaction(): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [rec, h] = await this.getRecordHandle(tx);
if (!rec) {
@@ -321,7 +321,7 @@ export class RefreshTransactionContext implements TransactionContext {
});
}
- async failTransaction(reason?: TalerErrorDetail): Promise<void> {
+ async userFailTransaction(reason?: TalerErrorDetail): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [rec, h] = await this.getRecordHandle(tx);
if (!rec) {
diff --git a/packages/taler-wallet-core/src/shepherd.ts b/packages/taler-wallet-core/src/shepherd.ts
@@ -1165,7 +1165,7 @@ export async function processCleanupExpiredTransactions(
)
) {
const ctx = new PayMerchantTransactionContext(wex, exp.proposalId);
- await ctx.deleteTransaction();
+ await ctx.userDeleteTransaction();
}
}
});
diff --git a/packages/taler-wallet-core/src/transactions.ts b/packages/taler-wallet-core/src/transactions.ts
@@ -29,10 +29,8 @@ import {
GetTransactionsV2Request,
j2s,
Logger,
- makeTalerErrorDetail,
NotificationType,
ScopeType,
- TalerErrorCode,
Transaction,
TransactionByIdRequest,
TransactionIdStr,
@@ -883,7 +881,7 @@ export async function suspendTransaction(
transactionId: string,
): Promise<void> {
const ctx = await getContextForTransaction(wex, transactionId);
- await ctx.suspendTransaction();
+ await ctx.userSuspendTransaction();
}
export async function failTransaction(
@@ -891,12 +889,7 @@ export async function failTransaction(
transactionId: string,
): Promise<void> {
const ctx = await getContextForTransaction(wex, transactionId);
- await ctx.failTransaction(
- makeTalerErrorDetail(
- TalerErrorCode.WALLET_TRANSACTION_ABANDONED_BY_USER,
- {},
- ),
- );
+ await ctx.userFailTransaction();
}
/**
@@ -907,7 +900,7 @@ export async function resumeTransaction(
transactionId: string,
): Promise<void> {
const ctx = await getContextForTransaction(wex, transactionId);
- await ctx.resumeTransaction();
+ await ctx.userResumeTransaction();
}
/**
@@ -918,7 +911,7 @@ export async function deleteTransaction(
transactionId: string,
): Promise<void> {
const ctx = await getContextForTransaction(wex, transactionId);
- await ctx.deleteTransaction();
+ await ctx.userDeleteTransaction();
if (ctx.taskId) {
wex.taskScheduler.stopShepherdTask(ctx.taskId);
}
@@ -929,9 +922,7 @@ export async function abortTransaction(
transactionId: string,
): Promise<void> {
const ctx = await getContextForTransaction(wex, transactionId);
- await ctx.abortTransaction(
- makeTalerErrorDetail(TalerErrorCode.WALLET_TRANSACTION_ABORTED_BY_USER, {}),
- );
+ await ctx.userAbortTransaction();
}
export interface TransitionInfo {
diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts
@@ -497,7 +497,7 @@ export class WithdrawTransactionContext implements TransactionContext {
);
}
- async deleteTransaction(): Promise<void> {
+ async userDeleteTransaction(): Promise<void> {
await this.wex.runLegacyWalletDbTx(async (tx) => {
return this.deleteTransactionInTx(tx);
});
@@ -519,7 +519,7 @@ export class WithdrawTransactionContext implements TransactionContext {
await h.update(undefined);
}
- async suspendTransaction(): Promise<void> {
+ async userSuspendTransaction(): Promise<void> {
const { withdrawalGroupId } = this;
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [wg, h] = await this.getRecordHandle(tx);
@@ -558,7 +558,7 @@ export class WithdrawTransactionContext implements TransactionContext {
});
}
- async abortTransaction(reason?: TalerErrorDetail): Promise<void> {
+ async userAbortTransaction(reason?: TalerErrorDetail): Promise<void> {
const { withdrawalGroupId } = this;
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [wg, h] = await this.getRecordHandle(tx);
@@ -615,7 +615,7 @@ export class WithdrawTransactionContext implements TransactionContext {
});
}
- async resumeTransaction(): Promise<void> {
+ async userResumeTransaction(): Promise<void> {
const { withdrawalGroupId } = this;
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [wg, h] = await this.getRecordHandle(tx);
@@ -654,7 +654,7 @@ export class WithdrawTransactionContext implements TransactionContext {
});
}
- async failTransaction(reason?: TalerErrorDetail): Promise<void> {
+ async userFailTransaction(reason?: TalerErrorDetail): Promise<void> {
const { withdrawalGroupId } = this;
await this.wex.runLegacyWalletDbTx(async (tx) => {
const [wg, h] = await this.getRecordHandle(tx);