diff --git a/src-tauri/src/commands/wallets.rs b/src-tauri/src/commands/wallets.rs index 36e628ea..d62f3e76 100644 --- a/src-tauri/src/commands/wallets.rs +++ b/src-tauri/src/commands/wallets.rs @@ -3,7 +3,7 @@ use crate::{ commands::query, configs::{self, get_cfg, get_client}, configs_profile, - key_manager::{self, inject_private_key_to_cfg}, + key_manager::{self, inject_private_key_to_cfg, get_private_key}, }; use anyhow::{anyhow, Context}; @@ -247,3 +247,10 @@ pub async fn set_slow_wallet() -> Result<(), CarpeError> { // sender.sign_submit_wait(payload).await?; Ok(()) } + +#[tauri::command] +pub fn get_private_key_from_os(address: AccountAddress) -> Result { + let pk = get_private_key(&address)?; + let acc_struct = account_keys::get_account_from_private(&pk); + Ok(acc_struct.pri_key.to_encoded_string()?) +} \ No newline at end of file diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index ef772a92..38c7de75 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -97,6 +97,7 @@ async fn main() { commands::wallets::switch_profile, commands::wallets::is_slow, commands::wallets::set_slow_wallet, + commands::wallets::get_private_key_from_os, //////// Networks //////// commands::preferences::refresh_upstream_peer_stats, commands::networks::force_upstream, diff --git a/src/components/dev/DebugGetPrivateKey.svelte b/src/components/dev/DebugGetPrivateKey.svelte new file mode 100644 index 00000000..c2dacbb5 --- /dev/null +++ b/src/components/dev/DebugGetPrivateKey.svelte @@ -0,0 +1,49 @@ + + +
+
+

PrivateKey

+
{}}> +
+
+ Address + +
+
+ PrivateKey: + {#if privateKey} + + {privateKey.slice(0, 8) + '......' + privateKey.slice(-8)} + + {/if} +
+
+ +
+
+
+ +
+
diff --git a/src/components/dev/DevMode.svelte b/src/components/dev/DevMode.svelte index 2558f073..df85d960 100644 --- a/src/components/dev/DevMode.svelte +++ b/src/components/dev/DevMode.svelte @@ -10,7 +10,7 @@ import DebugSwitcher from './DebugSwitcher.svelte' import DebugPaths from './DebugPaths.svelte' import DebugNetworkInfo from './DebugNetworkInfo.svelte' - + import DebugGetPrivateKey from './DebugGetPrivateKey.svelte' let debugEnabled = false onMount(async () => { debugMode.subscribe((b) => (debugEnabled = b)) @@ -26,6 +26,7 @@ + {#if !debugEnabled} {/if} diff --git a/src/components/layout/Copy.svelte b/src/components/layout/Copy.svelte index f51ab2ee..105ee121 100644 --- a/src/components/layout/Copy.svelte +++ b/src/components/layout/Copy.svelte @@ -1,12 +1,15 @@