From df67d5dbb205665b57c8f860d79be16c94ba5a68 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 13 Dec 2023 08:52:17 +0100 Subject: wallet-core: add hint about responsible transaction ID in balance change notification --- packages/taler-util/src/notifications.ts | 7 +++++++ packages/taler-wallet-core/src/operations/deposits.ts | 1 + packages/taler-wallet-core/src/operations/pay-merchant.ts | 13 +++++++++++-- .../src/operations/pay-peer-pull-credit.ts | 5 ++++- .../taler-wallet-core/src/operations/pay-peer-pull-debit.ts | 7 +++++-- .../src/operations/pay-peer-push-credit.ts | 5 ++++- .../taler-wallet-core/src/operations/pay-peer-push-debit.ts | 5 ++++- packages/taler-wallet-core/src/operations/refresh.ts | 10 ++++++++-- packages/taler-wallet-core/src/operations/reward.ts | 5 ++++- packages/taler-wallet-core/src/operations/withdraw.ts | 5 ++++- 10 files changed, 52 insertions(+), 11 deletions(-) (limited to 'packages') diff --git a/packages/taler-util/src/notifications.ts b/packages/taler-util/src/notifications.ts index 571d8f036..179b6b383 100644 --- a/packages/taler-util/src/notifications.ts +++ b/packages/taler-util/src/notifications.ts @@ -79,6 +79,13 @@ export interface ExchangeStateTransitionNotification { export interface BalanceChangeNotification { type: NotificationType.BalanceChange; + + /** + * Transaction ID of the transaction that caused the balance update. + * + * Only used as a hint for debugging, should not be relied upon by clients. + */ + hintTransactionId: string; } export interface BackupOperationErrorNotification { diff --git a/packages/taler-wallet-core/src/operations/deposits.ts b/packages/taler-wallet-core/src/operations/deposits.ts index de413a514..057450b78 100644 --- a/packages/taler-wallet-core/src/operations/deposits.ts +++ b/packages/taler-wallet-core/src/operations/deposits.ts @@ -1449,6 +1449,7 @@ export async function createDepositGroup( ws.notify({ type: NotificationType.BalanceChange, + hintTransactionId: transactionId, }); return { diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts b/packages/taler-wallet-core/src/operations/pay-merchant.ts index b3ea5b3fe..2d364a866 100644 --- a/packages/taler-wallet-core/src/operations/pay-merchant.ts +++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts @@ -933,7 +933,13 @@ async function handleInsufficientFunds( }); }); - ws.notify({ type: NotificationType.BalanceChange }); + ws.notify({ + type: NotificationType.BalanceChange, + hintTransactionId: constructTransactionIdentifier({ + tag: TransactionType.Payment, + proposalId, + }), + }); } async function unblockBackup( @@ -1482,7 +1488,10 @@ export async function confirmPay( }); notifyTransition(ws, transactionId, transitionInfo); - ws.notify({ type: NotificationType.BalanceChange }); + ws.notify({ + type: NotificationType.BalanceChange, + hintTransactionId: transactionId, + }); return runPayForConfirmPay(ws, proposalId); } diff --git a/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts b/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts index f8ab07b10..ec482b2dd 100644 --- a/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts +++ b/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts @@ -833,7 +833,10 @@ export async function initiatePeerPullPayment( }); // The pending-incoming balance has changed. - ws.notify({ type: NotificationType.BalanceChange }); + ws.notify({ + type: NotificationType.BalanceChange, + hintTransactionId: transactionId, + }); notifyTransition(ws, transactionId, transitionInfo); diff --git a/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts b/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts index cf5fc355d..72e9e2e4a 100644 --- a/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts +++ b/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts @@ -460,13 +460,16 @@ export async function confirmPeerPullDebit( return pi; }); - ws.notify({ type: NotificationType.BalanceChange }); - const transactionId = constructTransactionIdentifier({ tag: TransactionType.PeerPullDebit, peerPullDebitId, }); + ws.notify({ + type: NotificationType.BalanceChange, + hintTransactionId: transactionId, + }); + return { transactionId, }; diff --git a/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts b/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts index 1174ccc8e..78263c4c3 100644 --- a/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts +++ b/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts @@ -234,7 +234,10 @@ export async function preparePeerPushCredit( notifyTransition(ws, transactionId, transitionInfo); - ws.notify({ type: NotificationType.BalanceChange }); + ws.notify({ + type: NotificationType.BalanceChange, + hintTransactionId: transactionId, + }); return { amount: purseStatus.balance, diff --git a/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts b/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts index 534114ed8..3eed52b91 100644 --- a/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts +++ b/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts @@ -696,7 +696,10 @@ export async function initiatePeerPushDebit( }; }); notifyTransition(ws, transactionId, transitionInfo); - ws.notify({ type: NotificationType.BalanceChange }); + ws.notify({ + type: NotificationType.BalanceChange, + hintTransactionId: transactionId, + }); return { contractPriv: contractKeyPair.priv, diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts index e5bc3277d..c58f03e05 100644 --- a/packages/taler-wallet-core/src/operations/refresh.ts +++ b/packages/taler-wallet-core/src/operations/refresh.ts @@ -295,7 +295,10 @@ async function provideRefreshSession( const newTxState = computeRefreshTransactionState(rg); return { oldTxState, newTxState }; }); - ws.notify({ type: NotificationType.BalanceChange }); + ws.notify({ + type: NotificationType.BalanceChange, + hintTransactionId: transactionId, + }); notifyTransition(ws, transactionId, transitionInfo); return; } @@ -509,7 +512,10 @@ async function refreshMelt( newTxState, }; }); - ws.notify({ type: NotificationType.BalanceChange }); + ws.notify({ + type: NotificationType.BalanceChange, + hintTransactionId: transactionId, + }); notifyTransition(ws, transactionId, transitionInfo); return; } diff --git a/packages/taler-wallet-core/src/operations/reward.ts b/packages/taler-wallet-core/src/operations/reward.ts index 90320d7cb..a1bf13ec4 100644 --- a/packages/taler-wallet-core/src/operations/reward.ts +++ b/packages/taler-wallet-core/src/operations/reward.ts @@ -429,7 +429,10 @@ export async function processTip( return { oldTxState, newTxState }; }); notifyTransition(ws, transactionId, transitionInfo); - ws.notify({ type: NotificationType.BalanceChange }); + ws.notify({ + type: NotificationType.BalanceChange, + hintTransactionId: transactionId, + }); return TaskRunResult.finished(); } diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts index e7ba6d820..8a718dd49 100644 --- a/packages/taler-wallet-core/src/operations/withdraw.ts +++ b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -1642,7 +1642,10 @@ async function processWithdrawalGroupPendingReady( } notifyTransition(ws, transactionId, res.transitionInfo); - ws.notify({ type: NotificationType.BalanceChange }); + ws.notify({ + type: NotificationType.BalanceChange, + hintTransactionId: transactionId, + }); if (numPlanchetErrors > 0) { return { -- cgit v1.2.3