Implement status response
MODIFY
WalletWasabi.Backend/Config.cs
WalletWasabi.Backend/Config.cs
@@ -29,12 +29,16 @@ namespace WalletWasabi.Backend
[JsonProperty(PropertyName = "BitcoinRpcPassword")]
public string BitcoinRpcPassword { get; private set; }
+ public Config()
+ {
+
+ }
+
public Config(string filePath)
{
SetFilePath(filePath);
}
- [JsonConstructor]
public Config(Network network, string bitcoinRpcUser, string bitcoinRpcPassword)
{
Network = Guard.NotNull(nameof(network), network);

MODIFY
WalletWasabi.Backend/Controllers/ChaumianCoinJoinController.cs
WalletWasabi.Backend/Controllers/ChaumianCoinJoinController.cs
@@ -5,7 +5,10 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using NBitcoin;
using NBitcoin.RPC;
+using WalletWasabi.Backend.Models.Responses;
+using WalletWasabi.ChaumianCoinJoin;
using WalletWasabi.Logging;
+using WalletWasabi.Services;
namespace WalletWasabi.Backend.Controllers
{
@@ -20,16 +23,31 @@ namespace WalletWasabi.Backend.Controllers
private static Network Network => Global.Config.Network;
+ private static CcjCoordinator Coordinator => Global.Coordinator;
+
/// <summary>
/// Satoshi gets various status information.
/// </summary>
- /// <returns>CurrentPhase, Denomination, RegisteredPeerCount, RequiredPeerCount, MaximumInputCountPerPeer, FeePerInputs, FeePerOutputs, CoordinatorFee, Version</returns>
- /// <response code="200">CurrentPhase, Denomination, RegisteredPeerCount, RequiredPeerCount, MaximumInputCountPerPeer, FeePerInputs, FeePerOutputs, CoordinatorFee, Version</response>
+ /// <returns>CurrentPhase, Denomination, RegisteredPeerCount, RequiredPeerCount, MaximumInputCountPerPeer, FeePerInputs, FeePerOutputs, CoordinatorFeePercent, Version</returns>
+ /// <response code="200">CurrentPhase, Denomination, RegisteredPeerCount, RequiredPeerCount, MaximumInputCountPerPeer, FeePerInputs, FeePerOutputs, CoordinatorFeePercent, Version</response>
[HttpGet("status")]
[ProducesResponseType(200)]
public IActionResult GetStatus()
{
- return Ok();
+ CcjRound round = Coordinator.GetCurrentRound();
+ var response = new CcjStatusResponse
+ {
+ CurrentPhase = round.Phase,
+ Denomination = round.Denomination,
+ RegisteredPeerCount = round.CountAlices(syncronized: false),
+ RequiredPeerCount = round.AnonymitySet,
+ MaximumInputCountPerPeer = 7, // Constant for now. If we want to do something with it later, we'll put it to the config file.
+ FeePerInputs = round.FeePerInputs,
+ FeePerOutputs = round.FeePerOutputs,
+ CoordinatorFeePercent = round.CoordinatorFeePercent,
+ Version = 1
+ };
+ return Ok(response);
}
/// <summary>

MODIFY
WalletWasabi/ChaumianCoinJoin/CcjRound.cs
WalletWasabi/ChaumianCoinJoin/CcjRound.cs
@@ -48,7 +48,7 @@ namespace WalletWasabi.ChaumianCoinJoin
Denomination = config.Denomination;
ConfirmationTarget = (int)config.ConfirmationTarget;
- CoordinatorFeePercent = (decimal)CoordinatorFeePercent;
+ CoordinatorFeePercent = (decimal)config.CoordinatorFeePercent;
AnonymitySet = (int)config.AnonymitySet;
Phase = CcjRoundPhase.InputRegistration;
@@ -226,13 +226,20 @@ namespace WalletWasabi.ChaumianCoinJoin
}
}
- public int CountAlices()
+ public int CountAlices(bool syncronized = true)
+ {
+ if (syncronized)
{
using (RoundSyncronizerLock.Lock())
{
return Alices.Count;
}
}
+ else
+ {
+ return Alices.Count;
+ }
+ }
public void RemoveAlicesByState(AliceState state)
{
@@ -242,13 +249,20 @@ namespace WalletWasabi.ChaumianCoinJoin
}
}
- public int CountBobs()
+ public int CountBobs(bool syncronized = true)
+ {
+ if (syncronized)
{
using (RoundSyncronizerLock.Lock())
{
return Bobs.Count;
}
}
+ else
+ {
+ return Alices.Count;
+ }
+ }
public void UpdateAnonymitySet(int anonymitySet)
{

MODIFY
WalletWasabi/ChaumianCoinJoin/CcjRoundConfig.cs
WalletWasabi/ChaumianCoinJoin/CcjRoundConfig.cs
@@ -20,7 +20,7 @@ namespace WalletWasabi.ChaumianCoinJoin
public string FilePath { get; private set; }
[JsonProperty(PropertyName = "Denomination")]
- [JsonConverter(typeof(MoneyConverter))]
+ [JsonConverter(typeof(MoneyBtcConverter))]
public Money Denomination { get; private set; }
[JsonProperty(PropertyName = "ConfirmationTarget")]
@@ -44,12 +44,17 @@ namespace WalletWasabi.ChaumianCoinJoin
[JsonProperty(PropertyName = "SigningTimeout")]
public long? SigningTimeout { get; private set; }
+
+ public CcjRoundConfig()
+ {
+
+ }
+
public CcjRoundConfig(string filePath)
{
SetFilePath(filePath);
}
- [JsonConstructor]
public CcjRoundConfig(Money denomination, int? confirmationTarget, decimal? coordinatorFeePercent, int? anonymitySet, long? inputRegistrationTimeout, long? connectionConfirmationTimeout, long? outputRegistrationTimeout, long? signingTimeout)
{
FilePath = null;

RENAME
WalletWasabi/Converters/MoneyConverter.cs
WalletWasabi/Converters/MoneyBtcConverter.cs
@@ -6,10 +6,7 @@ using System.Text;
namespace WalletWasabi.Converters
{
- /// <summary>
- /// BTC, not Satoshi
- /// </summary>
- public class MoneyConverter : JsonConverter
+ public class MoneyBtcConverter : JsonConverter
{
/// <inheritdoc />
public override bool CanConvert(Type objectType)

MODIFY
WalletWasabi/Models/SmartCoin.cs
WalletWasabi/Models/SmartCoin.cs
@@ -28,7 +28,7 @@ namespace WalletWasabi.Models
public Script ScriptPubKey { get; }
[JsonProperty(Order = 4)]
- [JsonConverter(typeof(MoneyConverter))]
+ [JsonConverter(typeof(MoneyBtcConverter))]
public Money Amount { get; }
[JsonProperty(Order = 5)]

MODIFY
WalletWasabi/WalletWasabi.csproj
WalletWasabi/WalletWasabi.csproj
<DocumentationFile>bin\Debug\netcoreapp2.0\WalletWasabi.xml</DocumentationFile>
</PropertyGroup>
- <ItemGroup>
- <Compile Remove="Backend\Models\Responses\**" />
- <EmbeddedResource Remove="Backend\Models\Responses\**" />
- <None Remove="Backend\Models\Responses\**" />
- </ItemGroup>
-
<ItemGroup>
<PackageReference Include="ConcurrentHashSet" Version="1.0.2" />
<PackageReference Include="NBitcoin" Version="4.1.0.7" />

Implement status response