Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: utxo instead of fmutxos #372

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
volumes:
- nodeguard_postgres_data:/var/lib/postgresql/data
ports:
- 25432:5432
- 5432:5432

nbxplorer:
restart: unless-stopped
Expand Down
2 changes: 1 addition & 1 deletion src/Automapper/MapperProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public MapperProfile()
.ForMember(x => x.UserRequestor, opt => opt.Ignore())
.ForMember(x => x.UTXOs, opt => opt.Ignore());

CreateMap<UTXO, FMUTXO>()
CreateMap<UTXO, Data.Models.UTXO>()
.ForMember(x => x.TxId, opt => opt.MapFrom(x => x.Outpoint.Hash.ToString()))
.ForMember(x => x.OutputIndex, opt => opt.MapFrom(x => x.Outpoint.N))
.ForMember(x => x.SatsAmount, opt => opt.MapFrom(x => ((Money)x.Value).Satoshi));
Expand Down
2 changes: 1 addition & 1 deletion src/Data/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)

public DbSet<InternalWallet> InternalWallets { get; set; }

public DbSet<FMUTXO> FMUTXOs { get; set; }
public DbSet<UTXO> UTXOs { get; set; }

public DbSet<LiquidityRule> LiquidityRules { get; set; }

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 @@ -137,7 +137,7 @@ public decimal Amount

public bool IsChannelPrivate { get; set; }

public List<FMUTXO> Utxos { get; set; }
public List<UTXO> Utxos { get; set; }

#endregion Relationships

Expand Down
8 changes: 4 additions & 4 deletions src/Data/Models/FMUTXO.cs → src/Data/Models/UTXO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace NodeGuard.Data.Models
/// <summary>
/// UTXO entity in the NodeGuard
/// </summary>
public class FMUTXO : Entity, IEquatable<FMUTXO>
public class UTXO : Entity, IEquatable<UTXO>
{
public string TxId { get; set; }

Expand All @@ -48,7 +48,7 @@ public override bool Equals(object? obj)
return base.Equals(obj);
}

public bool Equals(FMUTXO? other)
public bool Equals(UTXO? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
Expand All @@ -60,12 +60,12 @@ public override int GetHashCode()
return HashCode.Combine(TxId, OutputIndex, SatsAmount);
}

public static bool operator ==(FMUTXO? left, FMUTXO? right)
public static bool operator ==(UTXO? left, UTXO? right)
{
return Equals(left, right);
}

public static bool operator !=(FMUTXO? left, FMUTXO? right)
public static bool operator !=(UTXO? left, UTXO? right)
{
return !Equals(left, right);
}
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 @@ -195,11 +195,11 @@
public ApplicationUser UserRequestor { get; set; }
public int WalletId { get; set; }

public Wallet Wallet { get; set; }

Check warning on line 198 in src/Data/Models/WalletWithdrawalRequest.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Nullability of reference types in type of parameter 'value' of 'void WalletWithdrawalRequest.Wallet.set' doesn't match implicitly implemented member 'void IBitcoinRequest.Wallet.set' (possibly because of nullability attributes).

public List<WalletWithdrawalRequestPSBT> WalletWithdrawalRequestPSBTs { get; set; }

public List<FMUTXO> UTXOs { get; set; }
public List<UTXO> UTXOs { get; set; }

#endregion Relationships

Expand Down
6 changes: 3 additions & 3 deletions src/Data/Repositories/ChannelOperationRequestRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public async Task<(bool, string?)> AddRangeAsync(List<ChannelOperationRequest> t
return _repository.Update(strippedType, applicationDbContext);
}

