Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 19 additions & 4 deletions node-gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ license.workspace = true
version.workspace = true
edition.workspace = true
rust-version.workspace = true
authors = ["Samer Afach <samer.afach@mintlayer.org>", "Ben Marsh <benjamin.marsh@mintlayer.org>", "Enrico Rubboli <enrico.rubboli@mintlayer.org>"]
authors = [
"Samer Afach <samer.afach@mintlayer.org>",
"Ben Marsh <benjamin.marsh@mintlayer.org>",
"Enrico Rubboli <enrico.rubboli@mintlayer.org>",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -23,7 +27,7 @@ utils = { path = "../utils" }
wallet = { path = "../wallet" }
wallet-controller = { path = "../wallet/wallet-controller" }
wallet-types = { path = "../wallet/types" }
wallet-cli-commands = { path = "../wallet/wallet-cli-commands"}
wallet-cli-commands = { path = "../wallet/wallet-cli-commands" }
wallet-storage = { path = "../wallet/storage" }

anyhow.workspace = true
Expand All @@ -42,5 +46,16 @@ tokio.workspace = true
winres = "0.1"

[features]
trezor = ["wallet-controller/trezor", "wallet-types/trezor", "wallet-cli-commands/trezor", "node-gui-backend/trezor"]
default = ["trezor"]
trezor = [
"wallet-controller/trezor",
"wallet-types/trezor",
"wallet-cli-commands/trezor",
"node-gui-backend/trezor",
]
ledger = [
"wallet-controller/ledger",
"wallet-types/ledger",
"wallet-cli-commands/ledger",
"node-gui-backend/ledger",
]
default = ["trezor", "ledger"]
29 changes: 24 additions & 5 deletions node-gui/backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ license.workspace = true
version.workspace = true
edition.workspace = true
rust-version.workspace = true
authors = ["Samer Afach <samer.afach@mintlayer.org>", "Ben Marsh <benjamin.marsh@mintlayer.org>", "Enrico Rubboli <enrico.rubboli@mintlayer.org>"]
authors = [
"Samer Afach <samer.afach@mintlayer.org>",
"Ben Marsh <benjamin.marsh@mintlayer.org>",
"Enrico Rubboli <enrico.rubboli@mintlayer.org>",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -24,9 +28,9 @@ utils = { path = "../../utils" }
wallet = { path = "../../wallet" }
wallet-controller = { path = "../../wallet/wallet-controller" }
wallet-types = { path = "../../wallet/types" }
wallet-rpc-lib = { path = "../../wallet/wallet-rpc-lib"}
wallet-rpc-client = { path = "../../wallet/wallet-rpc-client"}
wallet-cli-commands = { path = "../../wallet/wallet-cli-commands"}
wallet-rpc-lib = { path = "../../wallet/wallet-rpc-lib" }
wallet-rpc-client = { path = "../../wallet/wallet-rpc-client" }
wallet-cli-commands = { path = "../../wallet/wallet-cli-commands" }

anyhow.workspace = true
chrono.workspace = true
Expand All @@ -45,4 +49,19 @@ test-utils = { path = "../../test-utils" }
rstest.workspace = true

[features]
trezor = ["wallet/trezor", "wallet-controller/trezor", "wallet-types/trezor", "wallet-rpc-lib/trezor", "wallet-rpc-client/trezor", "wallet-cli-commands/trezor"]
trezor = [
"wallet/trezor",
"wallet-controller/trezor",
"wallet-types/trezor",
"wallet-rpc-lib/trezor",
"wallet-rpc-client/trezor",
"wallet-cli-commands/trezor",
]
ledger = [
"wallet/ledger",
"wallet-controller/ledger",
"wallet-types/ledger",
"wallet-rpc-lib/ledger",
"wallet-rpc-client/ledger",
"wallet-cli-commands/ledger",
]
1 change: 1 addition & 0 deletions node-gui/src/main_window/main_widget/tabs/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ impl Tab for WalletTab {
Some(wallet_info) => match wallet_info.extra_info {
wallet_controller::types::WalletExtraInfo::SoftwareWallet => "Software wallet",
wallet_controller::types::WalletExtraInfo::TrezorWallet { .. } => "Trezor wallet",
wallet_controller::types::WalletExtraInfo::LedgerWallet { .. } => "Ledger wallet",
},
None => "No wallet",
};
Expand Down
11 changes: 8 additions & 3 deletions node-gui/src/main_window/main_widget/tabs/wallet/status_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#[cfg(any(feature = "trezor", feature = "ledger"))]
use iced::widget::{rich_text, span};
use iced::{
font,
widget::{container, row, Container},
Expand All @@ -31,7 +33,7 @@ const HORIZONTAL_PADDING: f32 = 10.;
pub fn estimate_status_bar_height(wallet_info: &WalletExtraInfo) -> f32 {
match wallet_info {
WalletExtraInfo::SoftwareWallet => 0.,
WalletExtraInfo::TrezorWallet { .. } => {
WalletExtraInfo::TrezorWallet { .. } | WalletExtraInfo::LedgerWallet { .. } => {
TEXT_SIZE + 2. * VERTICAL_PADDING
// For some reason, the status bar gets a bit of additional height.
+ 4.
Expand All @@ -55,8 +57,6 @@ pub fn view_status_bar(wallet_info: &WalletExtraInfo) -> Option<Element<'static,
device_name,
firmware_version,
} => {
use iced::widget::{rich_text, span};

row![
rich_text([span("Device name: ").font(bold_font), span(device_name.clone())])
.size(TEXT_SIZE),
Expand All @@ -67,6 +67,11 @@ pub fn view_status_bar(wallet_info: &WalletExtraInfo) -> Option<Element<'static,
.size(TEXT_SIZE),
]
}
#[cfg(feature = "ledger")]
WalletExtraInfo::LedgerWallet { app_version } => {
row![rich_text([span("App version: ").font(bold_font), span(app_version.clone())])
.size(TEXT_SIZE),]
}
};

let status_bar = Container::new(
Expand Down
1 change: 1 addition & 0 deletions wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ bip39 = { workspace = true, default-features = false, features = [
"std",
"zeroize",
] }
derive_more.workspace = true
hex.workspace = true
itertools.workspace = true
parity-scale-codec.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions wallet/src/key_chain/master_key_chain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crypto::vrf::ExtendedVRFPrivateKey;
use std::sync::Arc;
use wallet_storage::{
StoreTxRwUnlocked, WalletStorageReadLocked, WalletStorageReadUnlocked,
WalletStorageWriteUnlocked,
WalletStorageWriteLocked, WalletStorageWriteUnlocked,
};
use wallet_types::seed_phrase::{SerializableSeedPhrase, StoreSeedPhrase};

Expand Down Expand Up @@ -131,7 +131,7 @@ impl MasterKeyChain {

pub fn create_account_key_chain(
&self,
db_tx: &mut impl WalletStorageWriteUnlocked,
db_tx: &mut (impl WalletStorageWriteLocked + WalletStorageReadUnlocked),
account_index: U31,
lookahead_size: u32,
) -> KeyChainResult<AccountKeyChainImplSoftware> {
Expand Down
28 changes: 23 additions & 5 deletions wallet/src/signer/ledger_signer/ledger_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ use crypto::key::{
};
use serialization::{Decode, DecodeAll, Encode};
use utils::ensure;
use wallet_types::hw_data::LedgerFullInfo;

use ledger_lib::Exchange;
use mintlayer_ledger_messages::{
decode_all as ledger_decode_all, encode as ledger_encode, AddrType, Amount as LAmount,
Bip32Path as LedgerBip32Path, CoinType, InputAdditionalInfoReq, Ins,
OutputValue as LOutputValue, P1SignTx, PubKeyP1, PublicKeyReq, SignMessageReq, SignTxReq,
TxInput as LTxInput, TxInputReq, TxMetadataReq, TxOutput as LTxOutput, TxOutputReq, APDU_CLASS,
H256 as LH256, P1_APP_NAME, P1_SIGN_NEXT, P1_SIGN_START, P2_DONE, P2_SIGN_MORE,
H256 as LH256, P1_APP_NAME, P1_GET_VERSION, P1_SIGN_NEXT, P1_SIGN_START, P2_DONE, P2_SIGN_MORE,
};

const MAX_ADPU_LEN: usize = (u8::MAX - 5) as usize; // 4 bytes for the header + 1 for len
Expand Down Expand Up @@ -136,11 +137,15 @@ pub async fn sign_challenge<L: Exchange>(

pub async fn get_app_name<L: Exchange>(ledger: &mut L) -> Result<Vec<u8>, ledger_lib::Error> {
let msg_buf = [APDU_CLASS, Ins::APP_NAME, P1_APP_NAME, P2_DONE];
ledger.exchange(&msg_buf, Duration::from_millis(100)).await
ledger.exchange(&msg_buf, Duration::from_millis(500)).await
}

#[allow(dead_code)]
pub async fn check_current_app<L: Exchange>(ledger: &mut L) -> SignerResult<()> {
async fn get_app_version<L: Exchange>(ledger: &mut L) -> Result<Vec<u8>, ledger_lib::Error> {
let msg_buf = [APDU_CLASS, Ins::GET_VERSION, P1_GET_VERSION, P2_DONE];
ledger.exchange(&msg_buf, Duration::from_millis(500)).await
}

pub async fn check_current_app<L: Exchange>(ledger: &mut L) -> SignerResult<LedgerFullInfo> {
let resp = get_app_name(ledger)
.await
.map_err(|err| LedgerError::DeviceError(err.to_string()))?;
Expand All @@ -152,7 +157,20 @@ pub async fn check_current_app<L: Exchange>(ledger: &mut L) -> SignerResult<()>
LedgerError::DifferentActiveApp(name)
);

Ok(())
let resp = get_app_version(ledger)
.await
.map_err(|err| LedgerError::DeviceError(err.to_string()))?;
let ver = ok_response(resp)?;
let app_version = match ver.as_slice() {
[major, minor, patch] => common::primitives::semver::SemVer {
major: *major,
minor: *minor,
patch: *patch as u16,
},
_ => return Err(SignerError::LedgerError(LedgerError::InvalidResponse)),
};

Ok(LedgerFullInfo { app_version })
}

pub async fn get_extended_public_key<L: Exchange>(
Expand Down
Loading
Loading