Pass txnbroadcaster to the relevant VM's
MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
@@ -69,7 +69,7 @@ namespace WalletWasabi.Fluent.ViewModels
global.BitcoinStore.SmartHeaderChain,
global.Synchronizer);
- _walletManagerViewModel = new WalletManagerViewModel(global.WalletManager, global.UiConfig, _global.BitcoinStore, _global.LegalChecker);
+ _walletManagerViewModel = new WalletManagerViewModel(global.WalletManager, global.UiConfig, _global.BitcoinStore, _global.LegalChecker, _global.TransactionBroadcaster);
_addWalletPage = new AddWalletPageViewModel(
_walletManagerViewModel,

MODIFY
WalletWasabi.Fluent/ViewModels/WalletManagerViewModel.cs
WalletWasabi.Fluent/ViewModels/WalletManagerViewModel.cs
@@ -9,6 +9,7 @@ using Avalonia.Threading;
using DynamicData;
using DynamicData.Binding;
using ReactiveUI;
+using WalletWasabi.Blockchain.TransactionBroadcasting;
using WalletWasabi.Fluent.ViewModels.NavBar;
using WalletWasabi.Fluent.ViewModels.Wallets;
using WalletWasabi.Fluent.ViewModels.Wallets.Actions;
@@ -35,7 +36,8 @@ namespace WalletWasabi.Fluent.ViewModels
[AutoNotify] private ObservableCollection<WalletViewModelBase> _wallets;
[AutoNotify] private bool _anyWalletStarted;
- public WalletManagerViewModel(WalletManager walletManager, UiConfig uiConfig, BitcoinStore bitcoinStore, LegalChecker legalChecker)
+ public WalletManagerViewModel(WalletManager walletManager, UiConfig uiConfig, BitcoinStore bitcoinStore,
+ LegalChecker legalChecker, TransactionBroadcaster transactionBroadcaster)
{
WalletManager = walletManager;
BitcoinStore = bitcoinStore;
@@ -78,7 +80,7 @@ namespace WalletWasabi.Fluent.ViewModels
}
else if (_walletDictionary[wallet] is ClosedWalletViewModel { IsLoggedIn: true } cwvm && wallet.State == WalletState.Started)
{
- OpenClosedWallet(walletManager, uiConfig, cwvm);
+ OpenClosedWallet(walletManager, uiConfig, transactionBroadcaster, cwvm);
}
}
@@ -94,7 +96,7 @@ namespace WalletWasabi.Fluent.ViewModels
{
WalletViewModelBase vm = (wallet.State <= WalletState.Starting)
? ClosedWalletViewModel.Create(this, wallet)
- : WalletViewModel.Create(uiConfig, wallet);
+ : WalletViewModel.Create(uiConfig, transactionBroadcaster, wallet);
InsertWallet(vm);
});
@@ -140,13 +142,13 @@ namespace WalletWasabi.Fluent.ViewModels
return null;
}
- private void OpenClosedWallet(WalletManager walletManager, UiConfig uiConfig, ClosedWalletViewModel closedWalletViewModel)
+ private void OpenClosedWallet(WalletManager walletManager, UiConfig uiConfig, TransactionBroadcaster broadcaster, ClosedWalletViewModel closedWalletViewModel)
{
IsLoadingWallet = true;
RemoveWallet(closedWalletViewModel);
- var walletViewModelItem = OpenWallet(walletManager, uiConfig, closedWalletViewModel.Wallet);
+ var walletViewModelItem = OpenWallet(walletManager, uiConfig, broadcaster, closedWalletViewModel.Wallet);
if (!_walletActionsDictionary.TryGetValue(walletViewModelItem, out var actions))
{
@@ -163,14 +165,14 @@ namespace WalletWasabi.Fluent.ViewModels
IsLoadingWallet = false;
}
- private WalletViewModel OpenWallet(WalletManager walletManager, UiConfig uiConfig, Wallet wallet)
+ private WalletViewModel OpenWallet(WalletManager walletManager, UiConfig uiConfig, TransactionBroadcaster broadcaster, Wallet wallet)
{
if (_wallets.Any(x => x.Title == wallet.WalletName))
{
throw new Exception("Wallet already opened.");
}
- var walletViewModel = WalletViewModel.Create(uiConfig, wallet);
+ var walletViewModel = WalletViewModel.Create(uiConfig, broadcaster, wallet);
InsertWallet(walletViewModel);

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/HardwareWallet/HardwareWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/HardwareWallet/HardwareWalletViewModel.cs
+using WalletWasabi.Blockchain.TransactionBroadcasting;
using WalletWasabi.Gui;
using WalletWasabi.Wallets;
@@ -5,7 +6,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.HardwareWallet
{
public class HardwareWalletViewModel : WalletViewModel
{
- internal HardwareWalletViewModel(UiConfig uiConfig, Wallet wallet) : base(uiConfig, wallet)
+ internal HardwareWalletViewModel(UiConfig uiConfig, TransactionBroadcaster broadcaster, Wallet wallet) : base(uiConfig, broadcaster, wallet)
{
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/OptimisePrivacyViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/OptimisePrivacyViewModel.cs
@@ -5,6 +5,7 @@ using System.Reactive.Concurrency;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using ReactiveUI;
+using WalletWasabi.Blockchain.TransactionBroadcasting;
using WalletWasabi.Blockchain.TransactionBuilding;
using WalletWasabi.Fluent.ViewModels.Navigation;
using WalletWasabi.Wallets;
@@ -22,7 +23,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
[AutoNotify] private PrivacySuggestionControlViewModel? _selectedPrivacySuggestion;
public OptimisePrivacyViewModel(Wallet wallet,
- TransactionInfo transactionInfo, BuildTransactionResult requestedTransaction)
+ TransactionInfo transactionInfo, TransactionBroadcaster broadcaster, BuildTransactionResult requestedTransaction)
{
_wallet = wallet;
_requestedTransaction = requestedTransaction;
@@ -32,8 +33,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
NextCommand = ReactiveCommand.Create(() =>
{
- Navigate().To(new TransactionPreviewViewModel(wallet, transactionInfo,
- SelectedPrivacySuggestion!.TransactionResult));
+ Navigate().To(new TransactionPreviewViewModel(wallet, transactionInfo, broadcaster, SelectedPrivacySuggestion!.TransactionResult));
}, this.WhenAnyValue(x => x.SelectedPrivacySuggestion).Select(x => x is { }));
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
@@ -123,7 +123,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
mixedCoins.Select(x => x.OutPoint));
// Private coins are enough.
- Navigate().To(new OptimisePrivacyViewModel(wallet, transactionInfo, txRes));
+ Navigate().To(new OptimisePrivacyViewModel(wallet, transactionInfo, walletVm.TransactionBroadcaster, txRes));
return;
}
catch (NotEnoughFundsException)

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
@@ -6,6 +6,7 @@ using NBitcoin;
using ReactiveUI;
using Splat;
using WalletWasabi.Blockchain.Keys;
+using WalletWasabi.Blockchain.TransactionBroadcasting;
using WalletWasabi.Blockchain.TransactionBuilding;
using WalletWasabi.Blockchain.Transactions;
using WalletWasabi.CoinJoin.Client.Clients.Queuing;
@@ -28,7 +29,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
{
private readonly BuildTransactionResult _transaction;
- public TransactionPreviewViewModel(Wallet wallet, TransactionInfo info, BuildTransactionResult transaction)
+ public TransactionPreviewViewModel(Wallet wallet, TransactionInfo info, TransactionBroadcaster broadcaster, BuildTransactionResult transaction)
{
_transaction = transaction;
@@ -122,8 +123,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
}
}
- await Locator.Current.GetService<Global>().TransactionBroadcaster
- .SendTransactionAsync(signedTransaction);
+ await broadcaster.SendTransactionAsync(signedTransaction);
}
else
{

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModel.cs
@@ -5,6 +5,7 @@ using System;
using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq;
+using WalletWasabi.Blockchain.TransactionBroadcasting;
using WalletWasabi.Fluent.ViewModels.Wallets.HardwareWallet;
using WalletWasabi.Fluent.ViewModels.Wallets.WatchOnlyWallet;
using WalletWasabi.Gui;
@@ -15,11 +16,11 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
{
public partial class WalletViewModel : WalletViewModelBase
{
- protected WalletViewModel(UiConfig uiConfig, Wallet wallet) : base(wallet)
+ protected WalletViewModel(UiConfig uiConfig, TransactionBroadcaster broadcaster, Wallet wallet) : base(wallet)
{
Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");
- uiConfig = Locator.Current.GetService<Global>().UiConfig;
+ TransactionBroadcaster = broadcaster;
Observable.Merge(
Observable.FromEventPattern(Wallet.TransactionProcessor, nameof(Wallet.TransactionProcessor.WalletRelevantTransactionProcessed)).Select(_ => Unit.Default))
@@ -49,13 +50,15 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
public override string IconName => "web_asset_regular";
- public static WalletViewModel Create(UiConfig uiConfig, Wallet wallet)
+ public TransactionBroadcaster TransactionBroadcaster { get; }
+
+ public static WalletViewModel Create(UiConfig uiConfig, TransactionBroadcaster broadcaster, Wallet wallet)
{
return wallet.KeyManager.IsHardwareWallet
- ? new HardwareWalletViewModel(uiConfig, wallet)
+ ? new HardwareWalletViewModel(uiConfig, broadcaster, wallet)
: wallet.KeyManager.IsWatchOnly
- ? new WatchOnlyWalletViewModel(uiConfig, wallet)
- : new WalletViewModel(uiConfig, wallet);
+ ? new WatchOnlyWalletViewModel(uiConfig, broadcaster, wallet)
+ : new WalletViewModel(uiConfig, broadcaster, wallet);
}
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/WatchOnlyWallet/WatchOnlyWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/WatchOnlyWallet/WatchOnlyWalletViewModel.cs
+using WalletWasabi.Blockchain.TransactionBroadcasting;
using WalletWasabi.Gui;
using WalletWasabi.Wallets;
@@ -5,7 +6,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.WatchOnlyWallet
{
public class WatchOnlyWalletViewModel : WalletViewModel
{
- internal WatchOnlyWalletViewModel(UiConfig uiConfig, Wallet wallet) : base(uiConfig, wallet)
+ internal WatchOnlyWalletViewModel(UiConfig uiConfig, TransactionBroadcaster broadcaster, Wallet wallet) : base(uiConfig, broadcaster, wallet)
{
}
}

Pass txnbroadcaster to the relevant VM's