Skip to content
This repository has been archived by the owner on Jul 20, 2024. It is now read-only.

Commit

Permalink
以太坊生成地址默认支持效验
Browse files Browse the repository at this point in the history
  • Loading branch information
QuincySx committed Jun 21, 2018
1 parent 5b02e47 commit cd992ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ public static String toChecksumAddress(String address) {

StringBuilder result = new StringBuilder(lowercaseAddress.length() + 2);

result.append("0x");
if (containsHexPrefix(address)) {
result.append("0x");
}

for (int i = 0; i < lowercaseAddress.length(); i++) {
if (Integer.parseInt(String.valueOf(addressHash.charAt(i)), 16) >= 8) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.quincysx.crypto.ECKeyPair;
import com.quincysx.crypto.Key;
import com.quincysx.crypto.bip32.ValidationException;
import com.quincysx.crypto.eip55.EthCheckAddress;
import com.quincysx.crypto.utils.HexUtils;
import com.quincysx.crypto.utils.KECCAK256;

Expand Down Expand Up @@ -70,7 +71,7 @@ public byte[] getRawAddress() {

@Override
public String getAddress() {
return HexUtils.toHex(getRawAddress());
return EthCheckAddress.toChecksumAddress(HexUtils.toHex(getRawAddress()));
}

public ECDSASignature doSign(byte[] input) {
Expand Down

0 comments on commit cd992ba

Please sign in to comment.