Remove some setters
MODIFY
WalletWasabi.Tests/RegressionTests/SendTests.cs
WalletWasabi.Tests/RegressionTests/SendTests.cs
@@ -748,20 +748,20 @@ namespace WalletWasabi.Tests.RegressionTests
}
Assert.Single(wallet.Coins);
- Assert.True(wallet.Coins.First().IsReplaceable);
+ Assert.True(wallet.Coins.First().IsReplaceable());
var bfr = await rpc.BumpFeeAsync(tx0Id);
var tx1Id = bfr.TransactionId;
await Task.Delay(2000); // Waits for the replacement transaction get to the mempool.
Assert.Single(wallet.Coins);
- Assert.True(wallet.Coins.First().IsReplaceable);
+ Assert.True(wallet.Coins.First().IsReplaceable());
Assert.Equal(tx1Id, wallet.Coins.First().TransactionId);
bfr = await rpc.BumpFeeAsync(tx1Id);
var tx2Id = bfr.TransactionId;
await Task.Delay(2000); // Waits for the replacement transaction get to the mempool.
Assert.Single(wallet.Coins);
- Assert.True(wallet.Coins.First().IsReplaceable);
+ Assert.True(wallet.Coins.First().IsReplaceable());
Assert.Equal(tx2Id, wallet.Coins.First().TransactionId);
Interlocked.Exchange(ref Common.FiltersProcessedByWalletCount, 0);
@@ -770,7 +770,7 @@ namespace WalletWasabi.Tests.RegressionTests
var coin = Assert.Single(wallet.Coins);
Assert.True(coin.Confirmed);
- Assert.False(coin.IsReplaceable);
+ Assert.False(coin.IsReplaceable());
Assert.Equal(tx2Id, coin.TransactionId);
}
finally

MODIFY
WalletWasabi.Tests/UnitTests/Transactions/TransactionProcessorTests.cs
WalletWasabi.Tests/UnitTests/Transactions/TransactionProcessorTests.cs
@@ -339,8 +339,8 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
var unconfirmedCoin1 = Assert.Single(transactionProcessor.Coins, coin => coin.HdPubKey.Label == "B");
var unconfirmedCoin2 = Assert.Single(transactionProcessor.Coins, coin => coin.HdPubKey.Label == "C");
- Assert.True(unconfirmedCoin1.IsReplaceable);
- Assert.True(unconfirmedCoin2.IsReplaceable);
+ Assert.True(unconfirmedCoin1.IsReplaceable());
+ Assert.True(unconfirmedCoin2.IsReplaceable());
// Spend the received coin
var tx2 = CreateSpendingTransaction(unconfirmedCoin1.GetCoin(), transactionProcessor.NewKey("D").P2wpkhScript);
@@ -357,7 +357,7 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
Assert.True(relevant3.IsNews);
Assert.Equal(1, replaceTransactionReceivedCalled);
var finalCoin = Assert.Single(transactionProcessor.Coins);
- Assert.True(finalCoin.IsReplaceable);
+ Assert.True(finalCoin.IsReplaceable());
Assert.Equal("E", finalCoin.HdPubKey.Label);
Assert.DoesNotContain(unconfirmedCoin1, transactionProcessor.Coins.AsAllCoinsView());
@@ -493,7 +493,7 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
Assert.True(relevant2.IsNews);
var coin = Assert.Single(transactionProcessor.Coins);
- Assert.True(coin.IsReplaceable);
+ Assert.True(coin.IsReplaceable());
// Transaction store assertions
var mempool = transactionProcessor.TransactionStore.MempoolStore.GetTransactions();
@@ -545,10 +545,10 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
relevant = transactionProcessor.Process(tx3);
Assert.True(relevant.IsNews);
- var replaceableCoin = Assert.Single(transactionProcessor.Coins, c => c.IsReplaceable);
+ var replaceableCoin = Assert.Single(transactionProcessor.Coins, c => c.IsReplaceable());
Assert.Equal(tx3.Transaction.GetHash(), replaceableCoin.TransactionId);
- var nonReplaceableCoin = Assert.Single(transactionProcessor.Coins, c => !c.IsReplaceable);
+ var nonReplaceableCoin = Assert.Single(transactionProcessor.Coins, c => !c.IsReplaceable());
Assert.Equal(tx1.Transaction.GetHash(), nonReplaceableCoin.TransactionId);
// Transaction store assertions

