ln.bot
The official Rust 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.
use ;
let client = new;
let w = client.wallet;
let invoice = w.invoices.create.await?;
ln.bot also ships a TypeScript SDK, Python SDK, C# SDK, Go SDK, CLI, and MCP server.
Install
Add to your Cargo.toml:
[]
= "1"
= { = "1", = ["full"] }
Quick start
Register an account
use LnBot;
let client = unauthenticated;
let account = client.register.await?;
println!;
println!;
Create a wallet
let client = new;
let wallet = client.wallets.create.await?;
println!;
Receive sats
use CreateInvoiceRequest;
let w = client.wallet;
let invoice = w.invoices.create.await?;
println!;
Wait for payment (SSE)
use StreamExt;
use InvoiceEventType;
let mut stream = w.invoices.watch;
while let Some = stream.next.await
Send sats
use CreatePaymentRequest;
w.payments.create.await?;
Check balance
let info = w.get.await?;
println!;
Wallet-scoped API
All wallet operations go through a Wallet handle obtained via client.wallet(wallet_id):
let w = client.wallet;
// Wallet info
let info = w.get.await?;
w.update.await?;
// Sub-resources
w.key // Wallet key management (wk_ keys)
w.invoices // Create, list, get, watch invoices
w.payments // Send, list, get, resolve, watch payments
w.addresses // Create, list, delete, transfer Lightning addresses
w.transactions // List transaction history
w.webhooks // Create, list, delete webhook endpoints
w.events // Real-time SSE event stream
w.l402 // L402 paywall authentication
Account-level operations stay on the client:
client.register // Register new account
client.me // Get authenticated identity
client.wallets.create // Create wallet
client.wallets.list // List wallets
client.keys.rotate // Rotate account key
client.invoices.create_for_wallet // Public invoice by wallet ID
client.invoices.create_for_address // Public invoice by address
L402 paywalls
use ;
let w = client.wallet;
// Create a challenge (server side)
let challenge = w.l402.create_challenge.await?;
// Pay the challenge (client side)
let result = w.l402.pay.await?;
// Verify a token (server side, stateless)
let v = w.l402.verify.await?;
println!;
Error handling
use LnBotError;
match w.invoices.get.await
Configuration
use LnBot;
let client = new
.with_base_url;
Features
- Async-first -- built on
reqwest+tokio - Wallet-scoped API --
client.wallet(id)returns a typed scope with all sub-resources - Strongly typed -- every request/response is a Rust struct with
serdederives - Typed enums --
InvoiceStatus,PaymentStatus,TransactionTypeare real enums, not strings - SSE streaming --
watchreturns aStreamof typed events - Typed errors --
LnBotErrorenum withBadRequest,NotFound,Conflictvariants - Forward-compatible --
#[non_exhaustive]and#[serde(other)]for safe API evolution
Requirements
- Rust 2021 edition
- Get your API key at ln.bot
Links
- ln.bot -- website
- Documentation
- GitHub
- docs.rs
- crates.io
Other SDKs
- TypeScript SDK . npm
- Python SDK . pypi
- C# SDK . NuGet
- Go SDK . pkg.go.dev
License
MIT