1use anyhow::{bail, Result};
4use serde::{Deserialize, Serialize};
5
6use super::LNBitsEndpoint;
7
8#[derive(Debug, Serialize, Deserialize)]
10pub struct WalletDetails {
11 pub id: Option<String>,
13 pub name: String,
15}
16
17impl crate::LNBitsClient {
18 pub async fn get_wallet_details(&self) -> Result<WalletDetails> {
20 let body = self
21 .make_get(
22 LNBitsEndpoint::Wallet,
23 crate::api::LNBitsRequestKey::InvoiceRead,
24 )
25 .await?;
26 match serde_json::from_str(&body) {
27 Ok(res) => Ok(res),
28 Err(_) => {
29 log::error!("Api error response on get wallet details");
30 log::error!("{}", body);
31 bail!("Could not get wallet details")
32 }
33 }
34 }
35}