Prepare for labelling
MODIFY
WalletWasabi.Tests/SmartModelTests.cs
WalletWasabi.Tests/SmartModelTests.cs
@@ -82,12 +82,14 @@ namespace WalletWasabi.Tests
var tx3 = Transaction.Parse("02000000040aa8d0af84518df6e3a60c5bb19d9c3fcc3dc6e26b2f2449e8d7bf8d3fe84b87010000006a473044022018dfe9216c1209dd6c2b6c1607dbac4e499c1fce4878bc7d5d83fccbf3e24c9402202cac351c9c6a2b5eef338cbf0ec000d8de1c05e96a904cbba2b9e6ffc2d4e19501210364cc39da1091b1a9c12ec905a14a9e8478f951f7a1accdabeb40180533f2eaa5feffffff112c07d0f5e0617d720534f0b2b84dc0d5b7314b358c3ab338823b9e5bfbddf5010000006b483045022100ec155e7141e74661ee511ae980150a6c89261f31070999858738369afc28f2b6022006230d2aa24fac110b74ef15b84371486cf76c539b335a253c14462447912a300121020c2f41390f031d471b22abdb856e6cdbe0f4d74e72c197469bfd54e5a08f7e67feffffff38e799b8f6cf04fd021a9b135cdcd347da7aac4fd8bb8d0da9316a9fb228bb6e000000006b483045022100fc1944544a3f96edd8c8a9795c691e2725612b5ab2e1c999be11a2a4e3f841f1022077b2e088877829edeada0c707a9bb577aa79f26dafacba3d1d2d047f52524296012102e6015963dff9826836400cf8f45597c0705757d5dcdc6bf734f661c7dab89e69feffffff64c3f0377e86625123f2f1ee229319ed238e8ca8b7dda5bc080a2c5ecb984629000000006a47304402204233a90d6296182914424fd2901e16e6f5b13b451b67b0eec25a5eaacc5033c902203d8a13ef0b494c12009663475458e51da6bd55cc67688264230ece81d3eeca24012102f806d7152da2b52c1d9ad928e4a6253ccba080a5b9ab9efdd80e37274ac67f9bfeffffff0290406900000000001976a91491ac4e49b66f845180d98d8f8be6121588be6e3b88ac52371600000000001976a9142f44ed6749e8c84fd476e4440741f7e6f55542fa88acadd30700", Network.RegTest);
var height = Height.MemPool;
- var smartTx = new SmartTransaction(tx, height);
+ string label = "foo";
+ var smartTx = new SmartTransaction(tx, height, label: label);
var smartTx2 = new SmartTransaction(tx2, height);
var smartTx3 = new SmartTransaction(tx3, height);
var serialized = JsonConvert.SerializeObject(smartTx);
var deserialized = JsonConvert.DeserializeObject<SmartTransaction>(serialized);
+ Assert.Equal(label, smartTx.Label);
var serialized2 = JsonConvert.SerializeObject(smartTx2);
var deserialized2 = JsonConvert.DeserializeObject<SmartTransaction>(serialized2);
@@ -106,6 +108,10 @@ namespace WalletWasabi.Tests
object to = deserialized.Transaction;
Assert.True(smartTx.Equals(deserialized.Transaction));
// ToDo: Assert.True(smartTx.Equals(to));
+
+ var serializedWithoutLabel = "{\"Transaction\":\"02000000040aa8d0af84518df6e3a60c5bb19d9c3fcc3dc6e26b2f2449e8d7bf8d3fe84b87010000006a473044022018dfe9216c1209dd6c2b6c1607dbac4e499c1fce4878bc7d5d83fccbf3e24c9402202cac351c9c6a2b5eef338cbf0ec000d8de1c05e96a904cbba2b9e6ffc2d4e19501210364cc39da1091b1a9c12ec905a14a9e8478f951f7a1accdabeb40180533f2eaa5feffffff112c07d0f5e0617d720534f0b2b84dc0d5b7314b358c3ab338823b9e5bfbddf5010000006b483045022100ec155e7141e74661ee511ae980150a6c89261f31070999858738369afc28f2b6022006230d2aa24fac110b74ef15b84371486cf76c539b335a253c14462447912a300121020c2f41390f031d471b22abdb856e6cdbe0f4d74e72c197469bfd54e5a08f7e67feffffff38e799b8f6cf04fd021a9b135cdcd347da7aac4fd8bb8d0da9316a9fb228bb6e000000006b483045022100fc1944544a3f96edd8c8a9795c691e2725612b5ab2e1c999be11a2a4e3f841f1022077b2e088877829edeada0c707a9bb577aa79f26dafacba3d1d2d047f52524296012102e6015963dff9826836400cf8f45597c0705757d5dcdc6bf734f661c7dab89e69feffffff64c3f0377e86625123f2f1ee229319ed238e8ca8b7dda5bc080a2c5ecb984629000000006a47304402204233a90d6296182914424fd2901e16e6f5b13b451b67b0eec25a5eaacc5033c902203d8a13ef0b494c12009663475458e51da6bd55cc67688264230ece81d3eeca24012102f806d7152da2b52c1d9ad928e4a6253ccba080a5b9ab9efdd80e37274ac67f9bfeffffff0290406900000000001976a91491ac4e49b66f845180d98d8f8be6121588be6e3b88ac52371600000000001976a9142f44ed6749e8c84fd476e4440741f7e6f55542fa88acadd30700\",\"Height\":\"2147483646\"}";
+ var deserializedWithoutLabel = JsonConvert.DeserializeObject<SmartTransaction>(serializedWithoutLabel);
+ Assert.Empty(deserializedWithoutLabel.Label);
}
[Fact]

