Unavailable -> IsAvailable()
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinViewModel.cs
@@ -28,7 +28,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private ObservableAsPropertyHelper<bool> _coinJoinInProgress;
private ObservableAsPropertyHelper<bool> _unspent;
private ObservableAsPropertyHelper<bool> _confirmed;
- private ObservableAsPropertyHelper<bool> _unavailable;
private ObservableAsPropertyHelper<string> _cluster;
private volatile bool _disposedValue = false;
@@ -66,11 +65,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
.ToProperty(this, x => x.Cluster, scheduler: RxApp.MainThreadScheduler)
.DisposeWith(Disposables);
- _unavailable = Model
- .WhenAnyValue(x => x.Unavailable)
- .ToProperty(this, x => x.Unavailable, scheduler: RxApp.MainThreadScheduler)
- .DisposeWith(Disposables);
-
this.WhenAnyValue(x => x.Status)
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(_ => this.RaisePropertyChanged(nameof(ToolTip)));
@@ -142,8 +136,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public bool CoinJoinInProgress => _coinJoinInProgress?.Value ?? false;
- public bool Unavailable => _unavailable?.Value ?? false;
-
public bool Unspent => _unspent?.Value ?? false;
public string Address => Model.ScriptPubKey.GetDestinationAddress(Global.Network).ToString();

MODIFY
WalletWasabi.Tests/RegressionTests/CoinJoinTests.cs
WalletWasabi.Tests/RegressionTests/CoinJoinTests.cs
@@ -1489,8 +1489,8 @@ namespace WalletWasabi.Tests.RegressionTests
var allCoins = wallet.TransactionProcessor.Coins.AsAllCoinsView().ToArray();
var allCoins2 = wallet2.TransactionProcessor.Coins.AsAllCoinsView().ToArray();
- Assert.Equal(4, allCoins.Count(x => x.Label.IsEmpty && !x.Unavailable));
- Assert.Equal(3, allCoins2.Count(x => x.Label.IsEmpty && !x.Unavailable));
+ Assert.Equal(4, allCoins.Count(x => x.Label.IsEmpty && x.IsAvailable()));
+ Assert.Equal(3, allCoins2.Count(x => x.Label.IsEmpty && x.IsAvailable()));
Assert.Equal(2, allCoins.Count(x => x.Label.IsEmpty && !x.Unspent));
Assert.Equal(0, allCoins2.Count(x => x.Label.IsEmpty && !x.Unspent));
Assert.Equal(3, allCoins2.Count(x => x.Label.IsEmpty));

