Coder Social home page Coder Social logo

proof-of-reality / btcpayserver.lightning Goto Github PK

View Code? Open in Web Editor NEW

This project forked from btcpayserver/btcpayserver.lightning

0.0 0.0 0.0 583 KB

Client library for lightning network implementations to build Lightning Network Apps in C#.

License: MIT License

C# 99.45% PowerShell 0.49% Dockerfile 0.05% Shell 0.01%

btcpayserver.lightning's Introduction

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#. It is composed of 4 packages.

  • BTCPayServer.Lightning.All super package which reference all the others 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.Ptarmigan exposes easy to use Ptarmigan clients NuGet
  • BTCPayServer.Lightning.Common exposes common classes and ILightningClient 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

Examples

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.

Note that the certthumbprint to connect to your LND node can be obtained through this command line:

openssl x509 -noout -fingerprint -sha256 -inform pem -in /root/.lnd/tls.cert

You can omit certthumprint if you the certificate is trusted by your machine

You can set allowinsecure to true if your LND REST server is using HTTP or HTTPS with an untrusted certificate which you don't know the certthumprint.

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

MIT

btcpayserver.lightning's People

Contributors

nicolasdorier avatar kukks avatar rockstardev avatar joemphilips avatar araspitzu avatar bjarnemagnussen avatar dennisreimann avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.