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

Feature/webusb eth #22

Open
wants to merge 37 commits into
base: hotfix/fix_http_header_build_error
Choose a base branch
from

Conversation

XuNeal
Copy link
Collaborator

@XuNeal XuNeal commented May 6, 2021

No description provided.

])
return response;
}
function get_pubkey( path: string, ins: number, verify_flag: boolean) : Buffer {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最好在JS中所有方法都统一成camelCase

return genApdu(0x80,ins,p1,0x00,Buffer.from(path,"ascii"));
}
function register_address( ins: number, data: Buffer = Buffer.alloc(0)) : Buffer {
return genApdu(0x80,ins,0x00,0x00,data);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0x80和 0x00 最好有个常量定义,不然代码读起来比较累

* Error thrown when a devices returned a non success status.
* the error.statusCode is one of the `StatusCodes` exported by this library.
*/
export function TransportStatusError(statusCode: number): void {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这边可以尝试用ts 的写法 class TransportStatusError extends Error {}

fee: string,
}
const eth_apdu = ethApdu();
const remapTransactionRelatedErrors = (e) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段代码应该是 Ledger 特有的代码,我们应该用不到

let pri_key = Buffer.from("18e14a7b6a307f426a94f8114701e7c8e774e7f9a47e2c2035db29a206321725","hex");
let ha256_hash = utils.sha256(utils.sha256(data_to_sign)).substring(2)
let bind_signature = secp256k1.ecdsaSign(Buffer.from(ha256_hash,"hex"),pri_key).signature
let bind_signature_r =(bind_signature[0]>0x80) ? Buffer.concat(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

接下来的一些代码看起来和上面很像,不能合并到一起吗?

}

// TODO use bip32-path library
export function splitPath(path: string): number[] {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上面还有一个splitPath 这两个方法用哪个?

if (legacy) return legacy;

const mm = usbProductId >> 8;
console.log("mmmmmmmm:"+mm)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

部分没用的日志可以删除掉了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants