VOOZH about

URL: https://www.nuget.org/packages/BTCPayServer.Lightning.LNDhub

⇱ NuGet Gallery | BTCPayServer.Lightning.LNDhub 1.7.0




BTCPayServer.Lightning.LNDhub 1.7.0

dotnet add package BTCPayServer.Lightning.LNDhub --version 1.7.0
 
 
NuGet\Install-Package BTCPayServer.Lightning.LNDhub -Version 1.7.0
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BTCPayServer.Lightning.LNDhub" Version="1.7.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BTCPayServer.Lightning.LNDhub" Version="1.7.0" />
 
Directory.Packages.props
<PackageReference Include="BTCPayServer.Lightning.LNDhub" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BTCPayServer.Lightning.LNDhub --version 1.7.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: BTCPayServer.Lightning.LNDhub, 1.7.0"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BTCPayServer.Lightning.LNDhub@1.7.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BTCPayServer.Lightning.LNDhub&version=1.7.0
 
Install as a Cake Addin
#tool nuget:?package=BTCPayServer.Lightning.LNDhub&version=1.7.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

👁 CircleCI

A C# library for Lightning Network clients

Introduction

This library is meant to facilitate the development of Lightning Network based apps written in C#. Its main goal isn't to perfectly implement client API of all lightning node implementation, but to provide a common abstraction that can be used to support many implementations at once.

The most important packages are:

  • BTCPayServer.Lightning.Common contains the common abstractions shared between those implementation.
  • BTCPayServer.Lightning.All contains LightningClientFactory which can convert a connection string to an instance of ILightningClient.

If your app depends on ILightningClient directly, you will be able to support those different lightning implementations out of the box.

Here is a description of all packages:

  • BTCPayServer.Lightning.All super package which reference all the others 👁 NuGet
  • BTCPayServer.Lightning.Common exposes common classes and ILightningClient 👁 NuGet
  • BTCPayServer.Lightning.LND exposes easy to use LND clients 👁 NuGet
  • BTCPayServer.Lightning.CLightning exposes easy to use clightning clients 👁 NuGet
  • BTCPayServer.Lightning.Charge exposes easy to use Charge clients 👁 NuGet
  • BTCPayServer.Lightning.Eclair exposes easy to use Eclair clients 👁 NuGet
  • BTCPayServer.Lightning.LNbank exposes easy to use LNbank clients 👁 NuGet
  • BTCPayServer.Lightning.LNDhub exposes easy to use LNDhub clients 👁 NuGet

If you develop an app, we advise you to reference BTCPayServer.Lightning.All 👁 NuGet
.

If you develop a library, we advise you to reference BTCPayServer.Lightning.Common 👁 NuGet
.

You can also use our BOLT11PaymentRequest to parse BOLT11 invoices. (See example).

How to use

Click on the nuget button of the package interesting you, and follow the instruction to add it to your project. For .NET Core Apps, you need to enter this in your project's folder:

dotnet add package BTCPayServer.Lightning.All

You have two ways to use this library:

  • Either you want your code to works with all lightning implementation (right now LND, Charge, CLightning)
  • Or you want your code to work on a particular lightning implementation

Using the generic interface

This is done by using LightningClientFactory and the common interface ILightningClient.

string connectionString = "...";
ILightningClientFactory factory = new LightningClientFactory(Network.Main);
ILightningClient client = factory.Create(connectionString);
LightningInvoice invoice = await client.CreateInvoice(10000, "CanCreateInvoice", TimeSpan.FromMinutes(5));

ILightningClient is an interface which abstract the underlying implementation with a common interface.

The connectionString encapsulates the necessary information BTCPay needs to connect to your Lightning node, we currently support:

  • clightning via TCP or unix domain socket connection
  • lightning charge via HTTPS
  • LND via the REST proxy
  • Eclair via their new REST API
  • LNbank via REST API
  • LNDhub via their REST API
