diff --git a/src-tauri/src/device.rs b/src-tauri/src/device.rs index c7ebb13..865976e 100644 --- a/src-tauri/src/device.rs +++ b/src-tauri/src/device.rs @@ -10,7 +10,10 @@ pub enum ScriptType { P2TR, } -pub fn get_xpubs(hwi_state: &HWIClientState, account: u32) -> Result { +pub fn get_xpubs( + hwi_state: &HWIClientState, + account: usize, +) -> Result { let ss_path = get_derivation_path(ScriptType::P2WPKH, hwi_state.network, account); let ms_path = get_derivation_path(ScriptType::P2WSH, hwi_state.network, account); let tr_path = get_derivation_path(ScriptType::P2TR, hwi_state.network, account); @@ -27,24 +30,28 @@ pub fn get_xpubs(hwi_state: &HWIClientState, account: u32) -> Result DerivationPath { +fn get_derivation_path( + script_type: ScriptType, + network: Network, + account: usize, +) -> DerivationPath { let network_num = match network { Network::Bitcoin => 0, Network::Testnet | Network::Signet | Network::Regtest => 1, _ => panic!("Unsupported Network"), }; match script_type { - ScriptType::P2WPKH => format!("m/84'/{}'/{}'/", network_num, account) + ScriptType::P2WPKH => format!("m/84'/{}'/{}'", network_num, account) .parse() .unwrap(), ScriptType::P2WSH => format!("m/48'/{}'/{}'/2'", network_num, account) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 01f7523..5a34630 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -138,7 +138,7 @@ fn set_hwi_client( } #[tauri::command] -async fn hwi_get_xpubs(state: State<'_, AppState>, account: u32) -> Result { +async fn hwi_get_xpubs(state: State<'_, AppState>, account: usize) -> Result { let state = state.lock().await; let hwi_state = state.hwi.as_ref().ok_or("HWI client not initialized")?; let xpub_data = get_xpubs(hwi_state, account).map_err(|e| e.to_string())?; @@ -155,7 +155,7 @@ async fn hwi_get_xpubs(state: State<'_, AppState>, account: u32) -> Result, account: u32) -> Result { +async fn hwi_healthcheck(state: State<'_, AppState>, account: usize) -> Result { let state = state.lock().await; let hwi_state = state.hwi.as_ref().ok_or("HWI client not initialized")?; let xpub_data = get_xpubs(hwi_state, account).map_err(|e| e.to_string())?;