https://github.com/0xtlt/lnbits_rust
lnbits rust client
https://github.com/0xtlt/lnbits_rust
Last synced: 4 months ago
JSON representation
lnbits rust client
- Host: GitHub
- URL: https://github.com/0xtlt/lnbits_rust
- Owner: 0xtlt
- License: mit
- Created: 2023-01-08T08:49:55.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-25T20:24:10.000Z (almost 2 years ago)
- Last Synced: 2026-01-26T17:53:04.820Z (5 months ago)
- Language: Rust
- Size: 21.5 KB
- Stars: 5
- Watchers: 1
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# lnbits_rust
[](https://crates.io/crates/lnbits_rust)
[](https://docs.rs/lnbits_rust)
[](./LICENSE.txt)
[](https://github.com/0xtlt/lnbits_rust/actions/workflows/checks.yml)
[](https://img.shields.io/github/issues/0xtlt/lnbits_rust)
An ergonomic, [LNBits](https://lnbits.com/) API Client for Rust.
- [Changelog](CHANGELOG.md)
## Example
```toml
[dependencies]
tokio = { version = "1.0", features = ["full"] }
lnbits_rust = "0.1"
```
And then the code:
```rust,norun
use lnbits_rust::{api::invoice::CreateInvoiceParams, LNBitsClient};
#[tokio::main]
async fn main() {
let client = LNBitsClient::new(
"wallet id",
"admin_key",
"invoice_read_key",
"http://lnbits_url",
None,
)
.unwrap();
// OR with tor
let client = LNBitsClient::new(
"wallet id",
"admin_key",
"invoice_read_key",
"http://lnbits_url.onion",
Some("socks5h://127.0.0.1:9050"),
)
.unwrap();
let wallet_details = client.get_wallet_details().await.unwrap();
println!("wallet_details: {:?}", wallet_details);
let invoice = client
.create_invoice(&CreateInvoiceParams {
amount: 1,
unit: "sat".to_string(),
memo: None,
expiry: Some(10000),
webhook: None,
internal: None,
})
.await
.unwrap();
println!("invoice: {:?}", i);
println!(
"decoded invoice: {:?}",
client.decode_invoice(&i.payment_request).await.unwrap()
);
while !client.is_invoice_paid(&i.payment_hash).await.unwrap() {
println!("Waiting for payment");
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
}
println!("Payment received");
}
```
## Key features
- [x] Create invoices
- [x] Decode invoices
- [x] Pay invoices
- [x] Get wallet details
- [x] Tor support
## License
Licensed under MIT license ([LICENSE-MIT](LICENSE-MIT) or )