Examples
  • type=clightning;server=unix://root/.lightning/lightning-rpc
  • type=clightning;server=tcp://1.1.1.1:27743/
  • type=lnd-rest;server=http://mylnd:8080/;macaroonfilepath=/root/.lnd/invoice.macaroon;allowinsecure=true
  • type=lnd-rest;server=https://mylnd:8080/;macaroon=abef263adfe...
  • type=lnd-rest;server=https://mylnd:8080/;macaroon=abef263adfe...;certthumbprint=abef263adfe...
  • type=lnd-rest;server=https://mylnd:8080/;macaroonfilepath=/root/.lnd/invoice.macaroon;certfilepath=/var/lib/lnd/tls.cert
  • type=charge;server=https://charge:8080/;api-token=myapitoken...
  • type=charge;server=https://charge:8080/;cookiefilepath=/path/to/cookie...
  • type=eclair;server=http://127.0.0.1:4570;password=eclairpass
  • type=eclair;server=http://127.0.0.1:4570;password=eclairpass;bitcoin-host=bitcoin.host;bitcoin-auth=btcpass
  • type=lnbank;server=http://lnbank:5000;api-token=myapitoken;allowinsecure=true
  • type=lnbank;server=https://mybtcpay.com/lnbank;api-token=myapitoken
  • type=lndhub;server=https://login:password@lndhub.io
Eclair notes

Note that bitcoin-host and bitcoin-auth are optional, only useful if you want to call ILightningClient.GetDepositAddress on Eclair. We expect this won't be needed in the future.

LND notes

Unless the LND certificate is trusted by your machine you need to set the server authentication scheme for LND by specifying one of: certthumbprint, certfilepath, allowinsecure=true.

certfilepath and certthumbprint are equivalent in terms of security but differ in their practical usage. certfilepath reads a file on your file system so unless you set up some kind of file syncing you can not use it for remote connections. The advantage is that if the certificate is updated (and synced in case of a remote machine) no more reconfiguration is required for RPC connections to continue to work. It is therefore the recommended option if you can use it.

The certthumbprint to connect to your LND node can be obtained through this command line:

openssl x509 -noout -fingerprint -sha256 -in /root/.lnd/tls.cert | sed -e 's/.*=//;s/://g'

allowinsecure=true just blindly accepts any server connection and is therefore not secure unless used in tightly controlled environments. E.g. host is the same machine or is accessed over an encrypted tunnel, assuming no untrusted entities can bind the specified port.

LNDhub notes

You can also use the lndhub:// URL, which can be retrieved e.g. from the BlueWallet Export/Backup screen. The library turns it into the expected type=lndhub connection string format.

Using implementation specific class

If you want to leverage specific lightning network implementation, either instanciate directly ChargeClient, LndClient or CLightningClient, or cast the ILightningClient object returned by LightningClientFactory.

How to test

You first need to run all the dependencies with docker-compose:

cd tests
docker-compose up

Then you can run and debug the tests with Visual Studio or Visual Studio Code.

If you want to use command line:

cd tests
dotnet test

Licence

Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 was computed. 
.NET Framework net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.7.0 466 6/9/2026
1.5.4 3,167 4/20/2026
1.5.3 24,616 11/30/2024
1.5.2 19,695 12/4/2023
1.5.1 878 11/21/2023
1.5.0 336 10/19/2023
1.0.21 4,982 8/16/2023
1.0.20 3,942 6/19/2023
1.0.19 9,898 2/21/2023
1.0.18 1,649 2/8/2023
1.0.17 812 2/2/2023
1.0.16 2,313 1/10/2023
1.0.15 1,012 1/6/2023
1.0.14 1,248 12/23/2022
1.0.13 774 12/22/2022
1.0.12 1,104 12/7/2022
1.0.11 1,396 12/5/2022
1.0.10 2,781 10/31/2022
1.0.9 1,034 10/26/2022
1.0.8 1,098 10/17/2022
Loading failed