Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thorwallet #991

Closed
wants to merge 26 commits into from
Closed
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
Binary file added images/walletList/walletListThorWallet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions rust/apps/bitcoin/src/transactions/psbt/wrapped_psbt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ impl WrappedPsbt {
is_external: path.clone().map_or(false, |v| v.1),
need_sign,
ecdsa_sighash_type: input
.sighash_type
.map(|v| v.ecdsa_hash_ty().unwrap_or(bitcoin::EcdsaSighashType::All))
.unwrap_or(bitcoin::EcdsaSighashType::All)
.to_u32() as u8,
.sighash_type
.map(|v| v.ecdsa_hash_ty().unwrap_or(bitcoin::EcdsaSighashType::All))
.unwrap_or(bitcoin::EcdsaSighashType::All)
.to_u32() as u8,
})
}

Expand Down
27 changes: 27 additions & 0 deletions rust/apps/cosmos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,31 @@ mod tests {
assert_eq!("evmos1npvwllfr9dqr8erajqqr6s0vxnk2ak55t3r99j", address);
}
}

#[test]
fn test_derive_thorchain_address_by_seed() {
let seed = [
150, 6, 60, 69, 19, 44, 132, 15, 126, 22, 101, 163, 185, 120, 20, 216, 235, 37, 134,
243, 75, 217, 69, 240, 111, 161, 91, 147, 39, 238, 190, 53, 95, 101, 78, 129, 198, 35,
58, 82, 20, 157, 122, 149, 234, 116, 134, 235, 141, 105, 145, 102, 245, 103, 126, 80,
117, 41, 72, 37, 153, 98, 76, 220,
];
let path = "M/44'/931'/0'/0/0";
let pub_key =
keystore::algorithms::secp256k1::get_public_key_by_seed(&seed, &path.to_string())
.unwrap();
let address = generate_address(pub_key, "thor").unwrap();
assert_eq!("thor14vc9484wvt66f7upncl7hq8kcvdd7qm80ld002", address);
}

#[test]
fn test_derive_thorchain_address_by_xpub() {
{
let root_path = "44'/931'/0'";
let root_xpub = "xpub6CexGUAW8CXpTAZ19JxEGRxt2g4W7YNc3XSopBxw27jjBWDF67KShM7JqUibfQpHTsjzBdEwAw9X7QsBTVxjRpgK3bUbhS4e3y6kVhUfkek";
let hd_path = "44'/931'/0'/0/0";
let address = derive_address(hd_path, root_xpub, root_path, "thor").unwrap();
assert_eq!("thor14vc9484wvt66f7upncl7hq8kcvdd7qm80ld002", address);
}
}
}
11 changes: 11 additions & 0 deletions rust/apps/ethereum/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,15 @@ mod tests {
let result = derive_address(hd_path, root_x_pub, root_path).unwrap();
assert_eq!("0x31eA4a0976ceE79AF136B1Cfa914e20E87546156", result);
}

#[test]
fn test_derive_address() {
{
let root_path = "44'/60'/0'";
let root_xpub = "xpub6DJvcCRxBqSydGgQ1TZ7xKRaQ1TriTLCpH7bd912nvJfET2HwfQo292zEcGU6pSSH7Q7PpijZf1kAgk8Rt8pkgVd5UJNFSADZN7odCbX314";
let hd_path = "44'/60'/0'/0/0";
let address = derive_address(hd_path, root_xpub, root_path).unwrap();
assert_eq!("0x5820d178f480253Fa119CbfeE349C9b69Bf8EbB9", address);
}
}
}
5 changes: 4 additions & 1 deletion rust/apps/ethereum/src/eip712/eip712.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,9 @@ mod tests {

let typed_data: TypedData = serde_json::from_value(json).unwrap();
let hash = typed_data.encode_eip712().unwrap();
// println!("hash: {:?}", hex::encode(&hash[..]));
assert_eq!(
"37fe5c140a9d70d91f786f300ce87be665e9551469e5747de4dce35edf129cf6",
hex::encode(&hash[..])
);
}
}
4 changes: 2 additions & 2 deletions rust/apps/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ pub fn sign_typed_data_message(
) -> Result<EthereumSignature> {
let utf8_message =
String::from_utf8(sign_data).map_err(|e| EthereumError::InvalidUtf8Error(e.to_string()))?;
let typed_data: Eip712TypedData = serde_json::from_str(&utf8_message)
let value: serde_json::Value = serde_json::from_str(&utf8_message).unwrap();
let typed_data: Eip712TypedData = serde_json::from_value(value)
.map_err(|e| EthereumError::InvalidTypedData(e.to_string(), utf8_message))?;

let hash = typed_data
.encode_eip712()
.map_err(|e| EthereumError::HashTypedDataError(e.to_string()))?;
Expand Down
Loading
Loading