From 9e16b506e517e99daa8cdfbf0e2d80f23993082a Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Mon, 1 Jun 2020 13:10:21 +0900 Subject: [PATCH] Small esthetic refacotring --- .../Controllers/WalletsController.PSBT.cs | 15 +----------- .../TransactionLabelMarkerHostedService.cs | 23 ++++++++++++++----- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/BTCPayServer/Controllers/WalletsController.PSBT.cs b/BTCPayServer/Controllers/WalletsController.PSBT.cs index 3cfb8aa6e..5a2c26116 100644 --- a/BTCPayServer/Controllers/WalletsController.PSBT.cs +++ b/BTCPayServer/Controllers/WalletsController.PSBT.cs @@ -330,20 +330,7 @@ namespace BTCPayServer.Controllers vm.SigningContext.OriginalPSBT = psbt.ToBase64(); proposedPayjoin.Finalize(); var hash = proposedPayjoin.ExtractTransaction().GetHash(); - _EventAggregator.Publish(new UpdateTransactionLabel() - { - WalletId = walletId, - TransactionLabels = new Dictionary>() - { - { - hash, - new List<(string color, string label)> - { - UpdateTransactionLabel.PayjoinLabelTemplate() - } - } - } - }); + _EventAggregator.Publish(new UpdateTransactionLabel(walletId, hash, UpdateTransactionLabel.PayjoinLabelTemplate())); TempData.SetStatusMessageModel(new StatusMessageModel() { Severity = StatusMessageModel.StatusSeverity.Success, diff --git a/BTCPayServer/HostedServices/TransactionLabelMarkerHostedService.cs b/BTCPayServer/HostedServices/TransactionLabelMarkerHostedService.cs index 690e2b2d3..80e718641 100644 --- a/BTCPayServer/HostedServices/TransactionLabelMarkerHostedService.cs +++ b/BTCPayServer/HostedServices/TransactionLabelMarkerHostedService.cs @@ -50,12 +50,7 @@ namespace BTCPayServer.HostedServices labels.Add(UpdateTransactionLabel.PayjoinLabelTemplate()); } - _eventAggregator.Publish(new UpdateTransactionLabel() - { - WalletId = walletId, - TransactionLabels = - new Dictionary>() {{transactionId, labels}} - }); + _eventAggregator.Publish(new UpdateTransactionLabel(walletId, transactionId, labels)); } else if (evt is UpdateTransactionLabel updateTransactionLabel) { @@ -96,6 +91,22 @@ namespace BTCPayServer.HostedServices public class UpdateTransactionLabel { + public UpdateTransactionLabel() + { + + } + public UpdateTransactionLabel(WalletId walletId, uint256 txId, (string color, string label) colorLabel) + { + WalletId = walletId; + TransactionLabels = new Dictionary>(); + TransactionLabels.Add(txId, new List<(string color, string label)>() { colorLabel }); + } + public UpdateTransactionLabel(WalletId walletId, uint256 txId, List<(string color, string label)> colorLabels) + { + WalletId = walletId; + TransactionLabels = new Dictionary>(); + TransactionLabels.Add(txId, colorLabels); + } public static (string color, string label) PayjoinLabelTemplate() { return ("#51b13e", "payjoin");