Skip to content
Merged
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
31 changes: 8 additions & 23 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ serde = "1.0"
serde_json = "1.0"
serde_test = "1.0"
serde_with = "3.6"
serial_test = "3.2"
serial_test = "3.5"
sha-1 = "0.10"
sha2 = "0.10"
sha3 = "0.10"
Expand Down Expand Up @@ -300,8 +300,8 @@ rev = "c8ed12e89788e78d77cdc0dc9fb8a4bd4dc24b89"

[workspace.dependencies.mintlayer-ledger-messages]
git = "https://github.com/mintlayer/mintlayer-ledger-app"
# The commit "Merge pull request #22 from mintlayer/fix_core_repo_build"
rev = "44988a5ba1efc8b008a8ec61f32e4d7596999023"
# The commit "Merge pull request #23 from mintlayer/bugfixing"
rev = "16cc563caa5d3f746cc1b62608b88c3bdb284fa4"
package = "mintlayer-messages"

[workspace.dependencies.trezor-client]
Expand Down
12 changes: 2 additions & 10 deletions supply-chain/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1188,10 +1188,6 @@ criteria = "safe-to-deploy"
version = "0.14.1"
criteria = "safe-to-deploy"

[[exemptions.scc]]
version = "2.4.0"
criteria = "safe-to-run"

[[exemptions.schannel]]
version = "0.1.28"
criteria = "safe-to-deploy"
Expand All @@ -1208,10 +1204,6 @@ criteria = "safe-to-deploy"
version = "0.10.1"
criteria = "safe-to-deploy"

[[exemptions.sdd]]
version = "3.0.10"
criteria = "safe-to-run"

[[exemptions.security-framework]]
version = "2.11.1"
criteria = "safe-to-run"
Expand Down Expand Up @@ -1249,11 +1241,11 @@ version = "3.16.1"
criteria = "safe-to-deploy"

[[exemptions.serial_test]]
version = "3.3.1"
version = "3.5.0"
criteria = "safe-to-run"

[[exemptions.serial_test_derive]]
version = "3.3.1"
version = "3.5.0"
criteria = "safe-to-run"

[[exemptions.signal-hook]]
Expand Down
4 changes: 2 additions & 2 deletions supply-chain/imports.lock
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ user-login = "taiki-e"
user-name = "Taiki Endo"

[[publisher.crossbeam-epoch]]
version = "0.9.18"
when = "2024-01-08"
version = "0.9.20"
when = "2026-07-06"
user-id = 33035
user-login = "taiki-e"
user-name = "Taiki Endo"
Expand Down
11 changes: 11 additions & 0 deletions wallet/LEDGER_SUPPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Using Mintlayer with Ledger

At this moment Mintlayer Ledger App is not among the official Ledger apps, so you'll have to build
and install it yourself. See https://github.com/mintlayer/mintlayer-ledger-app/blob/master/README.md
for the details on how to do it.

ℹ️ If you want to use a Mintlayer wallet with Mintlayer Ledger App running in the emulator (Speculos),
note that the wallet expects the emulator to be available on port 1237, while the instructions
in the app's README use port 9999. Make sure you pass 1237 as `--apdu-port` to Speculos, or, if you're
running it in the Docker container, map the host port 1237 to whatever you use inside the container,
e.g. `--publish 1237:9999`.
2 changes: 1 addition & 1 deletion wallet/src/key_chain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ pub fn make_path_to_vrf_key(chain_config: &ChainConfig, account_index: U31) -> D
path.try_into().expect("Path creation should not fail")
}

fn get_purpose_and_index(
pub fn get_purpose_and_index(
derivation_path: &DerivationPath,
) -> KeyChainResult<(KeyPurpose, ChildNumber)> {
// Check that derivation path has the expected number of nodes
Expand Down
29 changes: 0 additions & 29 deletions wallet/src/send_request/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,35 +210,6 @@ impl SendRequest {
Ok(())
}

pub fn from_transaction<'a, PoolDataGetter>(
transaction: Transaction,
utxos: Vec<TxOutput>,
pool_data_getter: &PoolDataGetter,
) -> WalletResult<Self>
where
PoolDataGetter: Fn(&PoolId) -> Option<&'a PoolData>,
{
let destinations = utxos
.iter()
.map(|utxo| {
get_tx_output_destination(utxo, &pool_data_getter, HtlcSpendingCondition::Skip)
.ok_or_else(|| {
WalletError::UnsupportedTransactionOutput(Box::new(utxo.clone()))
})
})
.collect::<WalletResult<Vec<_>>>()?;

Ok(Self {
flags: transaction.flags(),
utxos: utxos.into_iter().map(Some).collect(),
destinations,
inputs: transaction.inputs().to_vec(),
outputs: transaction.outputs().to_vec(),
htlc_secrets: vec![None; transaction.inputs().len()],
fees: BTreeMap::new(),
})
}

pub fn inputs(&self) -> &[TxInput] {
&self.inputs
}
Expand Down
51 changes: 24 additions & 27 deletions wallet/src/signer/ledger_signer/ledger_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crypto::key::{
};
use utils::ensure;

use crate::signer::ledger_signer::LedgerError;
use crate::signer::ledger_signer::{LedgerError, SHORT_TIMEOUT_DUR, TIMEOUT_DUR};

use super::LedgerSignature;

Expand All @@ -43,13 +43,6 @@ macro_rules! ensure_response_type {
};
}

/// Timeout duration for normal Ledger operations
const TIMEOUT_DUR: Duration = Duration::from_secs(100);
/// While trying to get a successful operation use a short timeout.
/// Used in between normal operations when the screen is showing success/failure,
/// and the Ledger app doesn't respond with any response so no need to wait for a long time.
const SHORT_TIMEOUT_DUR: Duration = Duration::from_millis(200);

