-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
LNBitsClientSample.cs
33 lines (27 loc) · 1.09 KB
/
LNBitsClientSample.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
using System.Threading.Tasks;
using LightningPay.Clients.LNBits;
namespace LightningPay.Samples.Console
{
class LNBitsClientSample : SampleBase
{
public async override Task Execute()
{
using (var lnBitsClient =
LNBitsClient.New(apiKey: "YourApiKey"))
{
var balance = await lnBitsClient.GetBalance();
System.Console.WriteLine($"Wallet balance : {balance.ToSatoshis()} sat ");
var invoice = await lnBitsClient.CreateInvoice(Money.FromSatoshis(100),
"My First invoice");
System.Console.WriteLine($"Create a new invoice with id {invoice.Id}");
System.Console.WriteLine($"Payment request : {invoice.BOLT11}");
System.Console.WriteLine($"Invoice Uri : {invoice.Uri}");
while (!await lnBitsClient.CheckPayment(invoice.Id))
{
System.Console.WriteLine("Waiting for invoice payment....");
await Task.Delay(5000);
}
}
}
}
}