MODIFY
WalletWasabi.Tests/RegressionTests/SendTests.cs
WalletWasabi.Tests/RegressionTests/SendTests.cs
@@ -123,7 +123,7 @@ namespace WalletWasabi.Tests.RegressionTests
#region Basic
Script receive = keyManager.GetNextReceiveKey("Basic", out _).P2wpkhScript;
- Money amountToSend = wallet.Coins.Where(x => !x.Unavailable).Sum(x => x.Amount) / 2;
+ Money amountToSend = wallet.Coins.Where(x => x.IsAvailable()).Sum(x => x.Amount) / 2;
var res = wallet.BuildTransaction(password, new PaymentIntent(receive, amountToSend, label: "foo"), FeeStrategy.SevenDaysConfirmationTargetStrategy, allowUnconfirmed: true);
foreach (SmartCoin coin in res.SpentCoins)
@@ -171,7 +171,7 @@ namespace WalletWasabi.Tests.RegressionTests
#region SubtractFeeFromAmount
receive = keyManager.GetNextReceiveKey("SubtractFeeFromAmount", out _).P2wpkhScript;
- amountToSend = wallet.Coins.Where(x => !x.Unavailable).Sum(x => x.Amount) / 3;
+ amountToSend = wallet.Coins.Where(x => x.IsAvailable()).Sum(x => x.Amount) / 3;
res = wallet.BuildTransaction(password, new PaymentIntent(receive, amountToSend, subtractFee: true, label: "foo"), FeeStrategy.SevenDaysConfirmationTargetStrategy, allowUnconfirmed: true);
Assert.Equal(2, res.InnerWalletOutputs.Count());
@@ -322,7 +322,7 @@ namespace WalletWasabi.Tests.RegressionTests
Assert.Single(res.Transaction.Transaction.Outputs);
var maxBuiltTxOutput = res.Transaction.Transaction.Outputs.Single();
Assert.Equal(receive, maxBuiltTxOutput.ScriptPubKey);
- Assert.Equal(wallet.Coins.Where(x => !x.Unavailable).Sum(x => x.Amount) - res.Fee, maxBuiltTxOutput.Value);
+ Assert.Equal(wallet.Coins.Where(x => x.IsAvailable()).Sum(x => x.Amount) - res.Fee, maxBuiltTxOutput.Value);
await broadcaster.SendTransactionAsync(res.Transaction);
@@ -336,7 +336,7 @@ namespace WalletWasabi.Tests.RegressionTests
res = wallet.BuildTransaction(password, new PaymentIntent(receive, MoneyRequest.CreateAllRemaining(), "foo"), FeeStrategy.SevenDaysConfirmationTargetStrategy,
allowUnconfirmed: true,
- allowedInputs: wallet.Coins.Where(x => !x.Unavailable).Select(x => x.OutPoint).Take(1));
+ allowedInputs: wallet.Coins.Where(x => x.IsAvailable()).Select(x => x.OutPoint).Take(1));
Assert.Single(res.InnerWalletOutputs);
Assert.Empty(res.OuterWalletOutputs);
@@ -376,7 +376,7 @@ namespace WalletWasabi.Tests.RegressionTests
Assert.Single(res.InnerWalletOutputs);
Assert.Equal("foo, my label", res.InnerWalletOutputs.Single().Label);
- amountToSend = wallet.Coins.Where(x => !x.Unavailable).Sum(x => x.Amount) / 3;
+ amountToSend = wallet.Coins.Where(x => x.IsAvailable()).Sum(x => x.Amount) / 3;
res = wallet.BuildTransaction(
password,
new PaymentIntent(
@@ -421,7 +421,7 @@ namespace WalletWasabi.Tests.RegressionTests
receive = keyManager.GetNextReceiveKey("AllowedInputsDisallowUnconfirmed", out _).P2wpkhScript;
- var allowedInputs = wallet.Coins.Where(x => !x.Unavailable).Select(x => x.OutPoint).Take(1);
+ var allowedInputs = wallet.Coins.Where(x => x.IsAvailable()).Select(x => x.OutPoint).Take(1);
var toSend = new PaymentIntent(receive, MoneyRequest.CreateAllRemaining(), "fizz");
// covers:
@@ -600,12 +600,12 @@ namespace WalletWasabi.Tests.RegressionTests
// There is a coin destroyed
var allCoins = wallet.TransactionProcessor.Coins.AsAllCoinsView();
- Assert.Equal(1, allCoins.Count(x => x.Unavailable && x.SpenderTransactionId == tx1Res.Transaction.GetHash()));
+ Assert.Equal(1, allCoins.Count(x => !x.IsAvailable() && x.SpenderTransactionId == tx1Res.Transaction.GetHash()));
// There is at least one coin created from the destruction of the first coin
Assert.Contains(wallet.Coins, x => x.SpentOutputs.Any(o => o.Hash == tx0Id));
- var totalWallet = wallet.Coins.Where(c => !c.Unavailable).Sum(c => c.Amount);
+ var totalWallet = wallet.Coins.Where(c => c.IsAvailable()).Sum(c => c.Amount);
Assert.Equal((1 * Money.COIN) - tx1Res.Fee.Satoshi, totalWallet);
// Spend the unconfirmed and unspent coin (send it to ourself)
@@ -629,12 +629,12 @@ namespace WalletWasabi.Tests.RegressionTests
// There is a coin destroyed
allCoins = wallet.TransactionProcessor.Coins.AsAllCoinsView();
- Assert.Equal(2, allCoins.Count(x => x.Unavailable && x.SpenderTransactionId == tx2Hash));
+ Assert.Equal(2, allCoins.Count(x => !x.IsAvailable() && x.SpenderTransactionId == tx2Hash));
// There is at least one coin created from the destruction of the first coin
Assert.Contains(wallet.Coins, x => x.SpentOutputs.Any(o => o.Hash == tx1Res.Transaction.GetHash()));
- totalWallet = wallet.Coins.Where(c => !c.Unavailable).Sum(c => c.Amount);
+ totalWallet = wallet.Coins.Where(c => c.IsAvailable()).Sum(c => c.Amount);
Assert.Equal((1 * Money.COIN) - tx1Res.Fee.Satoshi - tx2Res.Fee.Satoshi, totalWallet);
Interlocked.Exchange(ref Common.FiltersProcessedByWalletCount, 0);

MODIFY
WalletWasabi.Tests/RegressionTests/WalletTests.cs
WalletWasabi.Tests/RegressionTests/WalletTests.cs
@@ -286,7 +286,7 @@ namespace WalletWasabi.Tests.RegressionTests
Assert.Equal(Money.Coins(0.1m), firstCoin.Amount);
Assert.Equal(new Height((int)bitcoinStore.SmartHeaderChain.TipHeight), firstCoin.Height);
Assert.InRange(firstCoin.Index, 0U, 1U);
- Assert.False(firstCoin.Unavailable);
+ Assert.True(firstCoin.IsAvailable());
Assert.Equal("foo label", firstCoin.Label);
Assert.Equal(key.P2wpkhScript, firstCoin.ScriptPubKey);
Assert.Null(firstCoin.SpenderTransactionId);
@@ -316,7 +316,7 @@ namespace WalletWasabi.Tests.RegressionTests
Assert.Equal(new Height(bitcoinStore.SmartHeaderChain.TipHeight).Value - 2, firstCoin.Height.Value);
Assert.Equal(new Height(bitcoinStore.SmartHeaderChain.TipHeight).Value - 1, secondCoin.Height.Value);
Assert.Equal(new Height(bitcoinStore.SmartHeaderChain.TipHeight), thirdCoin.Height);
- Assert.False(thirdCoin.Unavailable);
+ Assert.True(thirdCoin.IsAvailable());
Assert.Equal("foo label", firstCoin.Label);
Assert.Equal("bar label", secondCoin.Label);
Assert.Equal("bar label", thirdCoin.Label);
@@ -372,7 +372,7 @@ namespace WalletWasabi.Tests.RegressionTests
Assert.Equal(Money.Coins(0.03m), rbfCoin.Amount);
Assert.Equal(new Height(bitcoinStore.SmartHeaderChain.TipHeight).Value - 2, rbfCoin.Height.Value);
- Assert.False(rbfCoin.Unavailable);
+ Assert.True(rbfCoin.IsAvailable());
Assert.Equal("bar label", rbfCoin.Label);
Assert.Equal(key2.P2wpkhScript, rbfCoin.ScriptPubKey);
Assert.Null(rbfCoin.SpenderTransactionId);

MODIFY
WalletWasabi/Blockchain/TransactionOutputs/CoinsView.cs
WalletWasabi/Blockchain/TransactionOutputs/CoinsView.cs
@@ -19,7 +19,7 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
public ICoinsView Unspent() => new CoinsView(Coins.Where(x => x.Unspent && !x.SpentAccordingToBackend));
- public ICoinsView Available() => new CoinsView(Coins.Where(x => !x.Unavailable));
+ public ICoinsView Available() => new CoinsView(Coins.Where(x => x.IsAvailable()));
public ICoinsView CoinJoinInProcess() => new CoinsView(Coins.Where(x => x.CoinJoinInProgress));

MODIFY
WalletWasabi/Blockchain/TransactionOutputs/SmartCoin.cs
WalletWasabi/Blockchain/TransactionOutputs/SmartCoin.cs
@@ -69,7 +69,6 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
SetUnspent();
SetIsBanned();
- SetUnavailable();
}
#endregion Constructors
@@ -133,13 +132,7 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
public bool CoinJoinInProgress
{
get => _coinJoinInProgress;
- set
- {
- if (RaiseAndSetIfChanged(ref _coinJoinInProgress, value))
- {
- SetUnavailable();
- }
- }
+ set => RaiseAndSetIfChanged(ref _coinJoinInProgress, value);
}
public DateTimeOffset? BannedUntilUtc
@@ -161,13 +154,7 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
public bool SpentAccordingToBackend
{
get => _spentAccordingToBackend;
- set
- {
- if (RaiseAndSetIfChanged(ref _spentAccordingToBackend, value))
- {
- SetUnavailable();
- }
- }
+ set => RaiseAndSetIfChanged(ref _spentAccordingToBackend, value);
}
public HdPubKey HdPubKey { get; }
@@ -199,24 +186,14 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
}
/// <summary>
- /// Spent || SpentAccordingToBackend || CoinJoinInProgress || IsDust;
+ /// Unspent AND !SpentAccordingToBackend AND !CoinJoinInProgress
/// </summary>
- public bool Unavailable
- {
- get => _unavailable;
- private set => RaiseAndSetIfChanged(ref _unavailable, value);
- }
+ public bool IsAvailable() => Unspent && !SpentAccordingToBackend && !CoinJoinInProgress;
public bool Unspent
{
get => _unspent;
- private set
- {
- if (RaiseAndSetIfChanged(ref _unspent, value))
- {
- SetUnavailable();
- }
- }
+ private set => RaiseAndSetIfChanged(ref _unspent, value);
}
public bool IsBanned
@@ -239,11 +216,6 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
IsBanned = BannedUntilUtc is { } && BannedUntilUtc > DateTimeOffset.UtcNow;
}
- private void SetUnavailable()
- {
- Unavailable = !Unspent || SpentAccordingToBackend || CoinJoinInProgress;
- }
-
#endregion PropertySetters
#endregion Properties

MODIFY
WalletWasabi/CoinJoin/Client/Clients/CoinJoinClient.cs
WalletWasabi/CoinJoin/Client/Clients/CoinJoinClient.cs
@@ -763,7 +763,7 @@ namespace WalletWasabi.CoinJoin.Client.Clients
continue;
}
- if (coin.Unavailable)
+ if (!coin.IsAvailable())
{
except.Add(coin);
continue;

Unavailable -> IsAvailable()