/// Check that the response ends with the OK status code and return the rest of the response back
fn extract_response_apdu_data(mut resp: Vec<u8>) -> Result<Vec<u8>, LedgerError> {
let (_, status_code) = resp.split_last_chunk().ok_or(LedgerError::InvalidResponseApdu)?;
Expand Down Expand Up @@ -128,13 +121,13 @@ fn make_apdu<'a>(

pub async fn sign_challenge<L: Exchange>(
ledger: &mut L,
coin: ledger_msg::CoinType,
coin_type: ledger_msg::CoinType,
path: ledger_msg::Bip32Path,
addr_type: ledger_msg::AddrType,
message: &[u8],
) -> Result<ledger_msg::Signature, LedgerError> {
let req = ledger_msg::SignMessageStartReq {
coin,
coin_type,
addr_type,
path,
};
Expand All @@ -143,7 +136,7 @@ pub async fn sign_challenge<L: Exchange>(
ledger,
ledger_msg::Ins::SIGN_MSG,
ledger_msg::SignMsgP1::Start.into(),
&ledger_msg::encode(req),
&ledger_msg::encode(&req),
)
.await?;
let resp = decode_response(&resp)?;
Expand All @@ -163,16 +156,20 @@ pub async fn sign_challenge<L: Exchange>(
Ok(resp.signature)
}

pub fn check_current_app_info(info: ledger_lib::info::AppInfo) -> Result<String, LedgerError> {
ensure!(
info.name == "Mintlayer",
LedgerError::DifferentActiveApp(info.name)
);
Ok(info.version)
}

#[allow(unused)]
pub async fn check_current_app<L: Exchange + Device + Send>(
ledger: &mut L,
) -> Result<String, LedgerError> {
let info = ledger.app_info(TIMEOUT_DUR).await?;
let name = info.name;
let app_version = info.version;

ensure!(name == "Mintlayer", LedgerError::DifferentActiveApp(name));

Ok(app_version)
check_current_app_info(info)
}

pub async fn ping<L: Exchange>(ledger: &mut L) -> Result<(), LedgerError> {
Expand Down Expand Up @@ -202,7 +199,7 @@ pub async fn get_extended_public_key<L: Exchange>(
ledger,
ledger_msg::Ins::GET_PUB_KEY,
ledger_msg::GetPubKeyP1::NoDisplayAddress.into(),
&ledger_msg::encode(req),
&ledger_msg::encode(&req),
)
.await?;

Expand All @@ -220,13 +217,13 @@ pub async fn get_extended_public_key<L: Exchange>(

pub async fn sign_tx<L: Exchange>(
ledger: &mut L,
chain_type: ledger_msg::CoinType,
coin_type: ledger_msg::CoinType,
inputs: Vec<ledger_msg::TxInputData>,
input_commitments: Vec<ledger_msg::SighashInputCommitment>,
outputs: Vec<ledger_msg::TxOutputData>,
) -> Result<BTreeMap<usize, Vec<LedgerSignature>>, LedgerError> {
let start_req = ledger_msg::encode(ledger_msg::SignTxStartReq {
coin: chain_type,
let start_req = ledger_msg::encode(&ledger_msg::SignTxStartReq {
coin_type,
version: ledger_msg::TransactionVersion::V1,
num_inputs: inputs.len() as u32,
num_outputs: outputs.len() as u32,
Expand All @@ -247,7 +244,7 @@ pub async fn sign_tx<L: Exchange>(
ledger,
ledger_msg::Ins::SIGN_TX,
ledger_msg::SignTxP1::Next.into(),
&ledger_msg::encode(ledger_msg::SignTxNextReq::ProcessInput(Box::new(input))),
&ledger_msg::encode(&ledger_msg::SignTxNextReq::ProcessInput(Box::new(input))),
)
.await?;
let resp = decode_response(&resp)?;
Expand All @@ -259,9 +256,9 @@ pub async fn sign_tx<L: Exchange>(
ledger,
ledger_msg::Ins::SIGN_TX,
ledger_msg::SignTxP1::Next.into(),
&ledger_msg::encode(ledger_msg::SignTxNextReq::ProcessInputCommitment(Box::new(
ledger_msg::TxInputCommitmentData { commitment },
))),
&ledger_msg::encode(&ledger_msg::SignTxNextReq::ProcessInputCommitment(
Box::new(ledger_msg::TxInputCommitmentData { commitment }),
)),
)
.await?;
let resp = decode_response(&resp)?;
Expand All @@ -273,7 +270,7 @@ pub async fn sign_tx<L: Exchange>(
ledger,
ledger_msg::Ins::SIGN_TX,
ledger_msg::SignTxP1::Next.into(),
&ledger_msg::encode(ledger_msg::SignTxNextReq::ProcessOutput(Box::new(output))),
&ledger_msg::encode(&ledger_msg::SignTxNextReq::ProcessOutput(Box::new(output))),
)
.await?;

Expand All @@ -282,7 +279,7 @@ pub async fn sign_tx<L: Exchange>(
}

let next_sig_raw_req = {
let next_sig = ledger_msg::encode(ledger_msg::SignTxNextReq::ReturnNextSignature);
let next_sig = ledger_msg::encode(&ledger_msg::SignTxNextReq::ReturnNextSignature);
let apdu = make_apdu(
ledger_msg::Ins::SIGN_TX,
ledger_msg::SignTxP1::Next.into(),
Expand Down
Loading
Loading