MODIFY
WalletWasabi/Models/SmartCoin.cs
WalletWasabi/Models/SmartCoin.cs
@@ -202,6 +202,8 @@ namespace WalletWasabi.Models
return new TxoRef(TransactionId, Index);
}
+ public bool HasLabel() => !string.IsNullOrWhiteSpace(Label);
+
#region EqualityAndComparison
public override bool Equals(object obj) => obj is SmartCoin && this == (SmartCoin)obj;

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -200,9 +200,9 @@ namespace WalletWasabi.Services
if (File.Exists(TransactionsFilePath))
{
string jsonString = File.ReadAllText(TransactionsFilePath, Encoding.UTF8);
- var mempool = JsonConvert.DeserializeObject<IEnumerable<SmartTransaction>>(jsonString);
+ var serializedTransactions = JsonConvert.DeserializeObject<IEnumerable<SmartTransaction>>(jsonString);
- foreach (var tx in mempool)
+ foreach (SmartTransaction tx in serializedTransactions.Where(x => !x.Confirmed))
{
try
{
@@ -412,7 +412,7 @@ namespace WalletWasabi.Services
if (tx.Height.Type == HeightType.Chain)
{
MemPool.TransactionHashes.TryRemove(tx.GetHash()); // If we have in mempool, remove.
- SmartTransaction foundTx = TransactionCache.FirstOrDefault(x => x.GetHash() == tx.GetHash()); // If we have in cache, update height.
+ SmartTransaction foundTx = TransactionCache.FirstOrDefault(x => x == tx); // If we have in cache, update height.
if (foundTx != default(SmartTransaction))
{
foundTx.SetHeight(tx.Height);
@@ -1036,7 +1036,7 @@ namespace WalletWasabi.Services
var directoryPath = Path.GetDirectoryName(Path.GetFullPath(TransactionsFilePath));
Directory.CreateDirectory(directoryPath);
- string jsonString = JsonConvert.SerializeObject(TransactionCache.Where(x => x.Height == Height.MemPool), Formatting.Indented);
+ string jsonString = JsonConvert.SerializeObject(TransactionCache, Formatting.Indented);
File.WriteAllText(TransactionsFilePath,
jsonString,
Encoding.UTF8);

Prepare for labelling