Rename Locked smartcoin property to CoinJoinInProcess and add AnonymitySet computed property.
MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -476,7 +476,7 @@ namespace WalletWasabi.Tests
Assert.Equal(Money.Coins(0.1m), firstCoin.Amount);
Assert.Equal(indexDownloader.GetBestFilter().BlockHeight, firstCoin.Height);
Assert.InRange(firstCoin.Index, 0U, 1U);
- Assert.False(firstCoin.SpentOrLocked);
+ Assert.False(firstCoin.SpentOrCoinJoinInProcess);
Assert.Equal("foo label", firstCoin.Label);
Assert.Equal(key.GetP2wpkhScript(), firstCoin.ScriptPubKey);
Assert.Null(firstCoin.SpenderTransactionId);
@@ -506,7 +506,7 @@ namespace WalletWasabi.Tests
Assert.Equal(indexDownloader.GetBestFilter().BlockHeight.Value - 2, firstCoin.Height.Value);
Assert.Equal(indexDownloader.GetBestFilter().BlockHeight.Value - 1, secondCoin.Height.Value);
Assert.Equal(indexDownloader.GetBestFilter().BlockHeight, thirdCoin.Height);
- Assert.False(thirdCoin.SpentOrLocked);
+ Assert.False(thirdCoin.SpentOrCoinJoinInProcess);
Assert.Equal("foo label", firstCoin.Label);
Assert.Equal("bar label", secondCoin.Label);
Assert.Equal("bar label", thirdCoin.Label);
@@ -562,7 +562,7 @@ namespace WalletWasabi.Tests
Assert.Equal(Money.Coins(0.03m), rbfCoin.Amount);
Assert.Equal(indexDownloader.GetBestFilter().BlockHeight.Value - 2, rbfCoin.Height.Value);
- Assert.False(rbfCoin.SpentOrLocked);
+ Assert.False(rbfCoin.SpentOrCoinJoinInProcess);
Assert.Equal("bar label", rbfCoin.Label);
Assert.Equal(key2.GetP2wpkhScript(), rbfCoin.ScriptPubKey);
Assert.Null(rbfCoin.SpenderTransactionId);
@@ -740,7 +740,7 @@ namespace WalletWasabi.Tests
#region Basic
Script receive = wallet.GetReceiveKey("Basic").GetP2wpkhScript();
- Money amountToSend = wallet.Coins.Where(x => !x.SpentOrLocked).Sum(x => x.Amount) / 2;
+ Money amountToSend = wallet.Coins.Where(x => !x.SpentOrCoinJoinInProcess).Sum(x => x.Amount) / 2;
var res = await wallet.BuildTransactionAsync(password, new[] { new WalletService.Operation(receive, amountToSend, "foo") }, 1008, allowUnconfirmed: true);
Assert.Equal(2, res.InnerWalletOutputs.Count());
@@ -780,7 +780,7 @@ namespace WalletWasabi.Tests
#region SubtractFeeFromAmount
receive = wallet.GetReceiveKey("SubtractFeeFromAmount").GetP2wpkhScript();
- amountToSend = wallet.Coins.Where(x => !x.SpentOrLocked).Sum(x => x.Amount) / 2;
+ amountToSend = wallet.Coins.Where(x => !x.SpentOrCoinJoinInProcess).Sum(x => x.Amount) / 2;
res = await wallet.BuildTransactionAsync(password, new[] { new WalletService.Operation(receive, amountToSend, "foo") }, 1008, allowUnconfirmed: true, subtractFeeFromAmountIndex: 0);
Assert.Equal(2, res.InnerWalletOutputs.Count());
@@ -936,7 +936,7 @@ namespace WalletWasabi.Tests
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.SpentOrLocked).Sum(x => x.Amount) - res.Fee, maxBuiltTxOutput.Value);
+ Assert.Equal(wallet.Coins.Where(x => !x.SpentOrCoinJoinInProcess).Sum(x => x.Amount) - res.Fee, maxBuiltTxOutput.Value);
await wallet.SendTransactionAsync(res.Transaction);
@@ -949,7 +949,7 @@ namespace WalletWasabi.Tests
var inputCountBefore = res.SpentCoins.Count();
res = await wallet.BuildTransactionAsync(password, new[] { new WalletService.Operation(receive, Money.Zero, "foo") }, 1008,
allowUnconfirmed: true,
- allowedInputs: wallet.Coins.Where(x => !x.SpentOrLocked).Select(x => new TxoRef(x.TransactionId, x.Index)).Take(1));
+ allowedInputs: wallet.Coins.Where(x => !x.SpentOrCoinJoinInProcess).Select(x => new TxoRef(x.TransactionId, x.Index)).Take(1));
Assert.Single(res.InnerWalletOutputs);
Assert.Empty(res.OuterWalletOutputs);
@@ -989,7 +989,7 @@ namespace WalletWasabi.Tests
Assert.Single(res.InnerWalletOutputs);
Assert.Equal("change of (my label)", res.InnerWalletOutputs.Single().Label);
- amountToSend = wallet.Coins.Where(x => !x.SpentOrLocked).Sum(x => x.Amount) / 3;
+ amountToSend = wallet.Coins.Where(x => !x.SpentOrCoinJoinInProcess).Sum(x => x.Amount) / 3;
res = await wallet.BuildTransactionAsync(password, new[] {
new WalletService.Operation(new Key().ScriptPubKey, amountToSend, "outgoing"),
new WalletService.Operation(new Key().ScriptPubKey, amountToSend, "outgoing2")
@@ -1021,7 +1021,7 @@ namespace WalletWasabi.Tests
receive = wallet.GetReceiveKey("AllowedInputsDisallowUnconfirmed").GetP2wpkhScript();
- var allowedInputs = wallet.Coins.Where(x => !x.SpentOrLocked).Select(x => new TxoRef(x.TransactionId, x.Index)).Take(1);
+ var allowedInputs = wallet.Coins.Where(x => !x.SpentOrCoinJoinInProcess).Select(x => new TxoRef(x.TransactionId, x.Index)).Take(1);
var toSend = new[] { new WalletService.Operation(receive, Money.Zero, "fizz") };
// covers:
@@ -1528,12 +1528,12 @@ namespace WalletWasabi.Tests
Assert.Contains(wallet.Coins, x => x.TransactionId == tx1Res.Transaction.GetHash());
// There is a coin destroyed
- Assert.Equal(1, wallet.Coins.Count(x => x.SpentOrLocked && x.SpenderTransactionId == tx1Res.Transaction.GetHash()));
+ Assert.Equal(1, wallet.Coins.Count(x => x.SpentOrCoinJoinInProcess && 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.TransactionId == tx0Id));
- var totalWallet = wallet.Coins.Where(c => !c.SpentOrLocked).Sum(c => c.Amount);
+ var totalWallet = wallet.Coins.Where(c => !c.SpentOrCoinJoinInProcess).Sum(c => c.Amount);
Assert.Equal((1 * Money.COIN) - tx1Res.Fee.Satoshi, totalWallet);
// Spend the unconfirmed and unspent coin (send it to ourself)
@@ -1548,12 +1548,12 @@ namespace WalletWasabi.Tests
Assert.Contains(wallet.Coins, x => x.TransactionId == tx2Res.Transaction.GetHash());
// There is a coin destroyed
- Assert.Equal(1, wallet.Coins.Count(x => x.SpentOrLocked && x.SpenderTransactionId == tx2Res.Transaction.GetHash()));
+ Assert.Equal(1, wallet.Coins.Count(x => x.SpentOrCoinJoinInProcess && x.SpenderTransactionId == tx2Res.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.TransactionId == tx1Res.Transaction.GetHash()));
- totalWallet = wallet.Coins.Where(c => !c.SpentOrLocked).Sum(c => c.Amount);
+ totalWallet = wallet.Coins.Where(c => !c.SpentOrCoinJoinInProcess).Sum(c => c.Amount);
Assert.Equal((1 * Money.COIN) - tx1Res.Fee.Satoshi - tx2Res.Fee.Satoshi, totalWallet);
Interlocked.Exchange(ref _filtersProcessedByWalletCount, 0);
@@ -2367,39 +2367,39 @@ namespace WalletWasabi.Tests
chaumianClient1.Start();
chaumianClient2.Start();
- smartCoin1.Locked = true;
+ smartCoin1.CoinJoinInProcess = true;
Assert.True(!(await chaumianClient1.QueueCoinsToMixAsync(password, smartCoin1)).Any());
- Assert.True(smartCoin1.Locked);
+ Assert.True(smartCoin1.CoinJoinInProcess);
await Assert.ThrowsAsync<SecurityException>(async () => await chaumianClient1.QueueCoinsToMixAsync("asdasdasd", smartCoin1, smartCoin2));
- Assert.True(smartCoin1.Locked);
- Assert.False(smartCoin2.Locked);
- smartCoin1.Locked = false;
+ Assert.True(smartCoin1.CoinJoinInProcess);
+ Assert.False(smartCoin2.CoinJoinInProcess);
+ smartCoin1.CoinJoinInProcess = false;
await chaumianClient1.QueueCoinsToMixAsync(password, smartCoin1, smartCoin2);
- Assert.True(smartCoin1.Locked);
- Assert.True(smartCoin2.Locked);
+ Assert.True(smartCoin1.CoinJoinInProcess);
+ Assert.True(smartCoin2.CoinJoinInProcess);
// Make sure it doesn't throw.
await chaumianClient1.DequeueCoinsFromMixAsync(new SmartCoin((new Transaction()).GetHash(), 1, new Script(), Money.Parse("3"), new TxoRef[] { new TxoRef((new Transaction()).GetHash(), 0) }, Height.MemPool, rbf: false, mixin: 0));
Assert.True(2 == (await chaumianClient1.QueueCoinsToMixAsync(password, smartCoin1, smartCoin2)).Count());
await chaumianClient1.DequeueCoinsFromMixAsync(smartCoin1);
- Assert.False(smartCoin1.Locked);
+ Assert.False(smartCoin1.CoinJoinInProcess);
await chaumianClient1.DequeueCoinsFromMixAsync(smartCoin1, smartCoin2);
- Assert.False(smartCoin1.Locked);
- Assert.False(smartCoin2.Locked);
+ Assert.False(smartCoin1.CoinJoinInProcess);
+ Assert.False(smartCoin2.CoinJoinInProcess);
Assert.True(2 == (await chaumianClient1.QueueCoinsToMixAsync(password, smartCoin1, smartCoin2)).Count());
- Assert.True(smartCoin1.Locked);
- Assert.True(smartCoin2.Locked);
+ Assert.True(smartCoin1.CoinJoinInProcess);
+ Assert.True(smartCoin2.CoinJoinInProcess);
await chaumianClient1.DequeueCoinsFromMixAsync(smartCoin1);
await chaumianClient1.DequeueCoinsFromMixAsync(smartCoin2);
- Assert.False(smartCoin1.Locked);
- Assert.False(smartCoin2.Locked);
+ Assert.False(smartCoin1.CoinJoinInProcess);
+ Assert.False(smartCoin2.CoinJoinInProcess);
Assert.True(2 == (await chaumianClient1.QueueCoinsToMixAsync(password, smartCoin1, smartCoin2)).Count());
- Assert.True(smartCoin1.Locked);
- Assert.True(smartCoin2.Locked);
+ Assert.True(smartCoin1.CoinJoinInProcess);
+ Assert.True(smartCoin2.CoinJoinInProcess);
Assert.True(1 == (await chaumianClient2.QueueCoinsToMixAsync(password, smartCoin3)).Count());
Task timeout = Task.Delay(TimeSpan.FromSeconds(connectionConfirmationTimeout * 2 + 7 * 2 + 7 * 2 + 7 * 2));
@@ -2673,15 +2673,15 @@ namespace WalletWasabi.Tests
SmartCoin[] unspentChanges = wallet.Coins.Where(x => x.Label == "ZeroLink Change" && x.Unspent).ToArray();
await wallet.ChaumianClient.DequeueCoinsFromMixAsync(unspentChanges);
- Assert.Equal(3, wallet.Coins.Count(x => x.Label == "ZeroLink Mixed Coin" && !x.SpentOrLocked));
- Assert.Equal(3, wallet2.Coins.Count(x => x.Label == "ZeroLink Mixed Coin" && !x.SpentOrLocked));
+ Assert.Equal(3, wallet.Coins.Count(x => x.Label == "ZeroLink Mixed Coin" && !x.SpentOrCoinJoinInProcess));
+ Assert.Equal(3, wallet2.Coins.Count(x => x.Label == "ZeroLink Mixed Coin" && !x.SpentOrCoinJoinInProcess));
Assert.Equal(0, wallet.Coins.Count(x => x.Label == "ZeroLink Mixed Coin" && !x.Unspent));
Assert.Equal(0, wallet2.Coins.Count(x => x.Label == "ZeroLink Mixed Coin" && !x.Unspent));
Assert.Equal(2, wallet.Coins.Count(x => x.Label == "ZeroLink Change" && !x.Unspent));
Assert.Equal(0, wallet2.Coins.Count(x => x.Label == "ZeroLink Change"));
Assert.Equal(0, wallet.Coins.Count(x => x.Label == "ZeroLink Change" && x.Unspent));
Assert.Equal(0, wallet.Coins.Count(x => x.Label == "ZeroLink Dequeued Change" && !x.Unspent));
- Assert.Equal(1, wallet.Coins.Count(x => x.Label == "ZeroLink Dequeued Change" && !x.SpentOrLocked));
+ Assert.Equal(1, wallet.Coins.Count(x => x.Label == "ZeroLink Dequeued Change" && !x.SpentOrCoinJoinInProcess));
}
finally
{

MODIFY
WalletWasabi.Tests/SmartModelTests.cs
WalletWasabi.Tests/SmartModelTests.cs
@@ -69,7 +69,7 @@ namespace WalletWasabi.Tests
Assert.Equal(coin.Height, deserialized.Height);
Assert.Equal(coin.Amount, deserialized.Amount);
Assert.Equal(coin.Index, deserialized.Index);
- Assert.Equal(coin.SpentOrLocked, deserialized.SpentOrLocked);
+ Assert.Equal(coin.SpentOrCoinJoinInProcess, deserialized.SpentOrCoinJoinInProcess);
Assert.Equal(coin.Label, deserialized.Label);
Assert.Equal(coin.ScriptPubKey, deserialized.ScriptPubKey);
Assert.Equal(coin.SpenderTransactionId, deserialized.SpenderTransactionId);

MODIFY
WalletWasabi/Models/SmartCoin.cs
WalletWasabi/Models/SmartCoin.cs
@@ -47,15 +47,23 @@ namespace WalletWasabi.Models
[JsonProperty(Order = 10)]
[JsonConverter(typeof(FunnyBoolJsonConverter))]
- public bool Locked { get; set; }
+ public bool CoinJoinInProcess { get; set; }
+ /// <summary>
+ /// AnonymitySet - 1
+ /// </summary>
[JsonProperty(Order = 11)]
public int Mixin { get; }
- public bool SpentOrLocked => SpenderTransactionId != null || Locked;
+ public bool SpentOrCoinJoinInProcess => SpenderTransactionId != null || CoinJoinInProcess;
public bool Unspent => SpenderTransactionId == null;
public bool Confirmed => Height != Height.MemPool && Height != Height.Unknown;
+ /// <summary>
+ /// Mixin + 1
+ /// </summary>
+ public int AnonymitySet => Mixin + 1;
+
/// <summary>
/// It's a secret, so it's usually going to be null. Don't use it.
/// </summary>
@@ -74,7 +82,7 @@ namespace WalletWasabi.Models
Label = Guard.Correct(label);
SpenderTransactionId = spenderTransactionId;
RBF = rbf;
- Locked = locked;
+ CoinJoinInProcess = locked;
Secret = null;
}
@@ -91,7 +99,7 @@ namespace WalletWasabi.Models
Label = Guard.Correct(label);
SpenderTransactionId = spenderTransactionId;
RBF = rbf;
- Locked = locked;
+ CoinJoinInProcess = locked;
Secret = null;
}

