mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-01-31 07:12:17 +00:00
Add some error messages to the Address exceptions for easier debugging
This commit is contained in:
parent
bef08ade88
commit
5a3d188d03
@ -65,7 +65,7 @@ public class Address {
|
|||||||
return hash160;
|
return hash160;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Make this use Base58.decodeChecked
|
||||||
private byte[] strToHash160(String address) throws AddressFormatException {
|
private byte[] strToHash160(String address) throws AddressFormatException {
|
||||||
byte[] bytes = Base58.decode(address);
|
byte[] bytes = Base58.decode(address);
|
||||||
if (bytes.length != 25) {
|
if (bytes.length != 25) {
|
||||||
@ -75,10 +75,10 @@ public class Address {
|
|||||||
bytes = tmp;
|
bytes = tmp;
|
||||||
}
|
}
|
||||||
if (bytes[0] != params.addressHeader)
|
if (bytes[0] != params.addressHeader)
|
||||||
throw new AddressFormatException();
|
throw new AddressFormatException("Address header incorrect: from a different network?");
|
||||||
byte[] check = Utils.doubleDigest(bytes, 0, 21);
|
byte[] check = Utils.doubleDigest(bytes, 0, 21);
|
||||||
if (check[0] != bytes[21] || check[1] != bytes[22] || check[2] != bytes[23] || check[3] != bytes[24])
|
if (check[0] != bytes[21] || check[1] != bytes[22] || check[2] != bytes[23] || check[3] != bytes[24])
|
||||||
throw new AddressFormatException();
|
throw new AddressFormatException("Checksum failed: check the address for typos");
|
||||||
byte[] hash160 = new byte[20];
|
byte[] hash160 = new byte[20];
|
||||||
System.arraycopy(bytes, 1, hash160, 0, 20);
|
System.arraycopy(bytes, 1, hash160, 0, 20);
|
||||||
return hash160;
|
return hash160;
|
||||||
|
Loading…
Reference in New Issue
Block a user