Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
Don't expose Ergo Wallet Password through API
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Weichhold committed Jan 14, 2022
1 parent f9996e3 commit 44ab4de
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Miningcore/Api/Controllers/ClusterApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ClusterApiController(IComponentContext ctx) : base(ctx)
public async Task<Responses.Block[]> PageBlocksPagedAsync(
[FromQuery] int page, [FromQuery] int pageSize = 15, [FromQuery] BlockStatus[] state = null)
{
var blockStates = state != null && state.Length > 0 ?
var blockStates = state is { Length: > 0 } ?
state :
new[] { BlockStatus.Confirmed, BlockStatus.Pending, BlockStatus.Orphaned };

Expand Down
3 changes: 1 addition & 2 deletions src/Miningcore/Api/Controllers/PoolApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ public async Task<GetPoolResponse> GetPoolInfoAsync(string poolId)

var from = clock.Now.AddDays(-1);

response.Pool.TopMiners = (await cf.Run(con => statsRepo.PagePoolMinersByHashrateAsync(
con, pool.Id, from, 0, 15)))
response.Pool.TopMiners = (await cf.Run(con => statsRepo.PagePoolMinersByHashrateAsync(con, pool.Id, from, 0, 15)))
.Select(mapper.Map<MinerPerformanceStats>)
.ToArray();

Expand Down
4 changes: 3 additions & 1 deletion src/Miningcore/Api/Extensions/MiningPoolExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using AutoMapper;
using Miningcore.Api.Responses;
using Miningcore.Blockchain;
using Miningcore.Blockchain.Ergo.Configuration;
using Miningcore.Configuration;
using Miningcore.Extensions;
using Miningcore.Mining;

namespace Miningcore.Api.Extensions;
Expand All @@ -28,7 +30,7 @@ public static PoolInfo ToPoolInfo(this PoolConfig poolConfig, IMapper mapper, Pe
{
var extra = poolInfo.PaymentProcessing.Extra;

//extra.StripValue(nameof(EthereumPoolPaymentProcessingConfigExtra.CoinbasePassword));
extra.StripValue(nameof(ErgoPaymentProcessingConfigExtra.WalletPassword));
}

return poolInfo;
Expand Down
28 changes: 28 additions & 0 deletions src/Miningcore/Extensions/DictionaryExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;

namespace Miningcore.Extensions
{
public static class DictionaryExtensions
{
public static void StripValue<T>(this IDictionary<string, T> dict, string key)
{
if(dict == null)
return;

key = key.ToLower(CultureInfo.InvariantCulture);

var keyActual = dict.Keys.FirstOrDefault(x => x.ToLower(CultureInfo.InvariantCulture) == key);

if(keyActual != null)
{
var result = dict.Remove(keyActual);
Debug.Assert(result);
}
}
}
}

0 comments on commit 44ab4de

Please sign in to comment.