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

Why reverseHex once in address.toHexString() #128

Open
bluesky139 opened this issue Nov 27, 2018 · 1 comment
Open

Why reverseHex once in address.toHexString() #128

bluesky139 opened this issue Nov 27, 2018 · 1 comment

Comments

@bluesky139
Copy link

Check code below:

constructor(value: string) {
if (value.length === 40 || value.length === 34) {
this.value = value;
} else {
throw ERROR_CODE.INVALID_PARAMS;
}
}

toHexString() {
let val;
if (this.value.length === 40) {
val = this.value;
} else {
val = base58ToHex(this.value);
}
return reverseHex(val);
}

If pass 40 bytes hex string into Address, then call toHexString(), you will get a reversed wrong hex address.

@MickWang
Copy link
Contributor

The method address.toHexString is a combination of address.serialize() and reverseHex. It's barely used and you can ignore it.

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

No branches or pull requests

2 participants