LnBot 0.5.0

dotnet add package LnBot --version 0.5.0
                    
NuGet\Install-Package LnBot -Version 0.5.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LnBot" Version="0.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LnBot" Version="0.5.0" />
                    
Directory.Packages.props
<PackageReference Include="LnBot" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LnBot --version 0.5.0
                    
#r "nuget: LnBot, 0.5.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LnBot@0.5.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LnBot&version=0.5.0
                    
Install as a Cake Addin
#tool nuget:?package=LnBot&version=0.5.0
                    
Install as a Cake Tool

ln.bot-csharp

NuGet License: MIT

The official .NET SDK for ln.bot — Bitcoin for AI Agents.

Give your AI agents, apps, and services access to Bitcoin over the Lightning Network. Create wallets, send and receive sats, and get real-time payment notifications.

using LnBot;
using LnBot.Models;

using var client = new LnBotClient("key_...");

var invoice = await client.Invoices.CreateAsync(new CreateInvoiceRequest
{
    Amount = 1000,
    Memo = "Coffee",
});

ln.bot also ships a TypeScript SDK, Python SDK, Go SDK, Rust SDK, CLI, and MCP server.


Install

dotnet add package LnBot

Quick start

Create a wallet

using LnBot;
using LnBot.Models;

using var client = new LnBotClient();

var wallet = await client.Wallets.CreateAsync(new CreateWalletRequest
{
    Name = "my-agent",
});
Console.WriteLine(wallet.PrimaryKey);

Receive sats

using var client = new LnBotClient(wallet.PrimaryKey);

var invoice = await client.Invoices.CreateAsync(new CreateInvoiceRequest
{
    Amount = 1000,
    Memo = "Payment for task #42",
});
Console.WriteLine(invoice.Bolt11);

Wait for payment (SSE)

await foreach (var evt in client.Invoices.WatchAsync(invoice.Number))
{
    if (evt.Event == "settled")
    {
        Console.WriteLine("Paid!");
        break;
    }
}

Send sats

var payment = await client.Payments.CreateAsync(new CreatePaymentRequest
{
    Target = "alice@ln.bot",
    Amount = 500,
});

Check balance

var current = await client.Wallets.CurrentAsync();
Console.WriteLine($"{current.Available} sats available");

Error handling

using LnBot.Exceptions;

try
{
    var wallet = await client.Wallets.CurrentAsync();
}
catch (NotFoundException ex)
{
    Console.WriteLine($"Not found: {ex.Message}");
}
catch (BadRequestException ex)
{
    Console.WriteLine($"Bad request: {ex.Message}");
}
catch (ConflictException ex)
{
    Console.WriteLine($"Conflict: {ex.Message}");
}
catch (LnBotException ex)
{
    Console.WriteLine($"API error {ex.StatusCode}: {ex.Message}");
}

Configuration

using var client = new LnBotClient("key_...", new LnBotClientOptions
{
    BaseUrl = "https://api.ln.bot",
    Timeout = TimeSpan.FromSeconds(30),
});

Or bring your own HttpClient:

var httpClient = new HttpClient();
using var client = new LnBotClient("key_...", new LnBotClientOptions
{
    HttpClient = httpClient,
});

L402 paywalls

// Create a challenge (server side)
var challenge = await client.L402.CreateChallengeAsync(new CreateL402ChallengeRequest
{
    Amount = 100,
    Description = "API access",
    ExpirySeconds = 3600,
});

// Pay the challenge (client side)
var result = await client.L402.PayAsync(new PayL402Request
{
    WwwAuthenticate = challenge.WwwAuthenticate,
});

// Verify a token (server side, stateless)
var v = await client.L402.VerifyAsync(new VerifyL402Request
{
    Authorization = result.Authorization!,
});

Features

  • Zero dependenciesSystem.Net.Http + System.Text.Json only
  • Async-first — every method returns Task<T> with CancellationToken support
  • Typed exceptionsBadRequestException, NotFoundException, ConflictException, UnauthorizedException, ForbiddenException
  • SSE supportWatchAsync returns IAsyncEnumerable<T> for real-time events
  • Nullable reference types — fully annotated

Requirements

  • .NET 8.0+
  • Get your API key at ln.bot

Other SDKs

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on LnBot:

Package Downloads
LnBot.L402

L402 Lightning payment client for .NET — auto-pay any L402-protected API

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.0 133 2/27/2026
0.4.0 70 2/27/2026