MODIFY
WalletWasabi/Blockchain/TransactionOutputs/SmartCoin.cs
WalletWasabi/Blockchain/TransactionOutputs/SmartCoin.cs
@@ -15,18 +15,13 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
{
#region Fields
- private Script _scriptPubKey;
- private Money _amount;
private Height _height;
private SmartLabel _label;
- private OutPoint[] _spentOutputs;
- private bool _replaceable;
private int _anonymitySet;
private uint256 _spenderTransactionId;
private bool _coinJoinInProgress;
private DateTimeOffset? _bannedUntilUtc;
private bool _spentAccordingToBackend;
- private HdPubKey _hdPubKey;
private ISecret _secret;
@@ -56,7 +51,7 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
Amount = Guard.NotNull(nameof(amount), amount);
Height = height;
SpentOutputs = Guard.NotNullOrEmpty(nameof(spentOutputs), spentOutputs);
- IsReplaceable = replaceable;
+ WasReplaceable = replaceable;
AnonymitySet = Guard.InRangeAndNotNull(nameof(anonymitySet), anonymitySet, 1, int.MaxValue);
IsLikelyCoinJoinOutput = null;
@@ -72,7 +67,6 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
Cluster = new Cluster(this);
- SetConfirmed();
SetUnspent();
SetIsBanned();
SetUnavailable();
@@ -85,21 +79,13 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
public uint256 TransactionId => OutPoint.Hash;
public uint Index => OutPoint.N;
- private int HashCode { get; set; }
+ private int HashCode { get; }
- public OutPoint OutPoint { get; private set; }
+ public OutPoint OutPoint { get; }
- public Script ScriptPubKey
- {
- get => _scriptPubKey;
- private set => RaiseAndSetIfChanged(ref _scriptPubKey, value);
- }
+ public Script ScriptPubKey { get; }
- public Money Amount
- {
- get => _amount;
- private set => RaiseAndSetIfChanged(ref _amount, value);
- }
+ public Money Amount { get; }
public Height Height
{
@@ -108,7 +94,7 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
{
if (RaiseAndSetIfChanged(ref _height, value))
{
- SetConfirmed();
+ Confirmed = _height.Type == HeightType.Chain;
}
}
}
@@ -122,22 +108,14 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
set => RaiseAndSetIfChanged(ref _label, value);
}
- public OutPoint[] SpentOutputs
- {
- get => _spentOutputs;
- private set => RaiseAndSetIfChanged(ref _spentOutputs, value);
- }
+ public OutPoint[] SpentOutputs { get; }
- public bool IsReplaceable
- {
- get => _replaceable && !Confirmed;
- private set => RaiseAndSetIfChanged(ref _replaceable, value);
- }
+ public bool WasReplaceable { get; }
public int AnonymitySet
{
get => _anonymitySet;
- private set => RaiseAndSetIfChanged(ref _anonymitySet, value);
+ set => RaiseAndSetIfChanged(ref _anonymitySet, value);
}
public uint256 SpenderTransactionId
@@ -192,11 +170,7 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
}
}
- public HdPubKey HdPubKey
- {
- get => _hdPubKey;
- private set => RaiseAndSetIfChanged(ref _hdPubKey, value);
- }
+ public HdPubKey HdPubKey { get; }
public bool? IsLikelyCoinJoinOutput { get; set; }
@@ -255,11 +229,6 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
#region PropertySetters
- private void SetConfirmed()
- {
- Confirmed = Height != Height.Mempool && Height != Height.Unknown;
- }
-
private void SetUnspent()
{
Unspent = SpenderTransactionId is null;
@@ -281,10 +250,9 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
#region Methods
- public Coin GetCoin()
- {
- return new Coin(TransactionId, Index, Amount, ScriptPubKey);
- }
+ public bool IsReplaceable() => WasReplaceable && !Confirmed;
+
+ public Coin GetCoin() => new Coin(TransactionId, Index, Amount, ScriptPubKey);
#endregion Methods

MODIFY
WalletWasabi/Blockchain/TransactionProcessing/TransactionProcessor.cs
WalletWasabi/Blockchain/TransactionProcessing/TransactionProcessor.cs
@@ -125,7 +125,7 @@ namespace WalletWasabi.Blockchain.TransactionProcessing
// if the received transaction is spending at least one input already
// spent by a previous unconfirmed transaction signaling RBF then it is not a double
// spending transaction but a replacement transaction.
- var isReplacementTx = doubleSpends.Any(x => x.IsReplaceable && !x.Confirmed);
+ var isReplacementTx = doubleSpends.Any(x => x.IsReplaceable());
if (isReplacementTx)
{
// Undo the replaced transaction by removing the coins it created (if other coin

Remove some setters