MODIFY
WalletWasabi/Services/CcjClient.cs
WalletWasabi/Services/CcjClient.cs
@@ -531,7 +531,7 @@ namespace WalletWasabi.Services
continue;
}
- if (coin.SpentOrLocked)
+ if (coin.SpentOrCoinJoinInProcess)
{
continue;
}
@@ -539,7 +539,7 @@ namespace WalletWasabi.Services
coin.Secret = KeyManager.GetSecrets(password, coin.ScriptPubKey).Single();
OnePiece = OnePiece ?? password;
- coin.Locked = true;
+ coin.CoinJoinInProcess = true;
State.AddCoinToWaitingList(coin);
successful.Add(coin);
@@ -628,7 +628,7 @@ namespace WalletWasabi.Services
private void RemoveCoin(SmartCoin coinWaitingForMix)
{
State.RemoveCoinFromWaitingList(coinWaitingForMix);
- coinWaitingForMix.Locked = false;
+ coinWaitingForMix.CoinJoinInProcess = false;
coinWaitingForMix.Secret = null;
if (coinWaitingForMix.Label == "ZeroLink Change" && coinWaitingForMix.Unspent)
{

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -596,22 +596,22 @@ namespace WalletWasabi.Services
if (allowUnconfirmed)
{
- allowedSmartCoinInputs = Coins.Where(x => !x.SpentOrLocked && allowedInputs.Any(y => y.TransactionId == x.TransactionId && y.Index == x.Index)).ToList();
+ allowedSmartCoinInputs = Coins.Where(x => !x.SpentOrCoinJoinInProcess && allowedInputs.Any(y => y.TransactionId == x.TransactionId && y.Index == x.Index)).ToList();
}
else
{
- allowedSmartCoinInputs = Coins.Where(x => !x.SpentOrLocked && x.Confirmed && allowedInputs.Any(y => y.TransactionId == x.TransactionId && y.Index == x.Index)).ToList();
+ allowedSmartCoinInputs = Coins.Where(x => !x.SpentOrCoinJoinInProcess && x.Confirmed && allowedInputs.Any(y => y.TransactionId == x.TransactionId && y.Index == x.Index)).ToList();
}
}
else
{
if (allowUnconfirmed)
{
- allowedSmartCoinInputs = Coins.Where(x => !x.SpentOrLocked).ToList();
+ allowedSmartCoinInputs = Coins.Where(x => !x.SpentOrCoinJoinInProcess).ToList();
}
else
{
- allowedSmartCoinInputs = Coins.Where(x => !x.SpentOrLocked && x.Confirmed).ToList();
+ allowedSmartCoinInputs = Coins.Where(x => !x.SpentOrCoinJoinInProcess && x.Confirmed).ToList();
}
}

Rename Locked smartcoin property to CoinJoinInProcess and add AnonymitySet computed property.