commit df67d5dbb205665b57c8f860d79be16c94ba5a68 parent 80c61a93e6c33d771cec95a9acfde43ce7148935 Author: Florian Dold <florian@dold.me> Date: Wed, 13 Dec 2023 08:52:17 +0100 wallet-core: add hint about responsible transaction ID in balance change notification Diffstat:
10 files changed, 52 insertions(+), 11 deletions(-)
diff --git 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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 {