Skip to content

Commit cd3180c

Browse files
authored
Merge pull request #4358 from anoma/tomas/check-ledger-app-version
wallet: check min ledger app version for shielded key derivation
2 parents 9da7deb + 314a1e5 commit cd3180c

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Added a wallet check of the minimum supported Ledger app version for shielded
2+
key derivation. ([\#4358](https://github.com/anoma/namada/pull/4358))

crates/apps_lib/src/cli/wallet.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,22 @@ async fn shielded_key_derive(
254254
cli::safe_exit(1)
255255
}),
256256
);
257+
let version = app.version().await.unwrap_or_else(|err| {
258+
edisplay_line!(io, "Failed to retrieve Ledger app version: {err}");
259+
cli::safe_exit(1)
260+
});
261+
if version.major < 3 {
262+
edisplay_line!(
263+
io,
264+
"Minimum supported Ledger app version is 3.0.0 due to a \
265+
change in modified ZIP32 derivation path. Got v{}.{}.{}.",
266+
version.major,
267+
version.minor,
268+
version.patch
269+
);
270+
cli::safe_exit(1)
271+
}
272+
257273
let response = app
258274
.retrieve_keys(
259275
&BIP44Path {

crates/apps_lib/src/client/tx.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,10 +943,34 @@ async fn augment_masp_hardware_keys(
943943
let transport = WalletTransport::from_arg(args.device_transport);
944944
let app = NamadaApp::new(transport);
945945
let wallet = namada.wallet().await;
946+
let mut checked_app_version = false;
946947
// Augment the pseudo spending key with a proof authorization key
947948
for source in sources {
948949
// Only attempt an augmentation if proof authorization is not there
949950
if source.to_spending_key().is_none() {
951+
if !checked_app_version {
952+
checked_app_version = true;
953+
let version = app.version().await.map_err(|err| {
954+
error::Error::Other(format!(
955+
"Failed to retrieve Ledger app version: {err}"
956+
))
957+
})?;
958+
if version.major < 3 {
959+
edisplay_line!(
960+
namada.io(),
961+
"Please upgrade the Ledger app to version greater \
962+
than or equal to 3.0.0 (got v{}.{}.{}.), due to \
963+
a change in modified ZIP32 derivation path. If \
964+
you have keys derived using an older versions, \
965+
we recommend that you move any funds associated \
966+
with them to new keys.",
967+
version.major,
968+
version.minor,
969+
version.patch
970+
);
971+
}
972+
}
973+
950974
// First find the derivation path corresponding to this viewing
951975
// key
952976
let viewing_key =

0 commit comments

Comments
 (0)