Implement coin history
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinListView.xaml
WalletWasabi.Gui/Controls/WalletExplorer/CoinListView.xaml
<TextBlock Text="Transaction ID Copied to Clipboard!" Foreground="#22B14C" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Grid>
</Grid>
- <Grid ColumnDefinitions="30,30,100,600,100,Auto" Margin="35 0" DockPanel.Dock="Top">
+ <Grid ColumnDefinitions="30,30,100,100,Auto" Margin="35 0" DockPanel.Dock="Top">
<TextBlock Text="" />
<TextBlock Text="" Grid.Column="1" />
<TextBlock Text="Amount" Grid.Column="2" />
- <TextBlock Text="Label" Grid.Column="3" />
- <TextBlock Text="Privacy Level" Grid.Column="4" Margin="20 0 0 0" />
+ <TextBlock Text="Privacy" Grid.Column="3" Margin="20 0 0 0" />
+ <TextBlock Text="History" Grid.Column="4" />
</Grid>
<ListBox Items="{Binding Coins}" SelectedItem="{Binding SelectedCoin}">
<ListBox.ItemTemplate>
</Grid>
</StackPanel>
</Expander>
- <Grid ColumnDefinitions="30,30,100,600,100,Auto" Margin="30 0 0 0" VerticalAlignment="Top">
+ <Grid ColumnDefinitions="30,30,100,100,Auto" Margin="30 0 0 0" VerticalAlignment="Top">
<CheckBox HorizontalContentAlignment="Left" IsChecked="{Binding IsSelected}" />
<Path HorizontalAlignment="Left" Grid.Column="1" Data="F1 M 23.7501,33.25L 34.8334,44.3333L 52.2499,22.1668L 56.9999,26.9168L 34.8334,53.8333L 19.0001,38L 23.7501,33.25 Z" Fill="#22B14C" Height="16" Width="16" IsVisible="{Binding Confirmed}" Stretch="Fill">
<ToolTip.Tip>
</ToolTip.Tip>
</Path>
<TextBlock Grid.Column="2" Text="{Binding AmountBtc}" />
- <TextBlock Grid.Column="3" Text="{Binding Label}" />
- <TextBlock Grid.Column="4" Text="{Binding PrivacyLevel, Converter={StaticResource PrivacyLevelValueConverter}}" Margin="20 0 0 0" />
+ <TextBlock Grid.Column="3" Text="{Binding PrivacyLevel, Converter={StaticResource PrivacyLevelValueConverter}}" Margin="20 0 0 0" />
+ <TextBlock Grid.Column="4" Text="{Binding History}" />
<TextBlock Text="" Grid.Column="5" />
</Grid>
</Grid>

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinViewModel.cs
@@ -14,7 +14,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
private bool _isSelected;
private int _privacyLevel;
- private string _history;
public CoinViewModel(SmartCoin model)
{
@@ -76,10 +75,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public string InCoinJoin => Model.CoinJoinInProcess ? "Yes" : "No";
- public string History
- {
- get { return _history; }
- set { this.RaiseAndSetIfChanged(ref _history, value); }
- }
+ public string History => string.Join(", ", Global.WalletService.GetHistory(Model, Enumerable.Empty<SmartCoin>()).Select(x => x.Label));
}
}

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -259,6 +259,77 @@ namespace WalletWasabi.Services
return ret;
}
+ public List<SmartCoin> GetHistory(SmartCoin coin, IEnumerable<SmartCoin> current)
+ {
+ Guard.NotNull(nameof(coin), coin);
+ if (current.Contains(coin))
+ {
+ return current.ToList();
+ }
+ var history = current.Concat(new List<SmartCoin> { coin }).ToList(); // the coin is the firs elem in its history
+
+ // If the script is the same then we have a match, no matter of the anonimity set.
+ foreach (var c in Coins)
+ {
+ if (c.ScriptPubKey == coin.ScriptPubKey)
+ {
+ if (!history.Contains(c))
+ {
+ var h = GetHistory(c, history);
+ foreach (var hr in h)
+ {
+ if (!history.Contains(hr))
+ {
+ history.Add(hr);
+ }
+ }
+ }
+ }
+ }
+
+ // If it spends someone and haven't been sufficiently anonimized.
+ if (coin.AnonymitySet < 50)
+ {
+ var c = Coins.FirstOrDefault(x => x.SpenderTransactionId == coin.TransactionId && !history.Contains(x));
+ if (c != default)
+ {
+ var h = GetHistory(c, history);
+ foreach (var hr in h)
+ {
+ if (!history.Contains(hr))
+ {
+ history.Add(hr);
+ }
+ }
+ }
+ }
+
+ // If it's being spent by someone and that someone haven't been sufficiently anonimized.
+ if (!coin.Unspent)
+ {
+ var c = Coins.FirstOrDefault(x => x.TransactionId == coin.SpenderTransactionId && !history.Contains(x));
+ if (c != default)
+ {
+ if (c.AnonymitySet < 50)
+ {
+ if (c != default)
+ {
+ var h = GetHistory(c, history);
+ foreach (var hr in h)
+ {
+ if (!history.Contains(hr))
+ {
+ history.Add(hr);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return history;
+ }
+
/// <summary>
/// Make sure there's always clean keys generated and indexed.
/// </summary>

Implement coin history