diff --git a/tcx/src/handler.rs b/tcx/src/handler.rs index 53e43446..b222d51b 100644 --- a/tcx/src/handler.rs +++ b/tcx/src/handler.rs @@ -556,7 +556,12 @@ pub(crate) fn keystore_common_exists(data: &[u8]) -> Result> { KeystoreCommonExistsParam::decode(data).expect("keystore_common_exists params"); let key_hash: String; if param.r#type == KeyType::Mnemonic as i32 { - key_hash = key_hash_from_mnemonic(¶m.value)?; + let mnemonic: &str = ¶m + .value + .split_whitespace() + .collect::>() + .join(" "); + key_hash = key_hash_from_mnemonic(mnemonic)?; } else { if param.encoding.eq("TEZOS") { key_hash = key_hash_from_tezos_format_pk(¶m.value)?; diff --git a/tcx/src/lib.rs b/tcx/src/lib.rs index 47e9e95b..ad809ffe 100644 --- a/tcx/src/lib.rs +++ b/tcx/src/lib.rs @@ -1567,6 +1567,19 @@ mod tests { assert!(result.is_exists); assert_eq!(result.id, wallet.id); + let wallet = import_default_wallet(); + let param: KeystoreCommonExistsParam = KeystoreCommonExistsParam { + r#type: KeyType::Mnemonic as i32, + value: format!("{}", " inject kidney empty canal shadow pact comfort wife crush horse wife sketch ").to_string(),//Badly formatted mnemonic + encoding: "".to_string(), + }; + + let ret_bytes = call_api("keystore_common_exists", param).unwrap(); + let result: KeystoreCommonExistsResult = + KeystoreCommonExistsResult::decode(ret_bytes.as_slice()).unwrap(); + assert!(result.is_exists); + assert_eq!(result.id, wallet.id); + remove_created_wallet(&wallet.id); }) }