Skip to main content

lsdk/
lib.rs

1//! # lsdk
2//!
3//! A Rust SDK to talk to hardware wallets that run the BOLOS operating system
4//! (Nano S, Nano S Plus, Nano X, Stax, Flex, Nano Gen5) over USB HID, from
5//! native code or from the browser through WebHID.
6//!
7//! The crate is split in layers, each behind a cargo feature so you only pay
8//! for what you use:
9//!
10//! | Layer | Feature | Content |
11//! |-------|---------|---------|
12//! | core | *(always)* | APDU encoding, status words, HID framing, device models, [`Transport`](transport::Transport) trait, dashboard commands ([`Device`]) |
13//! | native HID | `hid` | [`transport::hid::HidTransport`] built on `hidapi` |
14//! | WebHID | `webhid` | [`transport::webhid::WebHidTransport`] for `wasm32` |
15//! | manager API | `manager-api` | [`manager::api::ManagerApi`]: app catalog, firmware metadata |
16//! | HSM channel | `hsm` | [`hsm`]: the websocket secure channel used for genuine check, install, update |
17//! | manager | `manager` | [`manager::ops`]: genuine check, install / uninstall apps, firmware update |
18//! | apps | `eth`, `btc`, `sol` | app clients ([`apps`]) to derive addresses, build and sign transactions |
19//!
20//! ```no_run
21//! # #[cfg(feature = "hid")]
22//! # async fn demo() -> Result<(), lsdk::Error> {
23//! use lsdk::{Device, transport::hid::HidTransport};
24//!
25//! let transport = HidTransport::open_first()?;
26//! let device = Device::new(transport);
27//! let version = device.get_version().await?;
28//! println!("{} running {}", version.model().map(|m| m.name()).unwrap_or("?"), version.se_version);
29//! # Ok(()) }
30//! ```
31
32#![allow(async_fn_in_trait)]
33#![cfg_attr(docsrs, feature(doc_cfg))]
34
35pub mod apdu;
36pub mod device;
37pub mod error;
38pub mod framing;
39pub mod model;
40pub mod os;
41pub mod path;
42pub mod transport;
43
44#[cfg(any(feature = "manager-api", feature = "hsm"))]
45pub mod manager;
46
47#[cfg(feature = "hsm")]
48pub mod hsm;
49
50#[cfg(feature = "attestation")]
51pub mod attestation;
52
53#[cfg(feature = "scp")]
54pub mod scp;
55
56#[cfg(feature = "loader")]
57pub mod loader;
58
59#[cfg(any(feature = "eth", feature = "btc", feature = "sol"))]
60pub mod apps;
61
62#[cfg(all(feature = "wasm", target_arch = "wasm32"))]
63pub mod wasm;
64
65pub use apdu::{Apdu, Response, StatusWord};
66pub use device::Device;
67pub use error::{Error, Result};
68pub use model::DeviceModel;
69pub use transport::Transport;
70
71/// USB vendor id used by all devices.
72pub const VENDOR_ID: u16 = 0x2c97;