ECKey, DeterministicKey: remove deprecated methods that take NetworkParameters

This commit is contained in:
Andreas Schildbach 2024-09-02 21:56:17 +02:00
parent d046ba3119
commit 5a55660116
2 changed files with 0 additions and 138 deletions

View File

@ -487,14 +487,6 @@ public class DeterministicKey extends ECKey {
return serialize(network, pub, ScriptType.P2PKH); return serialize(network, pub, ScriptType.P2PKH);
} }
/**
* @deprecated Use {@link #serialize(Network, boolean)}
*/
@Deprecated
byte[] serialize(NetworkParameters params, boolean pub) {
return serialize(params.network(), pub);
}
// TODO: remove outputScriptType parameter and merge with the two-param serialize() method. When deprecated serializePubB58/serializePrivB58 methods are removed. // TODO: remove outputScriptType parameter and merge with the two-param serialize() method. When deprecated serializePubB58/serializePrivB58 methods are removed.
private byte[] serialize(Network network, boolean pub, ScriptType outputScriptType) { private byte[] serialize(Network network, boolean pub, ScriptType outputScriptType) {
// TODO: Remove use of NetworkParameters after we can get BIP32 headers from Network enum // TODO: Remove use of NetworkParameters after we can get BIP32 headers from Network enum
@ -529,14 +521,6 @@ public class DeterministicKey extends ECKey {
return toBase58(serialize(network, true, outputScriptType)); return toBase58(serialize(network, true, outputScriptType));
} }
/**
* @deprecated Use {@link #serializePubB58(Network, ScriptType)}
*/
@Deprecated
public String serializePubB58(NetworkParameters params, ScriptType outputScriptType) {
return serializePubB58(params.network(), outputScriptType);
}
/** /**
* Serialize private key to Base58 * Serialize private key to Base58
* <p> * <p>
@ -551,14 +535,6 @@ public class DeterministicKey extends ECKey {
return toBase58(serialize(network, false, outputScriptType)); return toBase58(serialize(network, false, outputScriptType));
} }
/**
* @deprecated Use {@link #serializePrivB58(Network, ScriptType)}
*/
@Deprecated
public String serializePrivB58(NetworkParameters params, ScriptType outputScriptType) {
return serializePrivB58(params.network(), outputScriptType);
}
/** /**
* Serialize public key to Base58 (either "xpub" or "tpub") * Serialize public key to Base58 (either "xpub" or "tpub")
* @param network which network to serialize key for * @param network which network to serialize key for
@ -568,14 +544,6 @@ public class DeterministicKey extends ECKey {
return toBase58(serialize(network, true)); return toBase58(serialize(network, true));
} }
/**
* @deprecated Use {@link #serializePubB58(Network)}
*/
@Deprecated
public String serializePubB58(NetworkParameters params) {
return serializePubB58(params.network());
}
/** /**
* Serialize private key to Base58 (either "xprv" or "tprv") * Serialize private key to Base58 (either "xprv" or "tprv")
* @param network which network to serialize key for * @param network which network to serialize key for
@ -585,14 +553,6 @@ public class DeterministicKey extends ECKey {
return toBase58(serialize(network, false)); return toBase58(serialize(network, false));
} }
/**
* @deprecated Use {@link #serializePrivB58(Network)}
*/
@Deprecated
public String serializePrivB58(NetworkParameters params) {
return serializePrivB58(params.network());
}
static String toBase58(byte[] ser) { static String toBase58(byte[] ser) {
return Base58.encode(addChecksum(ser)); return Base58.encode(addChecksum(ser));
} }
@ -602,14 +562,6 @@ public class DeterministicKey extends ECKey {
return deserializeB58(null, base58, network); return deserializeB58(null, base58, network);
} }
/**
* @deprecated Use {@link #deserializeB58(String, Network)}
*/
@Deprecated
public static DeterministicKey deserializeB58(String base58, NetworkParameters params) {
return deserializeB58(base58, params.network());
}
/** /**
* Deserialize a base-58-encoded HD Key. * Deserialize a base-58-encoded HD Key.
* @param parent The parent node in the given key's deterministic hierarchy. * @param parent The parent node in the given key's deterministic hierarchy.
@ -619,14 +571,6 @@ public class DeterministicKey extends ECKey {
return deserialize(network, Base58.decodeChecked(base58), parent); return deserialize(network, Base58.decodeChecked(base58), parent);
} }
/**
* @deprecated Use {@link #deserializeB58(DeterministicKey, String, Network)}
*/
@Deprecated
public static DeterministicKey deserializeB58(@Nullable DeterministicKey parent, String base58, NetworkParameters params) {
return deserializeB58(parent, base58, params.network());
}
/** /**
* Deserialize an HD Key with no parent * Deserialize an HD Key with no parent
*/ */
@ -634,15 +578,6 @@ public class DeterministicKey extends ECKey {
return deserialize(network, serializedKey, null); return deserialize(network, serializedKey, null);
} }
/**
* Deserialize an HD Key with no parent
* @deprecated Use {@link #deserialize(Network, byte[])}
*/
@Deprecated
public static DeterministicKey deserialize(NetworkParameters params, byte[] serializedKey) {
return deserialize(params.network(), serializedKey);
}
/** /**
* Deserialize an HD Key. * Deserialize an HD Key.
* @param parent The parent node in the given key's deterministic hierarchy. * @param parent The parent node in the given key's deterministic hierarchy.
@ -691,17 +626,6 @@ public class DeterministicKey extends ECKey {
} }
} }
/**
* Deserialize an HD Key.
* @deprecated Use {@link #deserialize(Network, byte[], DeterministicKey)}
*/
@Deprecated
public static DeterministicKey deserialize(NetworkParameters params, byte[] serializedKey, @Nullable DeterministicKey parent) {
return deserialize(params.network(), serializedKey, parent);
}
/** /**
* The creation time of a deterministic key is equal to that of its parent, unless this key is the root of a tree * The creation time of a deterministic key is equal to that of its parent, unless this key is the root of a tree
* in which case the time is stored alongside the key as per normal, see {@link ECKey#getCreationTime()}. * in which case the time is stored alongside the key as per normal, see {@link ECKey#getCreationTime()}.
@ -800,14 +724,4 @@ public class DeterministicKey extends ECKey {
builder.append(" ").append(toStringWithPrivate(aesKey, network)).append("\n"); builder.append(" ").append(toStringWithPrivate(aesKey, network)).append("\n");
} }
} }
/**
* @deprecated Use {@link #formatKeyWithAddress(boolean, AesKey, StringBuilder, Network, ScriptType, String)}
*/
@Override
@Deprecated
public void formatKeyWithAddress(boolean includePrivateKeys, @Nullable AesKey aesKey, StringBuilder builder,
NetworkParameters params, ScriptType outputScriptType, @Nullable String comment) {
formatKeyWithAddress(includePrivateKeys, aesKey, builder, params.network(), outputScriptType, comment);
}
} }

