Skip to content

Commit

Permalink
Fix build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisreimann committed Jan 20, 2025
1 parent 4287d3b commit 4a3deb6
Show file tree
Hide file tree
Showing 24 changed files with 255 additions and 238 deletions.
5 changes: 4 additions & 1 deletion BTCPayApp.Core/BTCPayServer/BTCPayAppServerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ public async Task<PayResponse> PayInvoice(string key, string bolt11, long? amoun
if (PaymentsManager is null) throw new HubException("Payments Manager not available");

var config = await _serviceProvider.GetRequiredService<OnChainWalletManager>().GetConfig();
var bolt = BOLT11PaymentRequest.Parse(bolt11, config.NBitcoinNetwork);
var network = config?.NBitcoinNetwork;
if (network is null) throw new HubException("Network info not available");

var bolt = BOLT11PaymentRequest.Parse(bolt11, network);
try
{
var result = await PaymentsManager.PayInvoice(bolt,
Expand Down
8 changes: 4 additions & 4 deletions BTCPayApp.Core/BTCPayServer/BTCPayConnectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private set
if (_connectionState == value) return;
var old = _connectionState;
_connectionState = value;
_logger.LogInformation($"Connection state changed: {_connectionState} from {old}" );
_logger.LogInformation("Connection state changed: {Old} -> {ConnectionState}", old, _connectionState);
ConnectionChanged?.Invoke(this, (old, _connectionState));
}
finally
Expand Down Expand Up @@ -234,7 +234,7 @@ private async Task OnConnectionChanged(object? sender, (BTCPayConnectionState Ol
else
{
//check if we are the master previously to process outbox items
var masterDevice = await HubProxy.GetCurrentMaster();
var masterDevice = await HubProxy!.GetCurrentMaster();
if (deviceIdentifier == masterDevice)
{
await _syncService.SyncToRemote(CancellationToken.None);
Expand All @@ -249,11 +249,11 @@ private async Task OnConnectionChanged(object? sender, (BTCPayConnectionState Ol
case BTCPayConnectionState.ConnectedFinishedInitialSync:
if (ForceSlaveMode)
{
await HubProxy.DeviceMasterSignal(deviceIdentifier, false);
await HubProxy!.DeviceMasterSignal(deviceIdentifier, false);
ForceSlaveMode = false;
newState = BTCPayConnectionState.ConnectedAsSlave;
}
else if (!await HubProxy.DeviceMasterSignal(deviceIdentifier, true))
else if (!await HubProxy!.DeviceMasterSignal(deviceIdentifier, true))
{
newState = BTCPayConnectionState.ConnectedAsSlave;
}
Expand Down
27 changes: 7 additions & 20 deletions BTCPayApp.Core/BTCPayServer/IBTCPayAppHubClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using BTCPayServer.Client.Models;
using BTCPayServer.Client.Models;
using BTCPayServer.Lightning;
using NBitcoin;

Expand Down Expand Up @@ -30,7 +30,6 @@ public interface IBTCPayAppHubClient
public interface IBTCPayAppHubServer
{
Task<bool> DeviceMasterSignal(long deviceIdentifier, bool active);

Task<Dictionary<string,string>> Pair(PairRequest request);
Task<AppHandshakeResponse> Handshake(AppHandshake request);
Task<bool> BroadcastTransaction(string tx);
Expand All @@ -48,7 +47,7 @@ public interface IBTCPayAppHubServer

public class ServerEvent
{
public string? Type { get; set; }
public string Type { get; set; } = null!;
public string? StoreId { get; set; }
public string? UserId { get; set; }
public string? AppId { get; set; }
Expand All @@ -58,20 +57,11 @@ public class ServerEvent

public record TxResp
{
public TxResp(long confirmations, long? height, decimal balanceChange, DateTimeOffset timestamp, string transactionId)
{
Confirmations = confirmations;
Height = height;
BalanceChange = balanceChange;
Timestamp = timestamp;
TransactionId = transactionId;
}

public string TransactionId { get; set; } = null!;
public long Confirmations { get; set; }
public long? Height { get; set; }
public decimal BalanceChange { get; set; }
public DateTimeOffset Timestamp { get; set; }
public string TransactionId { get; set; }

public override string ToString()
{
Expand Down Expand Up @@ -101,7 +91,7 @@ public class TxInfoResponse
{
public Dictionary<string,TransactionResponse>? Txs { get; set; }
public Dictionary<string,string>? BlockHeaders { get; set; }
public Dictionary<string,int>? BlockHeghts { get; set; }
public Dictionary<string,int>? BlockHeights { get; set; }
}

public class TransactionResponse
Expand All @@ -119,18 +109,18 @@ public class BestBlockResponse

public class ScriptResponse
{
public string Script { get; set; }
public string KeyPath { get; set; }
public string Script { get; set; } = null!;
public string KeyPath { get; set; } = null!;
}

public class AppHandshake
{
public string[]? Identifiers { get; set; }
}

//response about identifiers being tracked successfully
public class AppHandshakeResponse
{
//response about identifiers being tracked successfully
public string[]? IdentifiersAcknowledged { get; set; }
}

Expand All @@ -143,8 +133,5 @@ public class DerivationItem
{
public string? Descriptor { get; set; }
public int Index { get; set; }

public OutPoint[] KnownCoins { get; set; } = [];


}
22 changes: 11 additions & 11 deletions BTCPayApp.Core/Data/AppDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.Condition(@ref => @ref.New.Backup)
.Insert(
// .InsertIfNotExists( (@ref, outbox) => outbox.Version == @ref.New.Version && outbox.ActionType == OutboxAction.Insert && outbox.Entity == "Setting" && outbox.Key == @ref.New.Key,
@ref => new Outbox()
@ref => new Outbox
{
Entity = "Setting",
Version = @ref.New.Version,
Expand All @@ -88,7 +88,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.Condition(@ref => @ref.Old.Backup)
.Insert(
// .InsertIfNotExists( (@ref, outbox) => @ref.Old.Version == outbox.Version && outbox.ActionType == OutboxAction.Delete && outbox.Entity == "Setting" && outbox.Key == @ref.Old.Key,
@ref => new Outbox()
@ref => new Outbox
{
Entity = "Setting",
Version = @ref.Old.Version,
Expand All @@ -101,10 +101,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
// .Condition(@ref => @ref.Old.Value != @ref.New.Value)
.Update<Setting>(
(tableRefs, setting) => tableRefs.Old.Key == setting.Key,
(tableRefs, setting) => new Setting() {Version = tableRefs.Old.Version + 1})
(tableRefs, setting) => new Setting { Version = tableRefs.Old.Version + 1 })
.Insert(
// .InsertIfNotExists( (@ref, outbox) => @ref.New.Version == outbox.Version && outbox.ActionType == OutboxAction.Update && outbox.Entity == "Setting" && outbox.Key == @ref.New.Key,
@ref => new Outbox()
@ref => new Outbox
{
Entity = "Setting",
Version = @ref.Old.Version + 1,
Expand All @@ -128,7 +128,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.Action(group => group
.Insert(
// .InsertIfNotExists( (@ref, outbox) => outbox.Version == @ref.New.Version && outbox.ActionType == OutboxAction.Insert && outbox.Entity == "Channel" && outbox.Key == @ref.New.Id,
@ref => new Outbox()
@ref => new Outbox
{
Entity = "Channel",
Version = @ref.New.Version,
Expand All @@ -139,7 +139,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.Action(group => group
.Insert(
// .InsertIfNotExists( (@ref, outbox) => @ref.Old.Version == outbox.Version && outbox.ActionType == OutboxAction.Delete && outbox.Entity == "Channel" && outbox.Key == @ref.Old.Id,
@ref => new Outbox()
@ref => new Outbox
{
Entity = "Channel",
Version = @ref.Old.Version,
Expand All @@ -149,9 +149,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.AfterUpdate(trigger => trigger
.Action(group => group.Update<Channel>(
(tableRefs, setting) => tableRefs.Old.Id == setting.Id,
(tableRefs, setting) => new Channel() {Version = tableRefs.Old.Version + 1}).Insert(
(tableRefs, setting) => new Channel { Id = tableRefs.Old.Id, Version = tableRefs.Old.Version + 1 }).Insert(
// .InsertIfNotExists( (@ref, outbox) => @ref.New.Version == outbox.Version && outbox.ActionType == OutboxAction.Update && outbox.Entity == "Channel" && outbox.Key == @ref.New.Id,
@ref => new Outbox()
@ref => new Outbox
{
Entity = "Channel",
Version = @ref.Old.Version +1,
Expand All @@ -164,7 +164,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.Action(group => group
.Insert(
// .InsertIfNotExists( (@ref, outbox) => outbox.Version == @ref.New.Version && outbox.ActionType == OutboxAction.Insert && outbox.Entity == "Payment" && outbox.Key == @ref.New.PaymentHash+ "_"[email protected]+ "_"[email protected],
@ref => new Outbox()
@ref => new Outbox
{
Entity = "Payment",
Version = @ref.New.Version,
Expand All @@ -175,7 +175,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.Action(group => group
.Insert(
// .InsertIfNotExists( (@ref, outbox) => @ref.Old.Version == outbox.Version && outbox.ActionType == OutboxAction.Delete && outbox.Entity == "Payment" && outbox.Key == @ref.Old.PaymentHash+ "_"[email protected]+ "_"[email protected],
@ref => new Outbox()
@ref => new Outbox
{
Entity = "Payment",
Version = @ref.Old.Version,
Expand All @@ -190,7 +190,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
(tableRefs, setting) => new AppLightningPayment {Version = tableRefs.Old.Version + 1}).Insert(
// .InsertIfNotExists( (@ref, outbox) =>
// outbox.Version != @ref.New.Version || outbox.ActionType != OutboxAction.Update || outbox.Entity != "Payment" || outbox.Key != @ref.New.PaymentHash+ "_"[email protected]+ "_"[email protected],
@ref => new Outbox()
@ref => new Outbox
{
Entity = "Payment",
Version = @ref.Old.Version +1,
Expand Down
8 changes: 3 additions & 5 deletions BTCPayApp.Core/Data/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ namespace BTCPayApp.Core.Data;

public class Channel:VersionedData
{
public string Id { get; set; }
public required string Id { get; init; }
public byte[] Data { get; set; }

Check warning on line 9 in BTCPayApp.Core/Data/Channel.cs

View workflow job for this annotation

GitHub Actions / test-desktop

Non-nullable property 'Data' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
public List<ChannelAlias> Aliases { get; set; }

Check warning on line 10 in BTCPayApp.Core/Data/Channel.cs

View workflow job for this annotation

GitHub Actions / test-desktop

Non-nullable property 'Aliases' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
public long Checkpoint { get; set; }
public bool Archived { get; set; }



[JsonExtensionData] public Dictionary<string, JsonElement> AdditionalData { get; set; } = new();

Expand All @@ -24,8 +22,8 @@ public override string EntityKey

public class ChannelAlias
{
public string Id { get; set; }
public string Type { get; set; }
public required string Id { get; init; }
public required string Type { get; init; }
public string ChannelId { get; set; }

Check warning on line 27 in BTCPayApp.Core/Data/Channel.cs

View workflow job for this annotation

GitHub Actions / test-desktop

Non-nullable property 'ChannelId' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
[JsonIgnore]
public Channel Channel { get; set; }

Check warning on line 29 in BTCPayApp.Core/Data/Channel.cs

View workflow job for this annotation

GitHub Actions / test-desktop

Non-nullable property 'Channel' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
Expand Down
8 changes: 4 additions & 4 deletions BTCPayApp.Core/Data/WalletDerivation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ namespace BTCPayApp.Core.Data;

public class WalletDerivation
{
public required string Name { get; set; }
public string? Identifier { get; set; }
public string? Descriptor { get; set; }

public const string NativeSegwit = "segwit";
public const string LightningScripts = "lightningScripts";
// public const string SpendableOutputs = "spendableOutputs";

public required string Name { get; set; }
public string? Identifier { get; set; }
public string? Descriptor { get; set; }

// TODO: this is useful when restoring, to tell NBX to generate addresses up to this to prevent address reuse.
public int? LastKnownIndex{ get; set; }
}
8 changes: 4 additions & 4 deletions BTCPayApp.Core/LDK/LDKChannelSync.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using BTCPayApp.Core.BTCPayServer;
using BTCPayApp.Core.BTCPayServer;
using BTCPayApp.Core.Helpers;
using BTCPayApp.Core.Wallet;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -47,7 +47,7 @@ public LDKChannelSync(
}

/// <summary>
///
///
/// </summary>
/// <param name="txIds">The specific transaction ids we should check the status of. If null, we get a list of transaction ids from LDK, and also a list of utxos that we are watching </param>
private async Task PollForTransactionUpdates(uint256[]? txIds = null)
Expand Down Expand Up @@ -156,7 +156,7 @@ private async Task PollForTransactionUpdates(uint256[]? txIds = null)
foreach (var block in blockToTxList)
{
var header = blockHeaders[block.Key];
var height = result.BlockHeghts[block.Key.ToString()];
var height = result.BlockHeights[block.Key.ToString()];
var headerBytes = header.ToBytes();
// if(block.Key.ToString() == "00000000000000086130942075335f4937cd89cb183d69cce612eb780c838f7c")
// continue;
Expand Down Expand Up @@ -233,4 +233,4 @@ public void Dispose()
{
_disposables.Dispose();
}
}
}
Loading

0 comments on commit 4a3deb6

Please sign in to comment.