Skip to content

Commit

Permalink
bump net 8, bump lib, add channel request actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Kukks committed Nov 29, 2024
1 parent 5b9c97b commit 9649f24
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 10 deletions.
14 changes: 7 additions & 7 deletions LNURL.Tests/LNURL.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="NBitcoin" Version="7.0.30" />
<PackageReference Include="NBitcoin.Altcoins" Version="3.0.20" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NBitcoin" Version="7.0.46" />
<PackageReference Include="NBitcoin.Altcoins" Version="3.0.31" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.0.2">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
6 changes: 3 additions & 3 deletions LNURL/LNURL.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Authors>Andrew Camilleri (kukks)</Authors>
<Copyright>MIT</Copyright>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Description>LNURL protocol implementation in .NET Core</Description>
<PackageTags>bitcoin lightning lnurl</PackageTags>
<PackageVersion>0.0.35</PackageVersion>
<PackageVersion>0.0.36</PackageVersion>
<RepositoryUrl>https://github.com/Kukks/LNURL.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand All @@ -16,7 +16,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.9"/>
<PackageReference Include="BTCPayServer.Lightning.Common" Version="1.3.21"/>
<PackageReference Include="BTCPayServer.Lightning.Common" Version="1.5.1"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
</ItemGroup>

Expand Down
36 changes: 36 additions & 0 deletions LNURL/LNURLChannelRequest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using BTCPayServer.Lightning;
using LNURL.JsonConverters;
using NBitcoin;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace LNURL;

Expand All @@ -21,4 +26,35 @@ public class LNURLChannelRequest
[JsonProperty("k1")] public string K1 { get; set; }

[JsonProperty("tag")] public string Tag { get; set; }


public async Task SendRequest(PubKey ourId, bool privateChannel, HttpClient httpClient,
CancellationToken cancellationToken = default)
{
var url = Callback;
var uriBuilder = new UriBuilder(url);
LNURL.AppendPayloadToQuery(uriBuilder, "k1", K1);
LNURL.AppendPayloadToQuery(uriBuilder, "remoteid", ourId.ToString());
LNURL.AppendPayloadToQuery(uriBuilder, "private",privateChannel? "1":"0");

url = new Uri(uriBuilder.ToString());
var response = await httpClient.GetAsync(url, cancellationToken);
var json = JObject.Parse(await response.Content.ReadAsStringAsync(cancellationToken));
if (LNUrlStatusResponse.IsErrorResponse(json, out var error)) throw new LNUrlException(error.Reason);

}

public async Task CancelRequest(PubKey ourId, HttpClient httpClient, CancellationToken cancellationToken = default)
{
var url = Callback;
var uriBuilder = new UriBuilder(url);
LNURL.AppendPayloadToQuery(uriBuilder, "k1", K1);
LNURL.AppendPayloadToQuery(uriBuilder, "remoteid", ourId.ToString());
LNURL.AppendPayloadToQuery(uriBuilder, "cancel", "1");

url = new Uri(uriBuilder.ToString());
var response = await httpClient.GetAsync(url, cancellationToken);
var json = JObject.Parse(await response.Content.ReadAsStringAsync(cancellationToken));
if (LNUrlStatusResponse.IsErrorResponse(json, out var error)) throw new LNUrlException(error.Reason);
}
}

0 comments on commit 9649f24

Please sign in to comment.