Simplify passing of txnbroadcaster references
MODIFY
WalletWasabi.Fluent/ViewModels/WalletManagerViewModel.cs
WalletWasabi.Fluent/ViewModels/WalletManagerViewModel.cs
@@ -28,6 +28,7 @@ namespace WalletWasabi.Fluent.ViewModels
private readonly Dictionary<Wallet, WalletViewModelBase> _walletDictionary;
private readonly Dictionary<WalletViewModelBase, List<NavBarItemViewModel>> _walletActionsDictionary;
private readonly ReadOnlyObservableCollection<NavBarItemViewModel> _items;
+ private readonly TransactionBroadcaster _transactionBroadcaster;
private NavBarItemViewModel? _currentSelection;
[AutoNotify] private WalletViewModelBase? _selectedWallet;
[AutoNotify(SetterModifier = AccessModifier.Private)] private bool _isLoadingWallet;
@@ -37,7 +38,7 @@ namespace WalletWasabi.Fluent.ViewModels
[AutoNotify] private bool _anyWalletStarted;
public WalletManagerViewModel(WalletManager walletManager, UiConfig uiConfig, BitcoinStore bitcoinStore,
- LegalChecker legalChecker, TransactionBroadcaster transactionBroadcaster)
+ LegalChecker legalChecker, TransactionBroadcaster broadcaster)
{
WalletManager = walletManager;
BitcoinStore = bitcoinStore;
@@ -47,6 +48,7 @@ namespace WalletWasabi.Fluent.ViewModels
_actions = new ObservableCollection<NavBarItemViewModel>();
_wallets = new ObservableCollection<WalletViewModelBase>();
_loggedInAndSelectedAlwaysFirst = true;
+ _transactionBroadcaster = broadcaster;
static Func<WalletViewModelBase, bool> SelectedWalletFilter(WalletViewModelBase? selected)
{
@@ -80,7 +82,7 @@ namespace WalletWasabi.Fluent.ViewModels
}
else if (_walletDictionary[wallet] is ClosedWalletViewModel { IsLoggedIn: true } cwvm && wallet.State == WalletState.Started)
{
- OpenClosedWallet(walletManager, uiConfig, transactionBroadcaster, cwvm);
+ OpenClosedWallet(walletManager, uiConfig, cwvm);
}
}
@@ -96,7 +98,7 @@ namespace WalletWasabi.Fluent.ViewModels
{
WalletViewModelBase vm = (wallet.State <= WalletState.Starting)
? ClosedWalletViewModel.Create(this, wallet)
- : WalletViewModel.Create(uiConfig, transactionBroadcaster, wallet);
+ : WalletViewModel.Create(uiConfig, wallet);
InsertWallet(vm);
});
@@ -142,13 +144,13 @@ namespace WalletWasabi.Fluent.ViewModels
return null;
}
- private void OpenClosedWallet(WalletManager walletManager, UiConfig uiConfig, TransactionBroadcaster broadcaster, ClosedWalletViewModel closedWalletViewModel)
+ private void OpenClosedWallet(WalletManager walletManager, UiConfig uiConfig, ClosedWalletViewModel closedWalletViewModel)
{
IsLoadingWallet = true;
RemoveWallet(closedWalletViewModel);
- var walletViewModelItem = OpenWallet(walletManager, uiConfig, broadcaster, closedWalletViewModel.Wallet);
+ var walletViewModelItem = OpenWallet(walletManager, uiConfig, closedWalletViewModel.Wallet);
if (!_walletActionsDictionary.TryGetValue(walletViewModelItem, out var actions))
{
@@ -165,14 +167,14 @@ namespace WalletWasabi.Fluent.ViewModels
IsLoadingWallet = false;
}
- private WalletViewModel OpenWallet(WalletManager walletManager, UiConfig uiConfig, TransactionBroadcaster broadcaster, Wallet wallet)
+ private WalletViewModel OpenWallet(WalletManager walletManager, UiConfig uiConfig, Wallet wallet)
{
if (_wallets.Any(x => x.Title == wallet.WalletName))
{
throw new Exception("Wallet already opened.");
}
- var walletViewModel = WalletViewModel.Create(uiConfig, broadcaster, wallet);
+ var walletViewModel = WalletViewModel.Create(uiConfig, wallet);
InsertWallet(walletViewModel);
@@ -272,7 +274,7 @@ namespace WalletWasabi.Fluent.ViewModels
if (wallet.KeyManager.IsHardwareWallet || !wallet.KeyManager.IsWatchOnly)
{
- actions.Add(new SendViewModel(walletViewModel));
+ actions.Add(new SendViewModel(walletViewModel, _transactionBroadcaster));
}
actions.Add(new ReceiveViewModel(walletViewModel, WalletManager, BitcoinStore));

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

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
@@ -13,6 +13,7 @@ using NBitcoin;
using NBitcoin.Payment;
using ReactiveUI;
using WalletWasabi.Blockchain.Analysis.Clustering;
+using WalletWasabi.Blockchain.TransactionBroadcasting;
using WalletWasabi.Blockchain.TransactionBuilding;
using WalletWasabi.Fluent.MathNet;
using WalletWasabi.Fluent.Validation;
@@ -50,7 +51,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
private string? _payJoinEndPoint;
private bool _parsingUrl;
- public SendViewModel(WalletViewModel walletVm)
+ public SendViewModel(WalletViewModel walletVm, TransactionBroadcaster broadcaster)
{
_to = "";
_owner = walletVm;
@@ -123,7 +124,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
mixedCoins.Select(x => x.OutPoint));
// Private coins are enough.
- Navigate().To(new OptimisePrivacyViewModel(wallet, transactionInfo, walletVm.TransactionBroadcaster, txRes));
+ Navigate().To(new OptimisePrivacyViewModel(wallet, transactionInfo, broadcaster, txRes));
return;
}
catch (NotEnoughFundsException)

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
@@ -80,9 +80,19 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
// Dequeue any coin-joining coins.
await wallet.ChaumianClient.DequeueAllCoinsFromMixAsync(DequeueReason.TransactionBuilding);
- // Broadcast transaction.
+
+
var signedTransaction = transaction.Transaction;
+ if (_transaction.Signed)
+ {
+
+ }
+ else
+ {
+
+ }
+
// If it's a hardware wallet and still has a private key then it's password.
if (wallet.KeyManager.IsHardwareWallet && !transaction.Signed)
{

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModel.cs
@@ -16,12 +16,10 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
{
public partial class WalletViewModel : WalletViewModelBase
{
- protected WalletViewModel(UiConfig uiConfig, TransactionBroadcaster broadcaster, Wallet wallet) : base(wallet)
+ protected WalletViewModel(UiConfig uiConfig, Wallet wallet) : base(wallet)
{
Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");
- TransactionBroadcaster = broadcaster;
-
Observable.Merge(
Observable.FromEventPattern(Wallet.TransactionProcessor, nameof(Wallet.TransactionProcessor.WalletRelevantTransactionProcessed)).Select(_ => Unit.Default))
.Throttle(TimeSpan.FromSeconds(0.1))
@@ -50,15 +48,13 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
public override string IconName => "web_asset_regular";
- public TransactionBroadcaster TransactionBroadcaster { get; }
-
- public static WalletViewModel Create(UiConfig uiConfig, TransactionBroadcaster broadcaster, Wallet wallet)
+ public static WalletViewModel Create(UiConfig uiConfig, Wallet wallet)
{
return wallet.KeyManager.IsHardwareWallet
- ? new HardwareWalletViewModel(uiConfig, broadcaster, wallet)
+ ? new HardwareWalletViewModel(uiConfig, wallet)
: wallet.KeyManager.IsWatchOnly
- ? new WatchOnlyWalletViewModel(uiConfig, broadcaster, wallet)
- : new WalletViewModel(uiConfig, broadcaster, wallet);
+ ? new WatchOnlyWalletViewModel(uiConfig, wallet)
+ : new WalletViewModel(uiConfig, wallet);
}
}
}

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

Simplify passing of txnbroadcaster references