User records instead of classes
MODIFY
WalletWasabi/WabiSabi/Backend/Banning/Inmate.cs
WalletWasabi/WabiSabi/Backend/Banning/Inmate.cs
@@ -11,21 +11,12 @@ namespace WalletWasabi.WabiSabi.Backend.Banning
/// <summary>
/// A UTXO that's living inside the prison.
/// </summary>
- public class Inmate
+ public record Inmate(
+ OutPoint Utxo,
+ Punishment Punishment,
+ DateTimeOffset Started,
+ Guid LastDisruptedRoundId)
{
- public Inmate(OutPoint utxo, Punishment punishment, DateTimeOffset started, Guid lastDisruptedRoundId)
- {
- Utxo = utxo;
- Punishment = punishment;
- Started = started;
- LastDisruptedRoundId = lastDisruptedRoundId;
- }
-
- public OutPoint Utxo { get; }
- public Punishment Punishment { get; }
- public DateTimeOffset Started { get; }
- public Guid LastDisruptedRoundId { get; }
-
public TimeSpan TimeSpent => DateTimeOffset.UtcNow - Started;
public static Inmate FromString(string str)
@@ -47,8 +38,6 @@ namespace WalletWasabi.WabiSabi.Backend.Banning
}
public override string ToString()
- {
- return $"{Started.ToUnixTimeSeconds()}:{Punishment}:{Utxo.Hash}:{Utxo.N}:{LastDisruptedRoundId}";
- }
+ => $"{Started.ToUnixTimeSeconds()}:{Punishment}:{Utxo.Hash}:{Utxo.N}:{LastDisruptedRoundId}";
}
}

