-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathCLightningClientSample.cs
36 lines (29 loc) · 1.34 KB
/
CLightningClientSample.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Threading.Tasks;
using LightningPay.Clients.CLightning;
namespace LightningPay.Samples.Console
{
class CLightningClientSample : SampleBase
{
public async override Task Execute()
{
using (CLightningClient client = CLightningClient.New("tcp://127.0.0.1:48532"))
{
System.Console.WriteLine($"check connectivity : {(await client.CheckConnectivity()).Result}");
var balance = await client.GetBalance();
System.Console.WriteLine($"Wallet balance : {balance.ToSatoshis()} sat ");
var invoice = await client.CreateInvoice(Money.FromSatoshis(100),
"My First invoice", new CreateInvoiceOptions(expiry: TimeSpan.FromHours(12)));
System.Console.WriteLine($"Create a new invoice with id {invoice.Id}");
System.Console.WriteLine($"Payment request : {invoice.BOLT11}");
System.Console.WriteLine($"Expiration date : {invoice.ExpiresAt}");
System.Console.WriteLine($"Invoice Uri : {invoice.Uri}");
while (!await client.CheckPayment(invoice.Id))
{
System.Console.WriteLine("Waiting for invoice payment....");
await Task.Delay(5000);
}
}
}
}
}