lnbot
The official Rust SDK for LnBot — 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 invoice = client.invoices.create.await?;
LnBot also ships a TypeScript SDK, Python SDK, Go SDK, CLI, and MCP server.
Install
Add to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["full"] }
Quick start
Create a wallet
use ;
let client = unauthenticated;
let wallet = client.wallets.create.await?;
println!;
println!;
Receive sats
use ;
let client = new;
let invoice = client.invoices.create.await?;
println!;
Wait for payment (SSE)
use StreamExt;
use InvoiceEventType;
let mut stream = client.invoices.watch;
while let Some = stream.next.await
Send sats
use CreatePaymentRequest;
client.payments.create.await?;
Check balance
let wallet = client.wallets.current.await?;
println!;
Error handling
use LnBotError;
match client.invoices.get.await
Configuration
use LnBot;
let client = new
.with_base_url;
Features
- Async-first — built on
reqwest+tokio - 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
License
MIT