Skip to content

Commit

Permalink
Merge pull request #14 from Elenpay/develop
Browse files Browse the repository at this point in the history
Release 0.1.0
  • Loading branch information
Jossec101 authored Jan 3, 2023
2 parents 113e896 + aaa5d62 commit a614e36
Show file tree
Hide file tree
Showing 34 changed files with 1,592 additions and 360 deletions.
54 changes: 0 additions & 54 deletions ansible/deploy_playbook.yaml

This file was deleted.

81 changes: 0 additions & 81 deletions ansible/docker-compose.deploy.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions ansible/inventory.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion docker/docker-compose.dev-novs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ services:
NBXPLORER_CHAINS: "btc"
NBXPLORER_BTCRPCUSER: "polaruser"
NBXPLORER_BTCRPCPASSWORD: "polarpass"
NBXPLORER_BTCRPCURL: http://host.docker.internal:18445/
NBXPLORER_BTCRPCURL: http://host.docker.internal:18443/
NBXPLORER_BTCNODEENDPOINT: host.docker.internal:19444
command: ["--noauth"]
volumes:
Expand Down
6 changes: 3 additions & 3 deletions src/Data/DbInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public static void Initialize(IServiceProvider serviceProvider)
applicationDbContext.Add(internalWallet);
applicationDbContext.SaveChanges();

logger.LogInformation("Internal wallet setup, seed:{}", internalWallet.MnemonicString);
logger.LogInformation("Internal wallet setup, seed: {MnemonicString}", internalWallet.MnemonicString);

internalWalletKey =
new Key
Expand Down Expand Up @@ -281,7 +281,7 @@ public static void Initialize(IServiceProvider serviceProvider)

var wallet1DerivationScheme = bitcoinExtPubKey1.ToWif();

logger.LogInformation("Wallet 1 seed: {}", wallet1seed);
logger.LogInformation("Wallet 1 seed: {MnemonicString}", wallet1seed);

var wallet2seed =
"solar goat auto bachelor chronic input twin depth fork scale divorce fury mushroom column image sauce car public artist announce treat spend jacket physical";
Expand All @@ -297,7 +297,7 @@ public static void Initialize(IServiceProvider serviceProvider)

var wallet2DerivationScheme = bitcoinExtPubKey2.ToWif();

logger.LogInformation("Wallet 2 seed: {}", wallet2seed);
logger.LogInformation("Wallet 2 seed: {MnemonicString}", wallet2seed);

var testingMultisigWallet = new Wallet
{
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Models/ChannelOperationRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public decimal Amount
!x.IsFinalisedPSBT && !x.IsTemplatePSBT && !x.IsInternalWalletPSBT);

/// <summary>
/// This is the JobId provided by Hangfire of the job executing this request.
/// This is the JobId provided by Quartz of the job executing this request.
/// </summary>
public string? JobId { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion src/Data/Models/WalletWithdrawalRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class WalletWithdrawalRequest : Entity, IEquatable<WalletWithdrawalReques
!x.IsTemplatePSBT && !x.IsFinalisedPSBT && !x.IsInternalWalletPSBT);

/// <summary>
/// This is the JobId provided by Hangfire of the job executing this request.
/// This is the JobId provided by Quartz of the job executing this request.
/// </summary>
public string? JobId { get; set; }

Expand Down
6 changes: 3 additions & 3 deletions src/Data/Repositories/ApplicationUserRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ on userRoles.UserId equals user.Id
var updateStampResult = await applicationDbContext.SaveChangesAsync() > 0;
if (!updateStampResult)
{
_logger.LogError("Error while invalidating user security stamp, user id:{}", user.Id);
_logger.LogError("Error while invalidating user security stamp, user id: {UserId}", user.Id);
}
}

Expand All @@ -292,13 +292,13 @@ on userRoles.UserId equals user.Id

if (!result.Item1)
{
_logger.LogError("Error while updating user roles, user Id:{}", user.Id);
_logger.LogError("Error while updating user roles, user Id: {UserId}", user.Id);
result.Item2 = "Error while updating user roles";
}
}
catch (Exception e)
{
_logger.LogError(e, "Error while updating user roles, user Id:{}", user.Id);
_logger.LogError(e, "Error while updating user roles, user Id: {UserId}", user.Id);
}

return result;
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Repositories/ChannelOperationRequestRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public async Task<List<ChannelOperationRequest>> GetUnsignedPendingRequestsByUse
}
catch (Exception e)
{
_logger.LogError(e, "Error while adding UTXOs ({}) to op request:{}", utxos.Humanize(), type.Id);
_logger.LogError(e, "Error while adding UTXOs ({Utxos}) to op request: {RequestId}", utxos.Humanize(), type.Id);

result.Item1 = false;
}
Expand Down
26 changes: 17 additions & 9 deletions src/Data/Repositories/ChannelRepository.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using AutoMapper;
using FundsManager.Data.Models;
using FundsManager.Data.Repositories.Interfaces;
using FundsManager.Services;
using Hangfire;
using FundsManager.Jobs;
using FundsManager.Helpers;
using Quartz;
using Microsoft.EntityFrameworkCore;

