Skip to content

Latest commit

 

History

History
89 lines (61 loc) · 2.84 KB

client-eclair.md

File metadata and controls

89 lines (61 loc) · 2.84 KB

Eclair Client

Introduction

Eclair Client is shipped with LightningPay package.

More info about Eclair (Github Project)

Create the client

Instantiate

string password = "yourPassword"; // Enter here your macaroon
using (var client = EclairClient.New("http://localhost:8080/", password))
{
	//Your code...
}

If you wants to use your own HttpClient to request the Eclair API, you can send it with the parameter "httpClient" of the method New() :

using (HttpClient httpClient = new HttpClient())
{
	var eclairClient = EclairClient.New("http://localhost:8080/", password, httpClient: httpClient);
    
	//Your code...
}

Sample

You can retrieve a code sample with Eclair Client here : Eclair Client Sample

Dependency Injection

LightningPay.DependencyInjection package adds extension method to create the Eclair Client with .NET Core Dependency Injection in your startup file :

public void ConfigureServices(IServiceCollection services)
{
	///...

	string password = "yourPassword"; 
	services.AddEclairLightningClient(new Uri("http://localhost:8080/"), password);
}

Options

The AddEclairLightningClient method has optionnal pamameters to configure your client :

Parameter name Type Required Description
address Uri Yes Address of your node server with port (example : http://localhost:8080/)
password String No Eclair api password
retryOnHttpError int No Number of retry on http error
certificateThumbprint String No Certificate thumbprint used for your https address if the certificate is not public
Ex : "284800A04D0C046636EBE60C37A4F527B8B550F3"
allowInsecure bool No If you use https address, determine if you allow non secure transport (certificateThumbprint parameter will be ignored)

Use to the LightningPay Client

Once you register LightningPay, you can use the client in any object by dependency injection in constructor :

private readonly ILightningClient lightningClient;

public HomeController(ILightningClient lightningClient)
{
        this.lightningClient = lightningClient;
}

Sample

You can retrieve a code samples used Dependency Injection in the Visual Studio Solution WebApp.sln

public void ConfigureServices(IServiceCollection services)
{
	//...

	services.AddEclairLightningClient(new Uri("http://localhost:8080/"), 
		password: "YourPassword");
}