lexe/
lib.rs

1//! Lexe Rust SDK.
2
3#![deny(missing_docs)]
4
5// --- Public API --- //
6//
7// All APIs accessible via these public modules must respect semver guarantees.
8
9/// Configuration options for a `LexeWallet`.
10pub mod config;
11/// Local payments database synced from the user node.
12pub mod payments_db;
13/// `LexeWallet`: the top-level handle to a Lexe wallet.
14pub mod wallet;
15
16/// Returns the default Lexe data directory (`~/.lexe`).
17pub use common::default_lexe_data_dir;
18
19/// Reexported types needed by SDK consumers.
20/// All types exported here are considered part of the stable public API.
21pub mod types {
22    pub use common::{
23        api::user::{NodePk, UserPk},
24        enclave::Measurement,
25        ln::{amount::Amount, hashes::LxTxid, priority::ConfirmationPriority},
26        rng::SysRng,
27        root_seed::RootSeed,
28        time::TimestampMs,
29    };
30    pub use lexe_api::{
31        models::command::UpdatePaymentNote,
32        types::payments::{
33            BasicPaymentV2, PaymentCreatedIndex, PaymentUpdatedIndex,
34        },
35    };
36    pub use lexe_api_core::types::{
37        invoice::LxInvoice,
38        payments::{
39            LxPaymentHash, LxPaymentId, LxPaymentSecret, PaymentDirection,
40            PaymentKind, PaymentRail, PaymentStatus,
41        },
42    };
43    pub use node_client::credentials::{
44        ClientCredentials, Credentials, CredentialsRef,
45    };
46    pub use sdk_core::{
47        models::{
48            SdkCreateInvoiceRequest, SdkCreateInvoiceResponse,
49            SdkGetPaymentRequest, SdkGetPaymentResponse, SdkNodeInfo,
50            SdkPayInvoiceRequest, SdkPayInvoiceResponse,
51        },
52        types::SdkPayment,
53    };
54}
55
56// Reexport possibly-useful dependencies
57pub use anyhow;
58pub use serde_json;
59pub use tracing;
60
61/// Initialize the Lexe logger with the given default log level.
62///
63/// Example: `lexe_sdk::init_logger("info")`
64pub fn init_logger(default_level: &str) {
65    logger::init_with_default(default_level);
66}
67
68// --- Unstable APIs --- //
69
70/// This module ensures all unstable APIs are accessible within the crate, but
71/// not to external users of the crate, unless they enable the `unstable`
72/// feature, in which case they can access it via the re-export below.
73mod unstable {
74    /// `Ffs`: A flat file system abstraction.
75    pub mod ffs;
76    /// Provision-related utilities.
77    pub mod provision;
78    /// Wallet database.
79    pub mod wallet_db;
80}
81
82/// Opt-in to unstable APIs.
83#[cfg(feature = "unstable")]
84pub use unstable::*;