BTCPayServer.Lightning.All
1.6.2
See the version list below for details.
dotnet add package BTCPayServer.Lightning.All --version 1.6.2
NuGet\Install-Package BTCPayServer.Lightning.All -Version 1.6.2
<PackageReference Include="BTCPayServer.Lightning.All" Version="1.6.2" />
paket add BTCPayServer.Lightning.All --version 1.6.2
#r "nuget: BTCPayServer.Lightning.All, 1.6.2"
// Install BTCPayServer.Lightning.All as a Cake Addin #addin nuget:?package=BTCPayServer.Lightning.All&version=1.6.2 // Install BTCPayServer.Lightning.All as a Cake Tool #tool nuget:?package=BTCPayServer.Lightning.All&version=1.6.2
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
containsLightningClientFactory
which can convert a connection string to an instance ofILightningClient
.
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 othersBTCPayServer.Lightning.Common
exposes common classes andILightningClient
BTCPayServer.Lightning.LND
exposes easy to use LND clientsBTCPayServer.Lightning.CLightning
exposes easy to use clightning clientsBTCPayServer.Lightning.Charge
exposes easy to use Charge clientsBTCPayServer.Lightning.Eclair
exposes easy to use Eclair clientsBTCPayServer.Lightning.LNbank
exposes easy to use LNbank clientsBTCPayServer.Lightning.LNDhub
exposes easy to use LNDhub clients
If you develop an app, we advise you to reference BTCPayServer.Lightning.All
.
If you develop a library, we advise you to reference BTCPayServer.Lightning.Common
.
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 connectionlightning charge
via HTTPSLND
via the REST proxyEclair
via their new REST APILNbank
via REST APILNDhub
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 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- BTCPayServer.Lightning.Charge (>= 1.5.1)
- BTCPayServer.Lightning.CLightning (>= 1.6.2)
- BTCPayServer.Lightning.Eclair (>= 1.5.2)
- BTCPayServer.Lightning.LNBank (>= 1.5.2)
- BTCPayServer.Lightning.LND (>= 1.5.4)
- BTCPayServer.Lightning.LNDhub (>= 1.5.2)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
-
net6.0
- BTCPayServer.Lightning.Charge (>= 1.5.1)
- BTCPayServer.Lightning.CLightning (>= 1.6.2)
- BTCPayServer.Lightning.Eclair (>= 1.5.2)
- BTCPayServer.Lightning.LNBank (>= 1.5.2)
- BTCPayServer.Lightning.LND (>= 1.5.4)
- BTCPayServer.Lightning.LNDhub (>= 1.5.2)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on BTCPayServer.Lightning.All:
Package | Downloads |
---|---|
LNTestFramework
Testing Framework for Bitcoin Lightning Network |
|
NostrSharp
A library that provide a set of tools for Nostr developement |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on BTCPayServer.Lightning.All:
Repository | Stars |
---|---|
btcpayserver/btcpayserver
Accept Bitcoin payments. Free, open-source & self-hosted, Bitcoin payment processor.
|
Version | Downloads | Last updated |
---|---|---|
1.6.7 | 693 | 11/13/2024 |
1.6.6 | 1,067 | 10/25/2024 |
1.6.5 | 170 | 10/22/2024 |
1.6.3 | 184 | 10/20/2024 |
1.6.2 | 106 | 10/20/2024 |
1.6.1 | 223 | 10/18/2024 |
1.6.0 | 6,748 | 4/10/2024 |
1.5.5 | 304 | 2/23/2024 |
1.5.4 | 3,325 | 2/1/2024 |
1.5.3 | 1,908 | 12/20/2023 |
1.5.2 | 775 | 12/4/2023 |
1.5.1 | 615 | 11/21/2023 |
1.5.0 | 194 | 10/19/2023 |
1.4.31 | 4,243 | 8/24/2023 |
1.4.30 | 164 | 8/16/2023 |
1.4.29 | 1,305 | 7/24/2023 |
1.4.28 | 1,943 | 6/21/2023 |
1.4.27 | 273 | 6/19/2023 |
1.4.26 | 993 | 5/30/2023 |
1.4.25 | 328 | 5/25/2023 |
1.4.24 | 597 | 5/12/2023 |
1.4.23 | 2,847 | 4/24/2023 |
1.4.22 | 938 | 4/6/2023 |
1.4.21 | 3,452 | 2/21/2023 |
1.4.20 | 1,188 | 2/8/2023 |
1.4.19 | 485 | 2/2/2023 |
1.4.18 | 1,485 | 1/11/2023 |
1.4.17 | 343 | 1/10/2023 |
1.4.16 | 581 | 1/6/2023 |
1.4.15 | 375 | 1/5/2023 |
1.4.14 | 729 | 12/23/2022 |
1.4.13 | 421 | 12/22/2022 |
1.4.12 | 727 | 12/7/2022 |
1.4.11 | 696 | 12/6/2022 |
1.4.10 | 420 | 12/5/2022 |
1.4.9 | 880 | 11/26/2022 |
1.4.8 | 1,525 | 10/31/2022 |
1.4.7 | 556 | 10/26/2022 |
1.4.6 | 631 | 10/17/2022 |
1.4.5 | 1,240 | 9/26/2022 |
1.4.4 | 843 | 9/15/2022 |
1.4.3 | 572 | 9/9/2022 |
1.4.2 | 459 | 9/9/2022 |
1.4.1 | 464 | 8/23/2022 |
1.3.13 | 1,351 | 8/9/2022 |
1.3.12 | 3,550 | 7/8/2022 |
1.3.11 | 1,244 | 6/21/2022 |
1.3.10 | 5,125 | 6/8/2022 |
1.3.9 | 517 | 6/2/2022 |
1.3.8 | 1,753 | 5/19/2022 |
1.3.7 | 621 | 5/14/2022 |
1.3.6 | 1,447 | 4/28/2022 |
1.3.5 | 792 | 4/21/2022 |
1.3.4 | 859 | 4/3/2022 |
1.3.3 | 1,556 | 3/4/2022 |
1.3.2 | 1,210 | 2/16/2022 |
1.3.1 | 458 | 2/16/2022 |
1.3.0 | 612 | 2/14/2022 |
1.2.21 | 484 | 2/13/2022 |
1.2.20 | 528 | 2/10/2022 |
1.2.19 | 3,101 | 1/13/2022 |
1.2.18 | 352 | 12/27/2021 |
1.2.17 | 3,065 | 11/26/2021 |
1.2.16 | 2,022 | 11/20/2021 |
1.2.15 | 1,272 | 11/20/2021 |
1.2.14 | 1,046 | 11/4/2021 |
1.2.13 | 1,261 | 10/21/2021 |
1.2.12 | 3,208 | 8/25/2021 |
1.2.11 | 412 | 8/18/2021 |
1.2.10 | 816 | 8/10/2021 |
1.2.9 | 921 | 7/29/2021 |
1.2.8 | 623 | 7/15/2021 |
1.2.7 | 33,076 | 1/27/2021 |
1.2.6 | 524 | 12/25/2020 |
1.2.5 | 541 | 8/27/2020 |
1.2.4 | 6,554 | 8/17/2020 |
1.2.3 | 819 | 8/16/2020 |
1.2.2 | 648 | 7/31/2020 |
1.2.1 | 583 | 6/9/2020 |
1.2.0 | 3,400 | 6/8/2020 |
1.1.15 | 1,508 | 5/19/2020 |
1.1.14 | 563 | 5/19/2020 |
1.1.13 | 17,662 | 4/26/2020 |
1.1.12 | 565 | 4/26/2020 |
1.1.11 | 596 | 4/26/2020 |
1.1.10 | 547 | 4/26/2020 |
1.1.9 | 3,999 | 3/10/2020 |
1.1.8 | 3,940 | 1/12/2020 |
1.1.7 | 966 | 12/27/2019 |
1.1.6 | 640 | 12/27/2019 |
1.1.5 | 2,383 | 11/5/2019 |
1.1.4 | 583 | 11/5/2019 |
1.1.3 | 690 | 11/2/2019 |
1.1.2 | 614 | 11/1/2019 |
1.1.1 | 1,853 | 8/17/2019 |
1.1.0.23 | 975 | 7/13/2019 |
1.1.0.22 | 746 | 7/4/2019 |
1.1.0.21 | 595 | 7/1/2019 |
1.1.0.20 | 639 | 6/21/2019 |
1.1.0.19 | 1,188 | 5/16/2019 |
1.1.0.18 | 1,045 | 5/7/2019 |
1.1.0.17 | 696 | 4/17/2019 |
1.1.0.16 | 1,047 | 4/10/2019 |
1.1.0.15 | 822 | 3/25/2019 |
1.1.0.14 | 789 | 3/17/2019 |
1.1.0.13 | 714 | 3/14/2019 |
1.1.0.12 | 688 | 3/14/2019 |
1.1.0.11 | 817 | 3/7/2019 |
1.1.0.10 | 785 | 3/2/2019 |
1.1.0.9 | 875 | 2/22/2019 |
1.1.0.8 | 763 | 2/20/2019 |
1.1.0.7 | 772 | 2/18/2019 |
1.1.0.6 | 719 | 2/17/2019 |
1.1.0.5 | 5,595 | 1/22/2019 |
1.1.0.4 | 1,510 | 12/19/2018 |
1.1.0.3 | 1,082 | 12/9/2018 |
1.1.0.2 | 1,245 | 11/6/2018 |
1.1.0.1 | 1,606 | 9/28/2018 |
1.1.0 | 1,060 | 9/9/2018 |
1.0.0.4 | 904 | 8/30/2018 |
1.0.0.3 | 818 | 8/30/2018 |
1.0.0.2 | 893 | 8/30/2018 |
1.0.0.1 | 852 | 8/30/2018 |
1.0.0 | 858 | 8/29/2018 |