SmartCoin refresh method
MODIFY
WalletWasabi/Blockchain/TransactionOutputs/SmartCoin.cs
WalletWasabi/Blockchain/TransactionOutputs/SmartCoin.cs
@@ -101,10 +101,9 @@ public class SmartCoin : NotifyPropertyChangedBase, IEquatable<SmartCoin>, IDest
get => _bannedUntilUtc;
set
{
- // ToDo: IsBanned does not get notified when it gets unbanned.
if (RaiseAndSetIfChanged(ref _bannedUntilUtc, value))
{
- SetIsBanned();
+ RefreshAndGetIsBanned();
}
}
}
@@ -136,9 +135,12 @@ public class SmartCoin : NotifyPropertyChangedBase, IEquatable<SmartCoin>, IDest
private set => RaiseAndSetIfChanged(ref _confirmed, value);
}
+ /// <summary>
+ /// If you want to have a notification about a coin is released, then you have to periodically read IsBanned.
+ /// </summary>
public bool IsBanned
{
- get => _isBanned;
+ get => RefreshAndGetIsBanned();
private set => RaiseAndSetIfChanged(ref _isBanned, value);
}
@@ -147,9 +149,19 @@ public class SmartCoin : NotifyPropertyChangedBase, IEquatable<SmartCoin>, IDest
return Transaction.Transaction.IsCoinBase && Height < bestHeight - 100;
}
- public void SetIsBanned()
+ public bool RefreshAndGetIsBanned()
+ {
+ if(BannedUntilUtc is { } && BannedUntilUtc > DateTimeOffset.UtcNow)
{
- IsBanned = BannedUntilUtc is { } && BannedUntilUtc > DateTimeOffset.UtcNow;
+ IsBanned = true;
+ return true;
+ }
+
+ IsBanned = false;
+ BannedUntilUtc = null;
+
+ return false;
+
}
[MemberNotNullWhen(returnValue: true, nameof(SpenderTransaction))]

SmartCoin refresh method