namespace FundsManager.Data.Repositories
Expand All @@ -13,21 +14,21 @@ public class ChannelRepository : IChannelRepository
private readonly ILogger<ChannelRepository> _logger;
private readonly IDbContextFactory<ApplicationDbContext> _dbContextFactory;
private readonly IChannelOperationRequestRepository _channelOperationRequestRepository;
private readonly IBackgroundJobClient _backgroundJobClient;
private readonly ISchedulerFactory _schedulerFactory;
private readonly IMapper _mapper;

public ChannelRepository(IRepository<Channel> repository,
ILogger<ChannelRepository> logger,
IDbContextFactory<ApplicationDbContext> dbContextFactory,
IChannelOperationRequestRepository channelOperationRequestRepository, IBackgroundJobClient backgroundJobClient,
IChannelOperationRequestRepository channelOperationRequestRepository, ISchedulerFactory schedulerFactory,
IMapper mapper
)
{
_repository = repository;
_logger = logger;
_dbContextFactory = dbContextFactory;
_channelOperationRequestRepository = channelOperationRequestRepository;
_backgroundJobClient = backgroundJobClient;
_schedulerFactory = schedulerFactory;
this._mapper = mapper;
}

Expand Down Expand Up @@ -104,22 +105,29 @@ public async Task<List<Channel>> GetAll()

if (!closeRequestAddResult.Item1)
{
_logger.LogError("Error while saving close request for channel with id:{}", type.Id);
_logger.LogError("Error while saving close request for channel with id: {RequestId}", type.Id);
return (false, closeRequestAddResult.Item2);
}

closeRequest = await _channelOperationRequestRepository.GetById(closeRequest.Id);

if (closeRequest == null) return (false, null);

var jobId = _backgroundJobClient.Enqueue<ILightningService>(service => service.CloseChannel(closeRequest, forceClose));
var scheduler = await _schedulerFactory.GetScheduler();

var map = new JobDataMap();
map.Put("closeRequest", closeRequest);
map.Put("forceClose", forceClose);
var job = RetriableJob.Create<ChannelCloseJob>(map);
await scheduler.ScheduleJob(job.Job, job.Trigger);

closeRequest.JobId = jobId;
// TODO: Check job id
closeRequest.JobId = job.Job.Key.ToString();

var jobUpdateResult = _channelOperationRequestRepository.Update(closeRequest);
if (!jobUpdateResult.Item1)
{
_logger.LogError("Error while updating the JobId for the close request with id:{}",
_logger.LogError("Error while updating the JobId for the close request with id: {RequestId}",
closeRequest.Id);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Data/Repositories/WalletRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public async Task<List<Wallet>> GetAvailableWallets()
}
catch (Exception e)
{
_logger.LogError(e, "Error while finalising wallet:{}", selectedWalletToFinalise.Id);
_logger.LogError(e, "Error while finalising wallet: {WalletId}", selectedWalletToFinalise.Id);

result = (false, "Error while finalising wallet");
}
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Repositories/WalletWithdrawalRequestRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public async Task<List<WalletWithdrawalRequest>> GetUnsignedPendingRequestsByUse
}
catch (Exception e)
{
_logger.LogError(e, "Error while adding UTXOs ({}) to op request:{}", utxos.Humanize(), type.Id);
_logger.LogError(e, "Error while adding UTXOs ({Utxos}) to op request: {RequestId}", utxos.Humanize(), type.Id);

result.Item1 = false;
}
Expand Down
1 change: 1 addition & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ RUN dotnet publish "FundsManager.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
COPY src/Migrations/*.sql Migrations/
ENTRYPOINT ["dotnet", "FundsManager.dll"]
6 changes: 0 additions & 6 deletions src/FundsManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
<PackageReference Include="Blazorise.Components" Version="1.1.5" />
<PackageReference Include="Blazorise.Icons.FontAwesome" Version="1.1.5" />
<PackageReference Include="Grpc.AspNetCore" Version="2.50.0" />
<PackageReference Include="Hangfire" Version="1.7.31" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.31" />
<PackageReference Include="Hangfire.Core" Version="1.7.31" />
<PackageReference Include="Hangfire.PostgreSql" Version="1.9.9" />
<PackageReference Include="Hangfire.Redis.StackExchange" Version="1.7.2" />
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="6.0.12" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.10" />
Expand All @@ -49,7 +44,6 @@
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc9.9" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc9.9" />
<PackageReference Include="OpenTelemetry.Instrumentation.EntityFrameworkCore" Version="1.0.0-beta.3" />
<PackageReference Include="OpenTelemetry.Instrumentation.Hangfire" Version="1.0.0-beta.3" />
<PackageReference Include="OpenTelemetry.Instrumentation.Quartz" Version="1.0.0-alpha.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.0.0" />
<PackageReference Include="Quartz" Version="3.5.0" />
Expand Down
Loading

0 comments on commit a614e36

Please sign in to comment.