public async Task<(bool, string?)> AddUTXOs(IBitcoinRequest type, List<FMUTXO> utxos)
public async Task<(bool, string?)> AddUTXOs(IBitcoinRequest type, List<UTXO> utxos)
{
if (type == null) throw new ArgumentNullException(nameof(type));
if (utxos.Count == 0) throw new ArgumentException("Value cannot be an empty collection.", nameof(utxos));
Expand Down Expand Up @@ -197,11 +197,11 @@ public async Task<(bool, string?)> AddUTXOs(IBitcoinRequest type, List<FMUTXO> u
return result;
}

public async Task<(bool, List<FMUTXO>?)> GetUTXOs(IBitcoinRequest request)
public async Task<(bool, List<UTXO>?)> GetUTXOs(IBitcoinRequest request)
{
await using var applicationDbContext = await _dbContextFactory.CreateDbContextAsync();

(bool, List<FMUTXO>?) result = (true, null);
(bool, List<UTXO>?) result = (true, null);
try
{
var channelOperationRequest = await applicationDbContext.ChannelOperationRequests
Expand Down
28 changes: 14 additions & 14 deletions src/Data/Repositories/FUTXORepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@

namespace NodeGuard.Data.Repositories
{
public class FUTXORepository : IFMUTXORepository
public class FUTXORepository : IUTXORepository
{
private readonly IRepository<FMUTXO> _repository;
private readonly IRepository<UTXO> _repository;
private readonly ILogger<FUTXORepository> _logger;
private readonly IDbContextFactory<ApplicationDbContext> _dbContextFactory;

public FUTXORepository(IRepository<FMUTXO> repository,
public FUTXORepository(IRepository<UTXO> repository,
ILogger<FUTXORepository> logger,
IDbContextFactory<ApplicationDbContext> dbContextFactory)
{
Expand All @@ -38,19 +38,19 @@ public class FUTXORepository : IFMUTXORepository
_dbContextFactory = dbContextFactory;
}

public async Task<FMUTXO?> GetById(int id)
public async Task<UTXO?> GetById(int id)
{
await using var applicationDbContext = await _dbContextFactory.CreateDbContextAsync();

return await applicationDbContext.FMUTXOs.FirstOrDefaultAsync(x => x.Id == id);
return await applicationDbContext.UTXOs.FirstOrDefaultAsync(x => x.Id == id);
}

public async Task<List<FMUTXO>> GetAll()
public async Task<List<UTXO>> GetAll()
{
throw new NotImplementedException();
}

public async Task<(bool, string?)> AddAsync(FMUTXO type)
public async Task<(bool, string?)> AddAsync(UTXO type)
{
await using var applicationDbContext = await _dbContextFactory.CreateDbContextAsync();

Expand All @@ -59,28 +59,28 @@ public async Task<(bool, string?)> AddAsync(FMUTXO type)
return await _repository.AddAsync(type, applicationDbContext);
}

public async Task<(bool, string?)> AddRangeAsync(List<FMUTXO> type)
public async Task<(bool, string?)> AddRangeAsync(List<UTXO> type)
{
await using var applicationDbContext = await _dbContextFactory.CreateDbContextAsync();

return await _repository.AddRangeAsync(type, applicationDbContext);
}

public (bool, string?) Remove(FMUTXO type)
public (bool, string?) Remove(UTXO type)
{
using var applicationDbContext = _dbContextFactory.CreateDbContext();

return _repository.Remove(type, applicationDbContext);
}

public (bool, string?) RemoveRange(List<FMUTXO> types)
public (bool, string?) RemoveRange(List<UTXO> types)
{
using var applicationDbContext = _dbContextFactory.CreateDbContext();

return _repository.RemoveRange(types, applicationDbContext);
}

public (bool, string?) Update(FMUTXO type)
public (bool, string?) Update(UTXO type)
{
using var applicationDbContext = _dbContextFactory.CreateDbContext();

Expand All @@ -89,11 +89,11 @@ public async Task<(bool, string?)> AddRangeAsync(List<FMUTXO> type)
return _repository.Update(type, applicationDbContext);
}

public async Task<List<FMUTXO>> GetLockedUTXOs(int? ignoredWalletWithdrawalRequestId = null, int? ignoredChannelOperationRequestId = null)
public async Task<List<UTXO>> GetLockedUTXOs(int? ignoredWalletWithdrawalRequestId = null, int? ignoredChannelOperationRequestId = null)
{
await using var applicationDbContext = await _dbContextFactory.CreateDbContextAsync();

var walletWithdrawalRequestsLockedUTXOs = new List<FMUTXO>();
var walletWithdrawalRequestsLockedUTXOs = new List<UTXO>();
if (ignoredWalletWithdrawalRequestId == null)
{
walletWithdrawalRequestsLockedUTXOs = await applicationDbContext.WalletWithdrawalRequests
Expand All @@ -116,7 +116,7 @@ public async Task<List<FMUTXO>> GetLockedUTXOs(int? ignoredWalletWithdrawalReque
.SelectMany(x => x.UTXOs).ToListAsync();
}

var channelOperationRequestsLockedUTXOs = new List<FMUTXO>();
var channelOperationRequestsLockedUTXOs = new List<UTXO>();

if (ignoredChannelOperationRequestId == null)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Data/Repositories/Interfaces/IBitcoinRequestRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface IBitcoinRequestRepository
/// <param name="type"></param>
/// <param name="utxos"></param>
/// <returns></returns>
Task<(bool, string?)> AddUTXOs(IBitcoinRequest type, List<FMUTXO> utxos);
Task<(bool, string?)> AddUTXOs(IBitcoinRequest type, List<UTXO> utxos);

public Task<(bool, List<FMUTXO>?)> GetUTXOs(IBitcoinRequest type);
public Task<(bool, List<UTXO>?)> GetUTXOs(IBitcoinRequest type);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@

namespace NodeGuard.Data.Repositories.Interfaces;

public interface IFMUTXORepository
public interface IUTXORepository
{
Task<FMUTXO?> GetById(int id);
Task<UTXO?> GetById(int id);

Task<List<FMUTXO>> GetAll();
Task<List<UTXO>> GetAll();

Task<(bool, string?)> AddAsync(FMUTXO type);
Task<(bool, string?)> AddAsync(UTXO type);

Task<(bool, string?)> AddRangeAsync(List<FMUTXO> type);
Task<(bool, string?)> AddRangeAsync(List<UTXO> type);

(bool, string?) Remove(FMUTXO type);
(bool, string?) Remove(UTXO type);

(bool, string?) RemoveRange(List<FMUTXO> types);
(bool, string?) RemoveRange(List<UTXO> types);

(bool, string?) Update(FMUTXO type);
(bool, string?) Update(UTXO type);

/// <summary>
/// Gets the current list of UTXOs locked on requests ChannelOperationRequest / WalletWithdrawalRequest by passing its id if wants to remove it from the resulting set
/// </summary>
/// <returns></returns>
Task<List<FMUTXO>> GetLockedUTXOs(int? ignoredWalletWithdrawalRequestId = null, int? ignoredChannelOperationRequestId = null);
Task<List<UTXO>> GetLockedUTXOs(int? ignoredWalletWithdrawalRequestId = null, int? ignoredChannelOperationRequestId = null);
}
6 changes: 3 additions & 3 deletions src/Data/Repositories/WalletWithdrawalRequestRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public async Task<(bool, string?)> AddRangeAsync(List<WalletWithdrawalRequest> t
return _repository.Update(strippedType, applicationDbContext);
}

public async Task<(bool, string?)> AddUTXOs(IBitcoinRequest type, List<FMUTXO> utxos)
public async Task<(bool, string?)> AddUTXOs(IBitcoinRequest type, List<UTXO> utxos)
{
if (type == null) throw new ArgumentNullException(nameof(type));
if (utxos.Count == 0) throw new ArgumentException("Value cannot be an empty collection.", nameof(utxos));
Expand Down Expand Up @@ -233,11 +233,11 @@ public async Task<(bool, string?)> AddUTXOs(IBitcoinRequest type, List<FMUTXO> u
return result;
}

public async Task<(bool, List<FMUTXO>?)> GetUTXOs(IBitcoinRequest request)
public async Task<(bool, List<UTXO>?)> GetUTXOs(IBitcoinRequest request)
{
await using var applicationDbContext = await _dbContextFactory.CreateDbContextAsync();

(bool, List<FMUTXO>?) result = (true, null);
(bool, List<UTXO>?) result = (true, null);
try
{
var walletWithdrawalRequest = await applicationDbContext.WalletWithdrawalRequests
Expand Down
1 change: 1 addition & 0 deletions src/Helpers/LightningHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using NBitcoin;
using NBXplorer;
using NBXplorer.Models;
using UTXO = NBXplorer.Models.UTXO;

namespace NodeGuard.Helpers
{
Expand Down
Loading
Loading