diff --git a/imkey-core/ikc/src/lib.rs b/imkey-core/ikc/src/lib.rs index 1c77fc93..cd458fdd 100644 --- a/imkey-core/ikc/src/lib.rs +++ b/imkey-core/ikc/src/lib.rs @@ -392,7 +392,7 @@ mod tests { } #[test] - fn get_register_address() { + fn test_derive_accounts() { hid_connect("imKey Pro").is_ok(); let action: ImkeyAction = ImkeyAction { method: "bind_check".to_string(), diff --git a/token-core/tcx/src/lib.rs b/token-core/tcx/src/lib.rs index 43ced2d0..930c7941 100644 --- a/token-core/tcx/src/lib.rs +++ b/token-core/tcx/src/lib.rs @@ -4056,309 +4056,4 @@ mod tests { assert_eq!(keystore.id(), "4b07b86f-cc3f-4bdd-b156-a69d5cbd4bca"); fs::remove_dir_all("../test-data/walletsV2").unwrap(); } - - #[test] - #[serial] - pub fn test_derive_accounts2() { - run_test(|| { - let param = ImportMnemonicParam { - mnemonic: OTHER_MNEMONIC.to_string(), - password: TEST_PASSWORD.to_string(), - network: "TESTNET".to_string(), - name: "test-wallet".to_string(), - password_hint: "imtoken".to_string(), - overwrite: true, - }; - let ret = call_api("import_mnemonic", param).unwrap(); - let import_result: KeystoreResult = KeystoreResult::decode(ret.as_slice()).unwrap(); - - let derivations = vec![ - // Derivation { - // chain_type: "LITECOIN".to_string(), - // path: "m/44'/2'/0'/0/0".to_string(), - // network: "MAINNET".to_string(), - // seg_wit: "NONE".to_string(), - // chain_id: "".to_string(), - // curve: "secp256k1".to_string(), - // bech32_prefix: "".to_string(), - // }, - // Derivation { - // chain_type: "LITECOIN".to_string(), - // path: "m/49'/2'/0'/0/0".to_string(), - // network: "MAINNET".to_string(), - // seg_wit: "P2WPKH".to_string(), - // chain_id: "".to_string(), - // curve: "secp256k1".to_string(), - // bech32_prefix: "".to_string(), - // }, - // Derivation { - // chain_type: "LITECOIN".to_string(), - // path: "m/49'/1'/0'/0/0".to_string(), - // network: "TESTNET".to_string(), - // seg_wit: "NONE".to_string(), - // chain_id: "".to_string(), - // curve: "secp256k1".to_string(), - // bech32_prefix: "".to_string(), - // }, - // Derivation { - // chain_type: "TRON".to_string(), - // path: "m/44'/195'/0'/0/0".to_string(), - // network: "".to_string(), - // seg_wit: "".to_string(), - // chain_id: "".to_string(), - // curve: "secp256k1".to_string(), - // bech32_prefix: "".to_string(), - // }, - // Derivation { - // chain_type: "NERVOS".to_string(), - // path: "m/44'/309'/0'/0/0".to_string(), - // network: "TESTNET".to_string(), - // seg_wit: "".to_string(), - // chain_id: "".to_string(), - // curve: "secp256k1".to_string(), - // bech32_prefix: "".to_string(), - // }, - // Derivation { - // chain_type: "FILECOIN".to_string(), - // path: "m/44'/461'/0'/0/0".to_string(), - // network: "TESTNET".to_string(), - // seg_wit: "".to_string(), - // chain_id: "".to_string(), - // curve: "secp256k1".to_string(), - // bech32_prefix: "".to_string(), - // }, - // Derivation { - // chain_type: "FILECOIN".to_string(), - // path: "m/12381/461/0/0".to_string(), - // network: "TESTNET".to_string(), - // seg_wit: "".to_string(), - // chain_id: "".to_string(), - // curve: "bls12-381".to_string(), - // bech32_prefix: "".to_string(), - // }, - // Derivation { - // chain_type: "COSMOS".to_string(), - // path: "m/44'/118'/0'/0/0".to_string(), - // network: "MAINNET".to_string(), - // seg_wit: "".to_string(), - // chain_id: "".to_string(), - // curve: "secp256k1".to_string(), - // bech32_prefix: "".to_string(), - // }, - // Derivation { - // chain_type: "EOS".to_string(), - // path: "m/44'/194'/0'/0/0".to_string(), - // network: "MAINNET".to_string(), - // seg_wit: "".to_string(), - // chain_id: "".to_string(), - // curve: "secp256k1".to_string(), - // bech32_prefix: "".to_string(), - // }, - // Derivation { - // chain_type: "ETHEREUM".to_string(), - // path: "m/44'/60'/0'/0/0".to_string(), - // network: "".to_string(), - // seg_wit: "".to_string(), - // chain_id: "".to_string(), - // curve: "secp256k1".to_string(), - // bech32_prefix: "".to_string(), - // }, - // Derivation { - // chain_type: "BITCOIN".to_string(), - // path: "m/44'/0'/0'/0/0".to_string(), - // network: "MAINNET".to_string(), - // seg_wit: "NONE".to_string(), - // chain_id: "".to_string(), - // curve: "secp256k1".to_string(), - // bech32_prefix: "".to_string(), - // }, - // Derivation { - // chain_type: "BITCOIN".to_string(), - // path: "m/49'/0'/0'/0/0".to_string(), - // network: "MAINNET".to_string(), - // seg_wit: "P2WPKH".to_string(), - // chain_id: "".to_string(), - // curve: "secp256k1".to_string(), - // bech32_prefix: "".to_string(), - // }, - Derivation { - chain_type: "KUSAMA".to_string(), - path: "m/44'/434'/0'/0'/0'".to_string(), - network: "".to_string(), - seg_wit: "".to_string(), - chain_id: "".to_string(), - curve: "sr25519".to_string(), - bech32_prefix: "".to_string(), - }, - Derivation { - chain_type: "POLKADOT".to_string(), - path: "//polkadot//imToken/0".to_string(), - network: "".to_string(), - seg_wit: "".to_string(), - chain_id: "".to_string(), - curve: "sr25519".to_string(), - bech32_prefix: "".to_string(), - }, - ]; - - let param = DeriveAccountsParam { - id: import_result.id.to_string(), - key: Some(crate::api::derive_accounts_param::Key::Password( - TEST_PASSWORD.to_owned(), - )), - derivations, - }; - let derived_accounts_bytes = call_api("derive_accounts", param).unwrap(); - let derived_accounts: DeriveAccountsResult = - DeriveAccountsResult::decode(derived_accounts_bytes.as_slice()).unwrap(); - // assert_eq!( - // "Ldfdegx3hJygDuFDUA7Rkzjjx8gfFhP9DP", - // derived_accounts.accounts[0].address - // ); - // assert_eq!( - // "0x0289ca41680edbc5594ee6378ebd937e42cd6b4b969e40dd82c20ef2a8aa5bad7b", - // derived_accounts.accounts[0].public_key - // ); - // assert_eq!("xpub6D3MqTwuLWB5veAfhDjPu1oHfS6L1imVbf22zQFWJW9EtnSmYYqiGMGkW1MCsT2HmkW872tefMY9deewW6DGd8zE7RcXVv8wKhZnbJeidjT", derived_accounts.accounts[0].extended_public_key); - // assert_eq!("MwDMFXVWDEuWvBogeW1v/MOMFDnGnnflm2JAPvJaJZO4HXp8fCsWETA7u8MzOW3KaPksglpUHLN3xkDr2QWMEQq0TewFZoZ3KsjmLW0KGMRN7XQKqo/omkSEsPfalVnp9Zxm2lpxVmIacqvlernVSg==", derived_accounts.accounts[0].encrypted_extended_public_key); - - // assert_eq!( - // "MQHaFwU3DiWQoz48TqZHtZ4jF7tFDj9yQF", - // derived_accounts.accounts[1].address - // ); - // assert_eq!( - // "0x03ace3b0da84c9944a077d62fc839c95324c2bdaa01786353f5538f89fbc24f428", - // derived_accounts.accounts[1].public_key - // ); - // assert_eq!("ypub6Y37Xmn4afXWyQduPKYWPXSbX6YUCewxo4qKJqqtKsGJzPnS95QNT261uvzfQJH95CeuGn3xEysWHau3knBKxy1tNs21HipL9cpG1LJy4Wc", derived_accounts.accounts[1].extended_public_key); - // assert_eq!("ypB3aQxsFPVl6EJAnDGiGh6UaUrh1bXsGFG7teh1fOJdkdcjq8vNCNh1f4MDYrjt71xA9cZ9y2iTRuSGdU0doLJkqdQ/VkRaGOlN4fsO2L+oBqUwxKQc0iHxsjrrNEBcge//2RglytnelFnGJHmzVw==", derived_accounts.accounts[1].encrypted_extended_public_key); - - // assert_eq!( - // "mpke4CzhBTV2dFZpnABT9EN1kPc4vDWZxw", - // derived_accounts.accounts[2].address - // ); - // assert_eq!( - // "0x031aee5e20399d68cf0035d1a21564868f22bc448ab205292b4279136b15ecaebc", - // derived_accounts.accounts[2].public_key - // ); - // assert_eq!("upub5E4woDJohDBJ2trk6HqhsvEeZXtjjWMAbHV4LWRhfR9thcpfkjJbBRnvBS21L2JjsZAGC6LhkqAoYgD5VHSXBRNW7gszbiGJP7B6CR35QhD", derived_accounts.accounts[2].extended_public_key); - // assert_eq!("ZDxvs7NEiNuUO/iXWvB2WvWmxXmQ+eP2qrEZe165dWLBm0PJpeRncYu+mZVUJJe0o6QUbnVop5TRqUBmRUzcxPioSmOVlzRpxOeUBZmaUi48hIwid1ouBZZ1zakxGLLnK4DyJN9NkyNDllKqxVhpdg==", derived_accounts.accounts[2].encrypted_extended_public_key); - - // assert_eq!( - // "TY2uroBeZ5trA9QT96aEWj32XLkAAhQ9R2", - // derived_accounts.accounts[3].address - // ); - // assert_eq!( - // "0x037b5253c24ce2a293566f9e066051366cda5073e4a43b25f07c990d7c9ac0aab5", - // derived_accounts.accounts[3].public_key - // ); - // assert_eq!("tpubDCxD6k9PreNhSacpfSZ3iErESZnncY1n7qU7e3stZXLPh84xVVt5ERMAqKeefUU8jswx2GpCkQpeYow4xH3PGx2iim6ftPa32GNvTKAtknz", derived_accounts.accounts[3].extended_public_key); - // assert_eq!("A6SCjz/iYksc/3pnVnMIzXimsQAm2p4EUJ1T6fRYkeHSqtSuBcF7O2Fyt3lYbiD4RoL1wf6VfknDiLdS1mcJyD09kXl5s+fuBaklKAZ2Dh6YuGlPGJqaGnrQ/rsTJ+Adb0ZRO3F3xGadXjiGb3hTSA==", derived_accounts.accounts[3].encrypted_extended_public_key); - - // assert_eq!( - // "ckt1qyqtr684u76tu7r8efkd24hw8922xfvhnazskzdzy6", - // derived_accounts.accounts[4].address - // ); - // assert_eq!( - // "0x03554851980004ff256888612bf0d64d9b1002bf82331450fd5a7405d1b23cc5bd", - // derived_accounts.accounts[4].public_key - // ); - // assert_eq!("tpubDDMZ3uNczagkRgAQBT6vmHFwM6Tc8RwYKU4ufqywmZEUNVfYNNyrVyXgmSpDTVsthVEbEzH5QjhxQPExpjBtVXVWZinpdRjiRGtpXuALuND", derived_accounts.accounts[4].extended_public_key); - // assert_eq!("VXhh0t5/x2aZJI0mKfkYREXX/VWw7PVEz4Gyf1bj9DS9ETRShdPA519gJMrbw8XJVk/p8X+ixbYras39ITKtl7KOSaE+E2T126r2NAR0gXRWOLIp2rrpnVWerlBkzjkoJ1KOKIPIIYhZYP7kn+tbSQ==", derived_accounts.accounts[4].encrypted_extended_public_key); - - // assert_eq!( - // "FqivQE5wEmrFDURJfkjcegQcqBuTGrxuSH5ugSVjNtNmmFF", - // derived_accounts.accounts[5].address - // ); - - // assert_eq!( - // "12wobevw8droBMpe5avXvEPPY6pUopJKEcyfHe8tmU9vVgxC", - // derived_accounts.accounts[6].address - // ); - - // assert_eq!( - // "t12i3bop43tprlnymx2c75u6uvlq7iur2rcd7qsey", - // derived_accounts.accounts[7].address - // ); - // assert_eq!( - // "0x03bd460186d29fd9ac68ee88b110c3acc4a4443648a1ec7607af9ce306ad76f785", - // derived_accounts.accounts[7].public_key - // ); - // assert_eq!("tpubDDaEZaaDDmwnZTP6u7m3yTKFgnbSx2uTaxp1hKM5oiVZo6iBB46rWnWpdkpbPxtfdYiyLbyhqgbXRXYff3LfW4rCpYyfpb5pC67CPZdKkZB", derived_accounts.accounts[7].extended_public_key); - // assert_eq!("PRImz4qL7pDJsEtqNVzVG9llzx+DN1XFbucDahOvyQ9g9yc5HWMdH6jAx4Mc/syseMWHLj9Y17Mfqib3sl88Ddgs3tTXhJq6vWToyXlQ6t9yg/LX1qKzLKcXLD+W0872G5m1urk//YOLIyhPkaLV2g==", derived_accounts.accounts[7].encrypted_extended_public_key); - - // assert_eq!( - // "cosmos1ajz9y0x3wekez7tz2td2j6l2dftn28v26dd992", - // derived_accounts.accounts[9].address - // ); - // assert_eq!( - // "0x0232c1ef21d73c19531b0aa4e863cf397c2b982b2f958f60cdb62969824c096d65", - // derived_accounts.accounts[9].public_key - // ); - // assert_eq!("xpub6CrWRZY39gj49G1ipdmcVunEnb5RoTGf9o6QnJQp8c4b84V2piN1Rdy1xWVJ4P7VXNx5Ckg6rZcvSNvJtvWz8zs3RkPayHn9vMMuK9ERrFr", derived_accounts.accounts[9].extended_public_key); - // assert_eq!("rJQ+jO02Yn+Rdfjn5QbStU/2aS0T5zW5HU83JoHLBZHafsr8FSdG7lPV59XAw1LwuUCMCtRBueG1iJ2AsA76PP1zyVzj0LxDIq3iHAOxBdwIZDP5C1sY+RMGwXk+6a2OwmYN/zF/q2SL8D6aeGyD9g==", derived_accounts.accounts[9].encrypted_extended_public_key); - - // assert_eq!("", derived_accounts.accounts[10].address); - // assert_eq!( - // "EOS88XhiiP7Cu5TmAUJqHbyuhyYgd6sei68AU266PyetDDAtjmYWF", - // derived_accounts.accounts[10].public_key - // ); - // assert_eq!("xpub6CUtvjXi3yjmhjaC2GxjiWE9FbQs1TrtqAgRDhB2gmDBsPzTfwqZ7MvGGYScKiVx8PBNFSmHm4mCnFDCaX23c1nJS4p8ynR2wnGne4qEEX9", derived_accounts.accounts[10].extended_public_key); - // assert_eq!("jSPl9msMWjfMrj/09dRJ/epEWFnjjNHoOfro8xVrvcmhTnTC0iK+RDXXJ7iI2UpIa3ckFw7g2QGaVgODFQVLrEboEysXX5YMsPczdAUrdKh27vx5A3KMFylw2kVrUmSdoMDID8wlVfqkteyIHED0iQ==", derived_accounts.accounts[10].encrypted_extended_public_key); - - // assert_eq!( - // "0x6031564e7b2F5cc33737807b2E58DaFF870B590b", - // derived_accounts.accounts[11].address - // ); - // assert_eq!( - // "0x0280c98b8ea7cab630defb0c09a4295c2193cdee016c1d5b9b0cb18572b9c370fe", - // derived_accounts.accounts[11].public_key - // ); - // assert_eq!("tpubDCvte6zYB6DKMaEy4fwyoXpuExA4ery3Hu6dVSBZeY9Rg57VKFLwNPMfywWtqRFM1Df5gQJTu42RaaNCgVEyngdVfnYRh9Kb1UCoEYojURc", derived_accounts.accounts[11].extended_public_key); - // assert_eq!("w6s0ZvUoPPSiEi1xDMKy5X9+qwhcX4u3e3LOBosJaOSro2ny9jppDxcczZfrhe29n9H3UkmgNoecq/85xfXkGDtH8PMR9iclK5WrcUtkgjXsBcrR6JF0j58i4W9x3y539vXOsLMifCmUr2RcqknDgw==", derived_accounts.accounts[11].encrypted_extended_public_key); - - // assert_eq!( - // "12z6UzsA3tjpaeuvA2Zr9jwx19Azz74D6g", - // derived_accounts.accounts[12].address - // ); - // assert_eq!( - // "0x026b5b6a9d041bc5187e0b34f9e496436c7bff261c6c1b5f3c06b433c61394b868", - // derived_accounts.accounts[12].public_key - // ); - // assert_eq!("xpub6CqzLtyKdJN53jPY13W6GdyB8ZGWuFZuBPU4Xh9DXm6Q1cULVLtsyfXSjx4G77rNdCRBgi83LByaWxjtDaZfLAKT6vFUq3EhPtNwTpJigx8", derived_accounts.accounts[12].extended_public_key); - // assert_eq!("BdgvWHN/Uh/K526q/+CdpGwEPZ41SvZHHGSgiSqhFesjErdbo6UnJMIoDOHV94qW8fd2KBW18UG3nTzDwS7a5oArqPtv+2aE9+1bNvCdtYoAx3979N3vbX4Xxn/najTABykXrJDjgpoaXxSo/xTktQ==", derived_accounts.accounts[12].encrypted_extended_public_key); - - // assert_eq!( - // "3JmreiUEKn8P3SyLYmZ7C1YCd4r2nFy3Dp", - // derived_accounts.accounts[13].address - // ); - // assert_eq!( - // "0x03036695c5f3de2e2792b170f59679d4db88a8516728012eaa42a22ce6f8bf593b", - // derived_accounts.accounts[13].public_key - // ); - // assert_eq!("ypub6Wdz1gzMKLnPxXti2GbSjQGXSqrA5NMKNP3C5JS2ZJKRDEecuZH8AhSvYQs4dZHi7b6Yind7bLekuTH9fNbJcH1MXMy9meoifu2wST55sav", derived_accounts.accounts[13].extended_public_key); - // assert_eq!("8mPByX5qAwVJ2bVNqDrm6Jx19osoWZwplnAESPaN//Gx3Q9Gp2Q2bqkaDsxlYaYsUKN6FRzwrJHaSKD2A9aWJ3RoTWJ9zY9g21zW4ttsXFl1CAZNIlFCC9CnXd2b89vDgqCQC/foz50TV4PUikR+/g==", derived_accounts.accounts[13].encrypted_extended_public_key); - - assert_eq!( - "FqivQE5wEmrFDURJfkjcegQcqBuTGrxuSH5ugSVjNtNmmFF", - derived_accounts.accounts[0].address - ); - assert_eq!( - "0x90742a577c8515391a46b7881c98c80ec92fe04255bb5b5fec862c7d633ada21", - derived_accounts.accounts[0].public_key - ); - assert_eq!("", derived_accounts.accounts[0].extended_public_key); - assert_eq!( - "", - derived_accounts.accounts[0].encrypted_extended_public_key - ); - - assert_eq!( - "12wobevw8droBMpe5avXvEPPY6pUopJKEcyfHe8tmU9vVgxC", - derived_accounts.accounts[1].address - ); - - remove_created_wallet(&import_result.id); - }) - } }