mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-01-19 05:33:44 +01: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;
|
||||
}
|
||||
|
||||
|
||||
// TODO: Make this use Base58.decodeChecked
|
||||
private byte[] strToHash160(String address) throws AddressFormatException {
|
||||
byte[] bytes = Base58.decode(address);
|
||||
if (bytes.length != 25) {
|
||||
@ -75,10 +75,10 @@ public class Address {
|
||||
bytes = tmp;
|
||||
}
|
||||
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);
|
||||
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];
|
||||
System.arraycopy(bytes, 1, hash160, 0, 20);
|
||||
return hash160;
|
||||
|
Loading…
Reference in New Issue
Block a user