Skip to content

Commit

Permalink
Merge pull request #4251 from anoma/murisi/ibc-for-maspless-hw
Browse files Browse the repository at this point in the history
Support IBC signing on hardware wallets not supporting MASP
  • Loading branch information
mergify[bot] authored Jan 20, 2025
2 parents 0d87759 + d9a139d commit 867e20d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/bug-fixes/4251-ibc-for-maspless-hw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Support IBC signing on hardware wallets not supporting MASP
([\#4251](https://github.com/anoma/namada/pull/4251))
22 changes: 19 additions & 3 deletions crates/apps_lib/src/client/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1404,14 +1404,30 @@ where
.chain(args.gas_spending_key.iter_mut());
let shielded_hw_keys =
augment_masp_hardware_keys(namada, &args.tx, sources).await?;
let mut bparams = generate_masp_build_params(
// Try to generate MASP build parameters. This might fail when using a
// hardware wallet if it does not support MASP operations.
let bparams_result = generate_masp_build_params(
MAX_HW_SPEND,
MAX_HW_CONVERT,
MAX_HW_OUTPUT,
&args.tx,
)
.await?;
let (mut tx, signing_data, _) = args.build(namada, &mut bparams).await?;
.await;
// If MASP build parameter generation failed for any reason, then try to
// build the transaction with no parameters. Remember the error though.
let (mut bparams, bparams_err) = bparams_result.map_or_else(
|e| (Box::new(StoredBuildParams::default()) as _, Some(e)),
|bparams| (bparams, None),
);
// If transaction building fails for any reason, then abort the process
// blaming MASP build parameter generation if that had also failed.
let (mut tx, signing_data, _) = args
.build(namada, &mut bparams)
.await
.map_err(|e| bparams_err.unwrap_or(e))?;
// Any effects of a MASP build parameter generation failure would have
// manifested during transaction building. So we discount that as a root
// cause from now on.
masp_sign(&mut tx, &args.tx, &signing_data, shielded_hw_keys).await?;

let opt_masp_section =
Expand Down

0 comments on commit 867e20d

Please sign in to comment.