MODIFY
WalletWasabi/WabiSabi/Backend/Models/Bob.cs
WalletWasabi/WabiSabi/Backend/Models/Bob.cs
@@ -7,27 +7,22 @@ using System.Threading.Tasks;
namespace WalletWasabi.WabiSabi.Backend.Models
{
- public class Bob
- {
- public Bob(Script script, long credentialAmount)
- {
- Script = script;
- CredentialAmount = credentialAmount;
- }
-
- public Script Script { get; }
-
+ public record Bob(
+ Script Script,
/// <summary>
/// This is slightly larger than the final TXO amount,
/// because the fees are coming down from this.
/// </summary>
- public long CredentialAmount { get; }
+ long CredentialAmount)
+ {
- public int OutputVsize => Script.EstimateOutputVsize();
+ public int OutputVsize
+ => Script.EstimateOutputVsize();
public Money CalculateOutputAmount(FeeRate feeRate)
=> CredentialAmount - feeRate.GetFee(OutputVsize);
- public long CalculateWeight() => OutputVsize * 4;
+ public long CalculateWeight()
+ => OutputVsize * 4;
}
}

MODIFY
WalletWasabi/WabiSabi/Models/ConnectionConfirmationRequest.cs
WalletWasabi/WabiSabi/Models/ConnectionConfirmationRequest.cs
@@ -8,23 +8,12 @@ using WalletWasabi.WabiSabi.Crypto.CredentialRequesting;
namespace WalletWasabi.WabiSabi.Models
{
- public class ConnectionConfirmationRequest
- {
- public ConnectionConfirmationRequest(Guid roundId, Guid aliceId, ZeroCredentialsRequest zeroAmountCredentialRequests, RealCredentialsRequest realAmountCredentialRequests, ZeroCredentialsRequest zeroWeightCredentialRequests, RealCredentialsRequest realWeightCredentialRequests)
- {
- RoundId = roundId;
- AliceId = aliceId;
- ZeroAmountCredentialRequests = zeroAmountCredentialRequests;
- RealAmountCredentialRequests = realAmountCredentialRequests;
- ZeroWeightCredentialRequests = zeroWeightCredentialRequests;
- RealWeightCredentialRequests = realWeightCredentialRequests;
- }
-
- public Guid RoundId { get; }
- public Guid AliceId { get; }
- public ZeroCredentialsRequest ZeroAmountCredentialRequests { get; }
- public RealCredentialsRequest RealAmountCredentialRequests { get; }
- public ZeroCredentialsRequest ZeroWeightCredentialRequests { get; }
- public RealCredentialsRequest RealWeightCredentialRequests { get; }
- }
+ public record ConnectionConfirmationRequest(
+ Guid RoundId,
+ Guid AliceId,
+ ZeroCredentialsRequest ZeroAmountCredentialRequests,
+ RealCredentialsRequest RealAmountCredentialRequests,
+ ZeroCredentialsRequest ZeroWeightCredentialRequests,
+ RealCredentialsRequest RealWeightCredentialRequests
+ );
}

MODIFY
WalletWasabi/WabiSabi/Models/ConnectionConfirmationResponse.cs
WalletWasabi/WabiSabi/Models/ConnectionConfirmationResponse.cs
@@ -7,19 +7,10 @@ using WalletWasabi.WabiSabi.Crypto.CredentialRequesting;
namespace WalletWasabi.WabiSabi.Models
{
- public class ConnectionConfirmationResponse
- {
- public ConnectionConfirmationResponse(CredentialsResponse zeroAmountCredentials, CredentialsResponse zeroWeightCredentials, CredentialsResponse? realAmountCredentials = null, CredentialsResponse? realWeightCredentials = null)
- {
- ZeroAmountCredentials = zeroAmountCredentials;
- ZeroWeightCredentials = zeroWeightCredentials;
- RealAmountCredentials = realAmountCredentials;
- RealWeightCredentials = realWeightCredentials;
- }
-
- public CredentialsResponse ZeroAmountCredentials { get; }
- public CredentialsResponse ZeroWeightCredentials { get; }
- public CredentialsResponse? RealAmountCredentials { get; }
- public CredentialsResponse? RealWeightCredentials { get; }
- }
+ public record ConnectionConfirmationResponse(
+ CredentialsResponse ZeroAmountCredentials,
+ CredentialsResponse ZeroWeightCredentials,
+ CredentialsResponse? RealAmountCredentials = null,
+ CredentialsResponse? RealWeightCredentials = null
+ );
}

MODIFY
WalletWasabi/WabiSabi/Models/InputRoundSignaturePair.cs
WalletWasabi/WabiSabi/Models/InputRoundSignaturePair.cs
using NBitcoin;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace WalletWasabi.WabiSabi.Models
{
- public class InputRoundSignaturePair
- {
- public InputRoundSignaturePair(OutPoint input, byte[] roundSignature)
- {
- Input = input;
- RoundSignature = roundSignature;
- }
-
- public OutPoint Input { get; }
-
- public byte[] RoundSignature { get; }
- }
+ public record InputRoundSignaturePair(
+ OutPoint Input,
+ byte[] RoundSignature
+ );
}

MODIFY
WalletWasabi/WabiSabi/Models/InputWitnessPair.cs
WalletWasabi/WabiSabi/Models/InputWitnessPair.cs
using NBitcoin;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace WalletWasabi.WabiSabi.Models
{
- public class InputWitnessPair
- {
- public InputWitnessPair(uint inputIndex, WitScript witness)
- {
- InputIndex = inputIndex;
- Witness = witness;
- }
-
- public uint InputIndex { get; }
- public WitScript Witness { get; }
- }
+ public record InputWitnessPair(
+ uint InputIndex,
+ WitScript Witness
+ );
}

MODIFY
WalletWasabi/WabiSabi/Models/InputsRegistrationRequest.cs
WalletWasabi/WabiSabi/Models/InputsRegistrationRequest.cs
-using NBitcoin;
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using WalletWasabi.WabiSabi.Crypto.CredentialRequesting;
namespace WalletWasabi.WabiSabi.Models
{
- public class InputsRegistrationRequest
- {
- public InputsRegistrationRequest(Guid roundId, IEnumerable<InputRoundSignaturePair> inputRoundSignaturePairs, ZeroCredentialsRequest zeroAmountCredentialRequests, ZeroCredentialsRequest zeroWeightCredentialRequests)
- {
- RoundId = roundId;
- InputRoundSignaturePairs = inputRoundSignaturePairs;
- ZeroAmountCredentialRequests = zeroAmountCredentialRequests;
- ZeroWeightCredentialRequests = zeroWeightCredentialRequests;
- }
-
- public Guid RoundId { get; }
- public IEnumerable<InputRoundSignaturePair> InputRoundSignaturePairs { get; }
- public ZeroCredentialsRequest ZeroAmountCredentialRequests { get; }
- public ZeroCredentialsRequest ZeroWeightCredentialRequests { get; }
- }
+ public record InputsRegistrationRequest(
+ Guid RoundId,
+ IEnumerable<InputRoundSignaturePair> InputRoundSignaturePairs,
+ ZeroCredentialsRequest ZeroAmountCredentialRequests,
+ ZeroCredentialsRequest ZeroWeightCredentialRequests
+ );
}

MODIFY
WalletWasabi/WabiSabi/Models/InputsRegistrationResponse.cs
WalletWasabi/WabiSabi/Models/InputsRegistrationResponse.cs
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using WalletWasabi.WabiSabi.Crypto.CredentialRequesting;
namespace WalletWasabi.WabiSabi.Models
{
- public class InputsRegistrationResponse
- {
- public InputsRegistrationResponse(Guid aliceId, CredentialsResponse amountCredentials, CredentialsResponse weightCredentials)
- {
- AliceId = aliceId;
- AmountCredentials = amountCredentials;
- WeightCredentials = weightCredentials;
- }
-
- public Guid AliceId { get; }
- public CredentialsResponse AmountCredentials { get; }
- public CredentialsResponse WeightCredentials { get; }
- }
+ public record InputsRegistrationResponse(
+ Guid AliceId,
+ CredentialsResponse AmountCredentials,
+ CredentialsResponse WeightCredentials
+ );
}

MODIFY
WalletWasabi/WabiSabi/Models/InputsRemovalRequest.cs
WalletWasabi/WabiSabi/Models/InputsRemovalRequest.cs
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace WalletWasabi.WabiSabi.Models
{
- public class InputsRemovalRequest
- {
- public InputsRemovalRequest(Guid roundId, Guid aliceId)
- {
- RoundId = roundId;
- AliceId = aliceId;
- }
-
- public Guid RoundId { get; }
- public Guid AliceId { get; }
- }
+ public record InputsRemovalRequest(
+ Guid RoundId,
+ Guid AliceId
+ );
}

MODIFY
WalletWasabi/WabiSabi/Models/OutputRegistrationRequest.cs
WalletWasabi/WabiSabi/Models/OutputRegistrationRequest.cs
-using NBitcoin;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using WalletWasabi.Crypto.ZeroKnowledge;
+using NBitcoin;
using WalletWasabi.WabiSabi.Crypto.CredentialRequesting;
namespace WalletWasabi.WabiSabi.Models
{
- public class OutputRegistrationRequest
- {
- public OutputRegistrationRequest(Guid roundId, Script script, RealCredentialsRequest amountCredentialRequests, RealCredentialsRequest weightCredentialRequests)
- {
- RoundId = roundId;
- Script = script;
- AmountCredentialRequests = amountCredentialRequests;
- WeightCredentialRequests = weightCredentialRequests;
- }
-
- public Guid RoundId { get; }
- public Script Script { get; }
- public RealCredentialsRequest AmountCredentialRequests { get; }
- public RealCredentialsRequest WeightCredentialRequests { get; }
- }
+ public record OutputRegistrationRequest(
+ Guid RoundId,
+ Script Script,
+ RealCredentialsRequest AmountCredentialRequests,
+ RealCredentialsRequest WeightCredentialRequests
+ );
}

MODIFY
WalletWasabi/WabiSabi/Models/OutputRegistrationResponse.cs
WalletWasabi/WabiSabi/Models/OutputRegistrationResponse.cs
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using WalletWasabi.WabiSabi.Crypto.CredentialRequesting;
namespace WalletWasabi.WabiSabi.Models
{
- public class OutputRegistrationResponse
- {
- public OutputRegistrationResponse(string unsignedTransactionSecret, CredentialsResponse amountCredentials, CredentialsResponse weightCredentials)
- {
- UnsignedTransactionSecret = unsignedTransactionSecret;
- AmountCredentials = amountCredentials;
- WeightCredentials = weightCredentials;
- }
-
- public string UnsignedTransactionSecret { get; }
- public CredentialsResponse AmountCredentials { get; }
- public CredentialsResponse WeightCredentials { get; }
- }
+ public record OutputRegistrationResponse(
+ string UnsignedTransactionSecret,
+ CredentialsResponse AmountCredentials,
+ CredentialsResponse WeightCredentials
+ );
}

MODIFY
WalletWasabi/WabiSabi/Models/TransactionSignaturesRequest.cs
WalletWasabi/WabiSabi/Models/TransactionSignaturesRequest.cs
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace WalletWasabi.WabiSabi.Models
{
- public class TransactionSignaturesRequest
- {
- public TransactionSignaturesRequest(Guid roundId, IEnumerable<InputWitnessPair> inputWitnessPairs)
- {
- RoundId = roundId;
- InputWitnessPairs = inputWitnessPairs;
- }
-
- public Guid RoundId { get; }
- public IEnumerable<InputWitnessPair> InputWitnessPairs { get; }
- }
+ public record TransactionSignaturesRequest(
+ Guid RoundId,
+ IEnumerable<InputWitnessPair> InputWitnessPairs
+ );
}

User records instead of classes