Skip to content

Commit

Permalink
[skip ci] Add SmartCoinStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
nopara73 committed Nov 16, 2018
1 parent 88483f0 commit c3b9083
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 16 deletions.
17 changes: 6 additions & 11 deletions WalletWasabi.Gui/Controls/WalletExplorer/CoinViewModel.cs
Expand Up @@ -7,17 +7,14 @@
using NBitcoin; using NBitcoin;
using System.Reactive.Linq; using System.Reactive.Linq;
using System.Linq; using System.Linq;
using WalletWasabi.Gui.Models;


namespace WalletWasabi.Gui.Controls.WalletExplorer namespace WalletWasabi.Gui.Controls.WalletExplorer
{ {
public enum CoinStatusEnum
{
None,
}
public class CoinViewModel : ViewModelBase public class CoinViewModel : ViewModelBase
{ {
private bool _isSelected; private bool _isSelected;
private CoinStatusEnum _status; private SmartCoinStatus _status;


public CoinViewModel(SmartCoin model) public CoinViewModel(SmartCoin model)
{ {
Expand Down Expand Up @@ -82,12 +79,10 @@ public bool IsSelected


public string History => string.Join(", ", Global.WalletService.GetHistory(Model, Enumerable.Empty<SmartCoin>()).Select(x => x.Label).Distinct()); public string History => string.Join(", ", Global.WalletService.GetHistory(Model, Enumerable.Empty<SmartCoin>()).Select(x => x.Label).Distinct());


public CoinStatusEnum Status public SmartCoinStatus Status
{ {
get => _status; get => _status;
set { this.RaiseAndSetIfChanged(ref _status, value); } set { this.RaiseAndSetIfChanged(ref _status, value); }
} }


} }
} }
Expand Up @@ -147,7 +147,7 @@ private void RewriteTable()
var txinfo = new TransactionInfo var txinfo = new TransactionInfo
{ {
DateTime = txr.dateTime.ToLocalTime(), DateTime = txr.dateTime.ToLocalTime(),
Confirmed = txr.height != Models.Height.MemPool && txr.height != Models.Height.Unknown, Confirmed = txr.height != WalletWasabi.Models.Height.MemPool && txr.height != WalletWasabi.Models.Height.Unknown,
AmountBtc = $"{txr.amount.ToString(fplus: true, trimExcessZero: true)}", AmountBtc = $"{txr.amount.ToString(fplus: true, trimExcessZero: true)}",
Label = txr.label, Label = txr.label,
TransactionId = txr.transactionId.ToString() TransactionId = txr.transactionId.ToString()
Expand Down
6 changes: 4 additions & 2 deletions WalletWasabi.Gui/Converters/CoinStatusColorConverter.cs
Expand Up @@ -5,6 +5,7 @@
using System.Globalization; using System.Globalization;
using System.Text; using System.Text;
using WalletWasabi.Gui.Controls.WalletExplorer; using WalletWasabi.Gui.Controls.WalletExplorer;
using WalletWasabi.Gui.Models;
using WalletWasabi.Models.ChaumianCoinJoin; using WalletWasabi.Models.ChaumianCoinJoin;


namespace WalletWasabi.Gui.Converters namespace WalletWasabi.Gui.Converters
Expand All @@ -13,12 +14,13 @@ public class CoinStatusColorConverter : IValueConverter
{ {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{ {
if (value is CoinStatusEnum status) if (value is SmartCoinStatus status)
{ {
switch (status) switch (status)
{ {
case CoinStatusEnum.None: case SmartCoinStatus.Confirmed:
return Brushes.Black; return Brushes.Black;

default: default:
return Brushes.Transparent; return Brushes.Transparent;
} }
Expand Down
5 changes: 3 additions & 2 deletions WalletWasabi.Gui/Converters/CoinStatusStringConverter.cs
Expand Up @@ -4,6 +4,7 @@
using System.Globalization; using System.Globalization;
using System.Text; using System.Text;
using WalletWasabi.Gui.Controls.WalletExplorer; using WalletWasabi.Gui.Controls.WalletExplorer;
using WalletWasabi.Gui.Models;
using WalletWasabi.Models.ChaumianCoinJoin; using WalletWasabi.Models.ChaumianCoinJoin;


namespace WalletWasabi.Gui.Converters namespace WalletWasabi.Gui.Converters
Expand All @@ -12,7 +13,7 @@ public class CoinStatusStringConverter : IValueConverter
{ {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{ {
if (value is CoinStatusEnum status) if (value is SmartCoinStatus status)
{ {
return status.ToString(); return status.ToString();
} }
Expand All @@ -23,7 +24,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{ {
var s = value.ToString(); var s = value.ToString();
return Enum.Parse<CoinStatusEnum>(s); return Enum.Parse<SmartCoinStatus>(s);
} }
} }
} }
20 changes: 20 additions & 0 deletions WalletWasabi.Gui/Models/SmartCoinStatus.cs
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace WalletWasabi.Gui.Models
{
public enum SmartCoinStatus
{
Unconfirmed, // The coin is unconfirmed.
Confirmed, // The coin is confirmed.
SpentAccordingToBackend, // The coin is spent according to the backend, but the wallet does not know about it yet. Probably a lost mempool transaction.
MixingBanned, // The coin is banned from mixing.
MixingWaitingForConfirmation, // The coin is on the mixing waiting list, but it is unconfirmed, so it cannot be registered yet.
MixingOnWaitingList, // The coin is on the mixing waiting list.
MixingInputRegistration, // The coin is registered for mixing.
MixingConnectionConfirmation, // The coin being mixed and in ConnectionConfirmation phase already.
MixingOutputRegistration, // The coin being mixed and in OutputRegistration phase already.
MixingSigning // The coin being mixed and in Signing phase already.
}
}

0 comments on commit c3b9083

Please sign in to comment.