View File

@ -27,7 +27,6 @@ import org.bitcoinj.base.SegwitAddress;
import org.bitcoinj.base.Sha256Hash; import org.bitcoinj.base.Sha256Hash;
import org.bitcoinj.base.internal.TimeUtils; import org.bitcoinj.base.internal.TimeUtils;
import org.bitcoinj.base.internal.ByteUtils; import org.bitcoinj.base.internal.ByteUtils;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.base.VarInt; import org.bitcoinj.base.VarInt;
import org.bitcoinj.crypto.internal.CryptoUtils; import org.bitcoinj.crypto.internal.CryptoUtils;
import org.bitcoinj.crypto.utils.MessageVerifyUtils; import org.bitcoinj.crypto.utils.MessageVerifyUtils;
@ -1069,20 +1068,6 @@ public class ECKey implements EncryptableItem {
return new DumpedPrivateKey(network, getPrivKeyBytes(), isCompressed()); return new DumpedPrivateKey(network, getPrivKeyBytes(), isCompressed());
} }
/**
* Exports the private key in the form used by Bitcoin Core's "dumpprivkey" and "importprivkey" commands. Use
* the {@link DumpedPrivateKey#toString()} method to get the string.
*
* @param params The network this key is intended for use on.
* @return Private key bytes as a {@link DumpedPrivateKey}.
* @throws IllegalStateException if the private key is not available.
* @deprecated Use {@link #getPrivateKeyEncoded(Network)}
*/
@Deprecated
public DumpedPrivateKey getPrivateKeyEncoded(NetworkParameters params) {
return getPrivateKeyEncoded(params.network());
}
/** /**
* Returns the creation time of this key, or empty if the key was deserialized from a version that did not store * Returns the creation time of this key, or empty if the key was deserialized from a version that did not store
* that data. * that data.
@ -1305,16 +1290,6 @@ public class ECKey implements EncryptableItem {
return toString(true, aesKey, network); return toString(true, aesKey, network);
} }
/**
* Produce a string rendering of the ECKey INCLUDING the private key.
* Unless you absolutely need the private key it is better for security reasons to just use {@link #toString()}.
* @deprecated Use {@link #toStringWithPrivate(AesKey, Network)}
*/
@Deprecated
public String toStringWithPrivate(@Nullable AesKey aesKey, NetworkParameters params) {
return toStringWithPrivate(aesKey, params.network());
}
public String getPrivateKeyAsHex() { public String getPrivateKeyAsHex() {
return ByteUtils.formatHex(getPrivKeyBytes()); return ByteUtils.formatHex(getPrivKeyBytes());
} }
@ -1328,14 +1303,6 @@ public class ECKey implements EncryptableItem {
return getPrivateKeyEncoded(network).toString(); return getPrivateKeyEncoded(network).toString();
} }
/**
* @deprecated Use {@link #getPrivateKeyEncoded(Network)}
*/
@Deprecated
public String getPrivateKeyAsWiF(NetworkParameters params) {
return getPrivateKeyAsWiF(params.network());
}
private String toString(boolean includePrivate, @Nullable AesKey aesKey, Network network) { private String toString(boolean includePrivate, @Nullable AesKey aesKey, Network network) {
final MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper(this).omitNullValues(); final MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper(this).omitNullValues();
helper.add("pub HEX", getPublicKeyAsHex()); helper.add("pub HEX", getPublicKeyAsHex());
@ -1361,16 +1328,6 @@ public class ECKey implements EncryptableItem {
return helper.toString(); return helper.toString();
} }
/**
* @deprecated Use {@link #toString(boolean, AesKey, Network)}
*/
@Deprecated
private String toString(boolean includePrivate, @Nullable AesKey aesKey, @Nullable NetworkParameters params) {
Network network = (params != null) ? params.network() : BitcoinNetwork.MAINNET;
return toString(includePrivate, aesKey, network);
}
public void formatKeyWithAddress(boolean includePrivateKeys, @Nullable AesKey aesKey, StringBuilder builder, public void formatKeyWithAddress(boolean includePrivateKeys, @Nullable AesKey aesKey, StringBuilder builder,
Network network, ScriptType outputScriptType, @Nullable String comment) { Network network, ScriptType outputScriptType, @Nullable String comment) {
builder.append(" addr:"); builder.append(" addr:");
@ -1398,15 +1355,6 @@ public class ECKey implements EncryptableItem {
} }
} }
/**
* @deprecated Use {@link #formatKeyWithAddress(boolean, AesKey, StringBuilder, Network, ScriptType, String)}
*/
@Deprecated
public void formatKeyWithAddress(boolean includePrivateKeys, @Nullable AesKey aesKey, StringBuilder builder,
NetworkParameters params, ScriptType outputScriptType, @Nullable String comment) {
formatKeyWithAddress(includePrivateKeys, aesKey, builder, params.network(), outputScriptType, comment);
}
/** The string that prefixes all text messages signed using Bitcoin keys. */ /** The string that prefixes all text messages signed using Bitcoin keys. */
private static final String BITCOIN_SIGNED_MESSAGE_HEADER = "Bitcoin Signed Message:\n"; private static final String BITCOIN_SIGNED_MESSAGE_HEADER = "Bitcoin Signed Message:\n";
private static final byte[] BITCOIN_SIGNED_MESSAGE_HEADER_BYTES = BITCOIN_SIGNED_MESSAGE_HEADER.getBytes(StandardCharsets.UTF_8); private static final byte[] BITCOIN_SIGNED_MESSAGE_HEADER_BYTES = BITCOIN_SIGNED_MESSAGE_HEADER.getBytes(StandardCharsets.UTF_8);