Skip to content

Commit

Permalink
Merge pull request #13013 from Whem/fix-coin-real-start
Browse files Browse the repository at this point in the history
fix coin join real start
  • Loading branch information
molnard committed May 9, 2024
2 parents 82eb88d + fece097 commit d6b113b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
16 changes: 13 additions & 3 deletions WalletWasabi.Fluent/Models/Wallets/WalletCoinjoinModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public WalletCoinjoinModel(Wallet wallet, IWalletSettingsModel settings)
Observable.FromEventPattern<StatusChangedEventArgs>(_coinJoinManager, nameof(CoinJoinManager.StatusChanged))
.Where(x => x.EventArgs.Wallet == wallet)
.Select(x => x.EventArgs)
.Where(x => x is WalletStartedCoinJoinEventArgs or WalletStoppedCoinJoinEventArgs or StartErrorEventArgs or CoinJoinStatusEventArgs or CompletedEventArgs)
.Where(x => x is WalletStartedCoinJoinEventArgs or WalletStoppedCoinJoinEventArgs or StartErrorEventArgs or CoinJoinStatusEventArgs or CompletedEventArgs or StartedEventArgs)
.ObserveOn(RxApp.MainThreadScheduler);

settings.WhenAnyValue(x => x.AutoCoinjoin)
Expand All @@ -48,11 +48,15 @@ public WalletCoinjoinModel(Wallet wallet, IWalletSettingsModel settings)
})
.Subscribe();

var coinjoinStarted =
var coinjoinInputStarted =
StatusUpdated.OfType<CoinJoinStatusEventArgs>()
.Where(e => e.CoinJoinProgressEventArgs is EnteringInputRegistrationPhase)
.Select(_ => true);

var coinjoinStarted =
StatusUpdated.OfType<StartedEventArgs>()
.Select(_ => true);

var coinjoinStopped =
StatusUpdated.OfType<WalletStoppedCoinJoinEventArgs>()
.Select(_ => false);
Expand All @@ -62,17 +66,23 @@ public WalletCoinjoinModel(Wallet wallet, IWalletSettingsModel settings)
.Select(_ => false);

IsRunning =
coinjoinStarted.Merge(coinjoinStopped)
coinjoinInputStarted.Merge(coinjoinStopped)
.Merge(coinjoinCompleted)
.ObserveOn(RxApp.MainThreadScheduler);

IsRunning.BindTo(this, x => x.IsCoinjoining);

IsStarted =
coinjoinStarted.Merge(coinjoinStopped)
.ObserveOn(RxApp.MainThreadScheduler);
}

public IObservable<StatusChangedEventArgs> StatusUpdated { get; }

public IObservable<bool> IsRunning { get; }

public IObservable<bool> IsStarted { get; }

public async Task StartAsync(bool stopWhenAllMixed, bool overridePlebStop)
{
Wallet outputWallet = Services.WalletManager.GetWallets().First(x => x.WalletId == _settings.OutputWalletId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public WalletCoinJoinSettingsViewModel(UiContext uiContext, IWalletModel walletM
.ObserveOn(RxApp.TaskpoolScheduler)
.Subscribe(x => _wallet.Settings.OutputWalletId = x.Id);

walletModel.Coinjoin.IsRunning
walletModel.Coinjoin.IsStarted
.Select(isRunning => !isRunning)
.BindTo(this, x => x.IsOutputWalletSelectionEnabled);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,15 @@

<DockPanel>
<TextBlock Text="Output Wallet" />
<PathIcon Data="{StaticResource warning_regular}" Foreground="{DynamicResource WarningMessageForeground}" DockPanel.Dock="Right" Margin="10,0,0,0" Height="20">
<PathIcon Data="{StaticResource warning_regular}" Foreground="{DynamicResource WarningMessageForeground}" Margin="-10,0,10,0" Height="20">
<ToolTip.Tip>
<TextBlock>
- Only loaded wallets can be selected.<LineBreak /><LineBreak />
- Coins from the CoinJoin transaction will be received by the output wallet. However, this setting resets after Wallet Wasabi restart.<LineBreak /><LineBreak />
- Until coinjoin is running you can't set the output wallet.
- Only loaded wallets can be selected.<LineBreak />
- Coins from the coinjoin transaction will be received by the output wallet. However, this setting resets after Wallet Wasabi restarts.<LineBreak />
- Output wallet cannot be changed when a coinjoin is in progress.
</TextBlock>
</ToolTip.Tip>
</PathIcon>

<ComboBox ItemsSource="{Binding Wallets}" IsEnabled="{Binding IsOutputWalletSelectionEnabled}" SelectedItem="{Binding SelectedOutputWallet}" HorizontalAlignment="Stretch">
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="wallets:IWalletModel">
Expand Down

0 comments on commit d6b113b

Please sign in to comment.