Skip to content

Commit

Permalink
BIP38PrivateKey: Early check for NetworkParameters not null.
Browse files Browse the repository at this point in the history
  • Loading branch information
schildbach committed Jan 8, 2016
1 parent 18bad5d commit 4d1ed91
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/src/main/java/org/bitcoinj/crypto/BIP38PrivateKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.text.Normalizer;
import java.util.Arrays;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;

/**
Expand Down Expand Up @@ -68,7 +69,7 @@ public static BIP38PrivateKey fromBase58(NetworkParameters params, String base58
@Deprecated
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)
Expand Down Expand Up @@ -202,6 +203,6 @@ private void writeObject(ObjectOutputStream out) throws IOException {

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
params = NetworkParameters.fromID(in.readUTF());
params = checkNotNull(NetworkParameters.fromID(in.readUTF()));
}
}

0 comments on commit 4d1ed91

Please sign in to comment.