BIP38PrivateKey: Early check for NetworkParameters not null.

This commit is contained in:
Andreas Schildbach
2016-01-01 13:04:59 +01:00
parent 61594c18fe
commit 8fd9b6480f

View File

@@ -33,6 +33,7 @@ import java.security.GeneralSecurityException;
import java.text.Normalizer;
import java.util.Arrays;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
/**
@@ -53,7 +54,7 @@ public class BIP38PrivateKey extends VersionedChecksummedBytes {
public BIP38PrivateKey(NetworkParameters params, String encoded) throws AddressFormatException {
super(encoded);
this.params = params;
this.params = checkNotNull(params);
if (version != 0x01)
throw new AddressFormatException("Mismatched version number: " + version);
if (bytes.length != 38)
@@ -189,6 +190,6 @@ public class BIP38PrivateKey extends VersionedChecksummedBytes {
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
params = NetworkParameters.fromID(in.readUTF());
params = checkNotNull(NetworkParameters.fromID(in.readUTF()));
}
}