From 4d1ed9173741e6ea8e520f363c703c95394a9edd Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Fri, 1 Jan 2016 13:04:59 +0100 Subject: [PATCH] BIP38PrivateKey: Early check for NetworkParameters not null. --- core/src/main/java/org/bitcoinj/crypto/BIP38PrivateKey.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/bitcoinj/crypto/BIP38PrivateKey.java b/core/src/main/java/org/bitcoinj/crypto/BIP38PrivateKey.java index a03cb715..23520d3b 100644 --- a/core/src/main/java/org/bitcoinj/crypto/BIP38PrivateKey.java +++ b/core/src/main/java/org/bitcoinj/crypto/BIP38PrivateKey.java @@ -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; /** @@ -68,7 +69,7 @@ public class BIP38PrivateKey extends VersionedChecksummedBytes { @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) @@ -202,6 +203,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())); } }