Skip to content

Commit

Permalink
Remove deprecated uses of NetworkParameters
Browse files Browse the repository at this point in the history
I realize there hasn't been a non "alpha" release since these were
deprecated but the alpha-releases are stable enough and finishing
this migration is important.
  • Loading branch information
msgilligan committed Sep 27, 2023
1 parent 8782688 commit 8b67dc3
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 70 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.consensusj.bitcoinj.wallet;

import org.bitcoinj.base.BitcoinNetwork;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.crypto.HDPath;
import org.bitcoinj.crypto.ChildNumber;

Expand Down Expand Up @@ -40,16 +39,6 @@ static HDPath pathFor(org.bitcoinj.base.ScriptType outputScriptType, String netI
.extend(coinType(netId), account(0));
}

/**
* Map desired output script type and account index to an account path
* @param outputScriptType output script type (purpose)
* @param networkParameters network/coin type
* @return The HD Path: purpose / coinType / accountIndex
*/
static HDPath pathFor(org.bitcoinj.base.ScriptType outputScriptType, NetworkParameters networkParameters) {
return pathFor(outputScriptType, networkParameters.getId());
}

/**
* Return the (root) path containing "purpose" for the specified scriptType
* @param scriptType script/address type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.bitcoinj.base.AddressParser;
import org.bitcoinj.base.Network;
import org.bitcoinj.base.exceptions.AddressFormatException;
import org.bitcoinj.core.NetworkParameters;

import java.io.IOException;

Expand Down Expand Up @@ -39,21 +38,6 @@ public AddressDeserializer(Network network) {
this(AddressParser.getDefault(network));
}

/**
* Construct an address deserializer that validates addresses for the specified {@link NetworkParameters}.
* When deserializing addresses, addresses that are not from the specified network will cause a
* {@link InvalidFormatException} to be thrown during deserialization.
*
* @param netParams Network parameters to specify the only network we will deserialize addresses for.
* @deprecated Use {@link AddressDeserializer#AddressDeserializer(Network)}
*/
@Deprecated
public AddressDeserializer(NetworkParameters netParams) {
this((netParams != null)
? AddressParser.getDefault(netParams.network())
: AddressParser.getDefault());
}

/**
* Construct an address deserializer with a custom {@link AddressParser}
* @param addressParser parser to convert a string to an address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.bitcoinj.base.AddressParser;
import org.bitcoinj.base.Network;
import org.bitcoinj.base.exceptions.AddressFormatException;
import org.bitcoinj.core.NetworkParameters;

import java.io.IOException;

Expand Down Expand Up @@ -47,14 +46,6 @@ public AddressKeyDeserializer(Network network) {
: AddressParser.getDefault());
}

/**
* @deprecated use {@link #AddressKeyDeserializer(Network)}
*/
@Deprecated
public AddressKeyDeserializer(NetworkParameters netParams) {
this(netParams.network());
}

@Override
public Object deserializeKey(String key, DeserializationContext ctxt) throws IOException, JsonProcessingException {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
import org.bitcoinj.base.Network;
import org.bitcoinj.core.Block;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.ProtocolException;

import java.io.IOException;
Expand All @@ -21,15 +19,6 @@ public class BlockHexDeserializer extends JsonDeserializer<Block> {

public BlockHexDeserializer() {
}

@Deprecated
public BlockHexDeserializer(Network network) {
}

@Deprecated
public BlockHexDeserializer(NetworkParameters netParams) {
}

@Override
public Block deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
JsonToken token = p.getCurrentToken();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.bitcoinj.base.Address;
import org.bitcoinj.base.Coin;
import org.bitcoinj.crypto.ECKey;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.Peer;
import org.bitcoinj.base.Sha256Hash;
import org.bitcoinj.core.Transaction;
Expand All @@ -30,9 +29,4 @@ public RpcServerModule() {
.addSerializer(Transaction.class, new TransactionSerializer())
.addSerializer(Script.class, new ScriptSerializer());
}

@Deprecated
public RpcServerModule(NetworkParameters netParams) {
this();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import org.bitcoinj.base.BitcoinNetwork;
import org.bitcoinj.base.Network;
import org.bitcoinj.core.NetworkParameters;

import java.net.URI;

Expand All @@ -19,11 +18,6 @@ public class RpcConfig {
private final String username;
private final String password;

@Deprecated
public RpcConfig(NetworkParameters netParams, URI uri, String username, String password) {
this(netParams.network(), uri, username, password);
}

public RpcConfig(Network network, URI uri, String username, String password) {
this.network = network;
this.uri = uri;
Expand Down Expand Up @@ -54,15 +48,6 @@ public Network network() {
return network;
}

/**
* @deprecated Use {@link #network()}
*/
@Deprecated
@JsonIgnore
public NetworkParameters getNetParams() {
return NetworkParameters.of(network);
}

@JsonProperty("netid")
public String getNetIdString() {
return network.id();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import org.bitcoinj.base.LegacyAddress;
import org.bitcoinj.base.Monetary;
import org.bitcoinj.base.Network;
import org.bitcoinj.base.SegwitAddress;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -76,7 +75,7 @@ public String toString() {
}

/**
* Return the network ID string (previously specified in {@code NetworkParameters})
* Return the network ID string (specified by a {@code Network})
*
* @return The network ID string
*/
Expand Down

0 comments on commit 8b67dc3

Please sign in to comment.