1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! Ledger Bitcoin Application
//!
//! This application handles getting XPubs and signatures from the ledger device, and relies
//! heavily on the `coins_bip32` and `bitcoins` crates. Please see those crates for documentation
//! of their respective types.
//!
//!
//!
//! This app can be used in native and WASM applications. In native settings, it uses the `hidapi`
//! to acquire the lock, while in WASM applications it uses a ledger JS transport library.

#![warn(missing_docs)]
#![warn(unused_extern_crates)]

pub(crate) mod utils;

/// Core BTC APP.
pub mod app;

pub use app::{SigningInfo, LedgerBTC};

use thiserror::Error;

/// Error types
#[derive(Error, Debug)]
pub enum LedgerBTCError {
    /// Bip32 Error
    #[error(transparent)]
    Bip32Error(#[from] coins_bip32::Bip32Error),

    /// Derivation path too long for ledger
    #[error("Derivation Path is too long. Only 10 derivations allowed.")]
    DerivationTooLong,

    /// Underlying ledger transport error
    #[error(transparent)]
    LedgerError(#[from] coins_ledger::errors::LedgerError),

    /// Device response was unexpectedly none
    #[error("Received unexpected response from device. Expected data in response, found none.")]
    UnexpectedNullResponse,

    /// `get_tx_signatures` received an incorrect number of signing_info objects
    #[error(
        "Received the wrong number of prevouts/key derivtions while signing. Need 1 per witness."
    )]
    SigningInfoLengthMismatch,
}