Skip to content

Commit

Permalink
core: remove deprecated methods that take instants or duration as lon…
Browse files Browse the repository at this point in the history
…g and TimeUnit
  • Loading branch information
schildbach committed Sep 2, 2024
1 parent bc7883e commit 3daf169
Show file tree
Hide file tree
Showing 21 changed files with 0 additions and 267 deletions.
18 changes: 0 additions & 18 deletions core/src/main/java/org/bitcoinj/core/Block.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,24 +230,6 @@ public Block(long version, Sha256Hash prevBlockHash, Sha256Hash merkleRoot, Inst
null;
}

/**
* Construct a block initialized with all the given fields.
* @param version This should usually be set to 1 or 2, depending on if the height is in the coinbase input.
* @param prevBlockHash Reference to previous block in the chain or {@link Sha256Hash#ZERO_HASH} if genesis.
* @param merkleRoot The root of the merkle tree formed by the transactions.
* @param time UNIX time seconds when the block was mined.
* @param difficultyTarget Number which this block hashes lower than.
* @param nonce Arbitrary number to make the block hash lower than the target.
* @param transactions List of transactions including the coinbase, or {@code null} for header-only blocks
* @deprecated use {@link #Block(long, Sha256Hash, Sha256Hash, Instant, long, long, List)}
*/
@Deprecated
public Block(long version, Sha256Hash prevBlockHash, Sha256Hash merkleRoot, long time,
long difficultyTarget, long nonce, @Nullable List<Transaction> transactions) {
this(version, prevBlockHash, merkleRoot, Instant.ofEpochSecond(time), difficultyTarget, nonce,
transactions);
}

public static Block createGenesis(Instant time, long difficultyTarget) {
return new Block(BLOCK_VERSION_GENESIS, time, difficultyTarget, genesisTransactions());
}
Expand Down
13 changes: 0 additions & 13 deletions core/src/main/java/org/bitcoinj/core/CheckpointManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,6 @@ public StoredBlock getCheckpointBefore(Instant time) {
}
}

/** @deprecated use {@link #getCheckpointBefore(Instant)} */
@Deprecated
public StoredBlock getCheckpointBefore(long timeSecs) {
return getCheckpointBefore(Instant.ofEpochSecond(timeSecs));
}

/** Returns the number of checkpoints that were loaded. */
public int numCheckpoints() {
return checkpoints.size();
Expand Down Expand Up @@ -207,11 +201,4 @@ public static void checkpoint(NetworkParameters params, InputStream checkpoints,
store.put(checkpoint);
store.setChainHead(checkpoint);
}

/** @deprecated use {@link #checkpoint(NetworkParameters, InputStream, BlockStore, Instant)} */
@Deprecated
public static void checkpoint(NetworkParameters params, InputStream checkpoints, BlockStore store, long timeSecs)
throws IOException, BlockStoreException {
checkpoint(params, checkpoints, store, Instant.ofEpochSecond(timeSecs));
}
}
9 changes: 0 additions & 9 deletions core/src/main/java/org/bitcoinj/core/Peer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1354,15 +1354,6 @@ public void setDownloadParameters(boolean useFilteredBlocks) {
}
}

/** @deprecated use {@link #setDownloadParameters(boolean)} or {@link #setFastDownloadParameters(boolean, Instant)} */
@Deprecated
public void setDownloadParameters(long fastCatchupTimeSecs, boolean useFilteredBlocks) {
if (fastCatchupTimeSecs > 0)
setFastDownloadParameters(useFilteredBlocks, Instant.ofEpochSecond(fastCatchupTimeSecs));
else
setDownloadParameters(useFilteredBlocks);
}

/**
* Links the given wallet to this peer. If you have multiple peers, you should use a {@link PeerGroup} to manage
* them and use the {@link PeerGroup#addWallet(Wallet)} method instead of registering the wallet with each peer
Expand Down
6 changes: 0 additions & 6 deletions core/src/main/java/org/bitcoinj/core/PeerAddress.java
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,6 @@ public Instant time() {
return time;
}

/** @deprecated use {@link #time()} */
@Deprecated
public long getTime() {
return time.getEpochSecond();
}

@Override
public String toString() {
if (hostname != null) {
Expand Down
7 changes: 0 additions & 7 deletions core/src/main/java/org/bitcoinj/core/PeerFilterProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ public interface PeerFilterProvider {
*/
Instant earliestKeyCreationTime();

/** @deprecated use {@link #earliestKeyCreationTime()} */
@Deprecated
default long getEarliestKeyCreationTime() {
Instant earliestKeyCreationTime = earliestKeyCreationTime();
return earliestKeyCreationTime.equals(Instant.MAX) ? Long.MAX_VALUE : earliestKeyCreationTime.getEpochSecond();
}

/**
* Called on all registered filter providers before {@link #getBloomFilterElementCount()} and
* {@link #getBloomFilter(int, double, int)} are called. Once called, the provider should ensure that the items
Expand Down
21 changes: 0 additions & 21 deletions core/src/main/java/org/bitcoinj/core/PeerGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -511,15 +511,6 @@ public void setPeerDiscoveryTimeout(Duration peerDiscoveryTimeout) {
this.vPeerDiscoveryTimeout = peerDiscoveryTimeout;
}

/**
* This is how many milliseconds we wait for peer discoveries to return their results.
* @deprecated use {@link #setPeerDiscoveryTimeout(Duration)}
*/
@Deprecated
public void setPeerDiscoveryTimeoutMillis(long peerDiscoveryTimeoutMillis) {
setPeerDiscoveryTimeout(Duration.ofMillis(peerDiscoveryTimeoutMillis));
}

/**
* Adjusts the desired number of connections that we will create to peers. Note that if there are already peers
* open and the new value is lower than the current number of peers, those connections will be terminated. Likewise
Expand Down Expand Up @@ -1774,12 +1765,6 @@ public void setFastCatchupTime(Instant fastCatchupTime) {
}
}

/** @deprecated use {@link #setFastCatchupTime(Instant)} */
@Deprecated
public void setFastCatchupTimeSecs(long fastCatchupTimeSecs) {
setFastCatchupTime(Instant.ofEpochSecond(fastCatchupTimeSecs));
}

/**
* Returns the current fast catchup time. The contents of blocks before this time won't be downloaded as they
* cannot contain any interesting transactions. If you use {@link PeerGroup#addWallet(Wallet)} this just returns
Expand All @@ -1795,12 +1780,6 @@ public Instant getFastCatchupTime() {
}
}

/** @deprecated use {@link #getFastCatchupTime()} */
@Deprecated
public long getFastCatchupTimeSecs() {
return getFastCatchupTime().getEpochSecond();
}

protected void handlePeerDeath(final Peer peer, @Nullable Throwable exception) {
// Peer deaths can occur during startup if a connect attempt after peer discovery aborts immediately.
if (!isRunning()) return;
Expand Down
7 changes: 0 additions & 7 deletions core/src/main/java/org/bitcoinj/crypto/EncryptableItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,4 @@ public interface EncryptableItem {

/** Returns the time at which this encryptable item was first created/derived, or empty of unknown. */
Optional<Instant> getCreationTime();

/** @deprecated use {@link #getCreationTime()} */
@Deprecated
default long getCreationTimeSeconds() {
Optional<Instant> creationTime = getCreationTime();
return creationTime.isPresent() ? creationTime.get().getEpochSecond() : 0;
}
}
1 change: 0 additions & 1 deletion core/src/main/java/org/bitcoinj/kits/WalletAppKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;

import static org.bitcoinj.base.internal.Preconditions.checkState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,6 @@ public void setConnectTimeout(Duration connectTimeout) {
this.connectTimeout = connectTimeout;
}

/** @deprecated use {@link #setConnectTimeout(Duration)} */
@Deprecated
public void setConnectTimeoutMillis(int connectTimeoutMillis) {
setConnectTimeout(Duration.ofMillis(connectTimeoutMillis));
}

@Override
protected void startUp() throws Exception { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.net.InetSocketAddress;
import java.time.Duration;
import java.util.List;
import java.util.concurrent.TimeUnit;

/**
* A PeerDiscovery object is responsible for finding addresses of other nodes in the Bitcoin P2P network. Note that
Expand All @@ -40,14 +39,6 @@ public interface PeerDiscovery {
*/
List<InetSocketAddress> getPeers(long services, Duration timeout) throws PeerDiscoveryException;

/**
* @deprecated use {@link #getPeers(long, Duration)}
*/
@Deprecated
default List<InetSocketAddress> getPeers(long services, long timeoutValue, TimeUnit timeoutUnit) throws PeerDiscoveryException {
return getPeers(services, Duration.ofMillis(timeoutUnit.toMillis(timeoutValue)));
}

/** Stops any discovery in progress when we want to shut down quickly. */
void shutdown();
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import java.time.Instant;
import java.time.temporal.Temporal;
import java.time.temporal.TemporalUnit;
import java.util.concurrent.TimeUnit;

import static org.bitcoinj.base.internal.Preconditions.checkState;

Expand Down
6 changes: 0 additions & 6 deletions core/src/main/java/org/bitcoinj/script/Script.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,6 @@ public Optional<Instant> creationTime() {
return Optional.ofNullable(creationTime);
}

/** @deprecated use {@link #creationTime()} */
@Deprecated
public long getCreationTimeSeconds() {
return creationTime().orElse(Instant.EPOCH).getEpochSecond();
}

/**
* Returns the program opcodes as a string, for example "[1234] DUP HASH160", or "&lt;empty&gt;".
*/
Expand Down
21 changes: 0 additions & 21 deletions core/src/main/java/org/bitcoinj/testing/FakeTxBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,6 @@ public static BlockPair createFakeBlock(BlockStore blockStore, long version,
return createFakeBlock(blockStore, version, time, 0, transactions);
}

/** @deprecated use {@link #createFakeBlock(BlockStore, long, Instant, Transaction...)} */
@Deprecated
public static BlockPair createFakeBlock(BlockStore blockStore, long version,
long timeSecs, Transaction... transactions) {
return createFakeBlock(blockStore, version, Instant.ofEpochSecond(timeSecs), transactions);
}

/** Emulates receiving a valid block */
public static BlockPair createFakeBlock(BlockStore blockStore, StoredBlock previousStoredBlock, long version,
Instant time, int height, Transaction... transactions) {
Expand All @@ -305,14 +298,6 @@ public static BlockPair createFakeBlock(BlockStore blockStore, StoredBlock previ
}
}

/** @deprecated use {@link #createFakeBlock(BlockStore, StoredBlock, long, Instant, int, Transaction...)} */
@Deprecated
public static BlockPair createFakeBlock(BlockStore blockStore, StoredBlock previousStoredBlock, long version,
long timeSecs, int height, Transaction... transactions) {
return createFakeBlock(blockStore, previousStoredBlock, version, Instant.ofEpochSecond(timeSecs), height,
transactions);
}

public static BlockPair createFakeBlock(BlockStore blockStore, StoredBlock previousStoredBlock, int height, Transaction... transactions) {
return createFakeBlock(blockStore, previousStoredBlock, Block.BLOCK_VERSION_BIP66, TimeUtils.currentTime(), height, transactions);
}
Expand All @@ -326,12 +311,6 @@ public static BlockPair createFakeBlock(BlockStore blockStore, long version, Ins
}
}

/** @deprecated use {@link #createFakeBlock(BlockStore, long, Instant, int, Transaction...)} */
@Deprecated
public static BlockPair createFakeBlock(BlockStore blockStore, long version, long timeSecs, int height, Transaction... transactions) {
return createFakeBlock(blockStore, version, Instant.ofEpochSecond(timeSecs), height, transactions);
}

/** Emulates receiving a valid block that builds on top of the chain. */
public static BlockPair createFakeBlock(BlockStore blockStore, int height,
Transaction... transactions) {
Expand Down
9 changes: 0 additions & 9 deletions core/src/main/java/org/bitcoinj/utils/ExponentialBackoff.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,6 @@ public Instant retryTime() {
return retryTime;
}

/**
* Get the next time to retry, in milliseconds since the epoch
* @deprecated use {@link #retryTime()}
**/
@Deprecated
public long getRetryTime() {
return retryTime.toEpochMilli();
}

@Override
public int compareTo(ExponentialBackoff other) {
// note that in this implementation compareTo() is not consistent with equals()
Expand Down
13 changes: 0 additions & 13 deletions core/src/main/java/org/bitcoinj/wallet/BasicKeyChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -650,13 +650,6 @@ public Optional<ECKey> findOldestKeyAfter(Instant time) {
}
}

/** @deprecated use {@link #findOldestKeyAfter(Instant)} */
@Nullable
@Deprecated
public ECKey findOldestKeyAfter(long timeSecs) {
return findOldestKeyAfter(Instant.ofEpochSecond(timeSecs)).orElse(null);
}

/** Returns a list of all ECKeys created after the given time. */
public List<ECKey> findKeysBefore(Instant time) {
lock.lock();
Expand All @@ -674,12 +667,6 @@ public List<ECKey> findKeysBefore(Instant time) {
}
}

/** @deprecated use {@link #findKeysBefore(Instant)} */
@Deprecated
public List<ECKey> findKeysBefore(long timeSecs) {
return findKeysBefore(Instant.ofEpochSecond(timeSecs));
}

public String toString(boolean includePrivateKeys, @Nullable AesKey aesKey, Network network) {
final StringBuilder builder = new StringBuilder();
List<ECKey> keys = getKeys();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,6 @@ public T entropy(byte[] entropy, Instant creationTime) {
return self();
}

/** @deprecated use {@link #entropy(byte[], Instant)} */
@Deprecated
public T entropy(byte[] entropy, long creationTimeSecs) {
checkArgument(creationTimeSecs > 0);
return entropy(entropy, Instant.ofEpochSecond(creationTimeSecs));
}

/**
* Creates a deterministic key chain starting from the given seed. All keys yielded by this chain will be the same
* if the starting seed is the same.
Expand Down
35 changes: 0 additions & 35 deletions core/src/main/java/org/bitcoinj/wallet/DeterministicSeed.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,6 @@ public static DeterministicSeed ofRandom(SecureRandom random, int bits, String p
this(decodeMnemonicCode(mnemonicString), seed, passphrase, creationTime);
}

/** @deprecated use {@link #ofMnemonic(String, String, Instant)} or {@link #ofMnemonic(String, String)} */
@Deprecated
public DeterministicSeed(String mnemonicString, byte[] seed, String passphrase, long creationTimeSecs) {
this(mnemonicString, seed, passphrase, creationTimeSecs > 0 ? Instant.ofEpochSecond(creationTimeSecs) : null);
}

/** Internal use only. */
private DeterministicSeed(byte[] seed, List<String> mnemonic, @Nullable Instant creationTime) {
this.seed = Objects.requireNonNull(seed);
Expand All @@ -165,23 +159,11 @@ private DeterministicSeed(byte[] seed, List<String> mnemonic, @Nullable Instant
this.creationTime = creationTime;
}

/** @deprecated will be removed in a future release */
@Deprecated
public DeterministicSeed(EncryptedData encryptedMnemonic, @Nullable EncryptedData encryptedSeed, long creationTimeSecs) {
this(encryptedMnemonic, encryptedSeed, creationTimeSecs > 0 ? Instant.ofEpochSecond(creationTimeSecs) : null);
}

/** Internal use only. */
private DeterministicSeed(List<String> mnemonicCode, @Nullable byte[] seed, String passphrase, @Nullable Instant creationTime) {
this((seed != null ? seed : MnemonicCode.toSeed(mnemonicCode, Objects.requireNonNull(passphrase))), mnemonicCode, creationTime);
}

/** @deprecated use {@link #ofMnemonic(List, String, Instant)} or {@link #ofMnemonic(List, String)} */
@Deprecated
public DeterministicSeed(List<String> mnemonicCode, @Nullable byte[] seed, String passphrase, long creationTimeSecs) {
this(mnemonicCode, seed, passphrase, creationTimeSecs > 0 ? Instant.ofEpochSecond(creationTimeSecs) : null);
}

/** @deprecated use {@link #ofRandom(SecureRandom, int, String)} */
@Deprecated
public DeterministicSeed(SecureRandom random, int bits, String passphrase) {
Expand All @@ -200,12 +182,6 @@ private DeterministicSeed(byte[] entropy, String passphrase, @Nullable Instant c
this.creationTime = creationTime;
}

/** @deprecated use {@link #ofEntropy(byte[], String, Instant)} or {@link #ofEntropy(byte[], String)} */
@Deprecated
public DeterministicSeed(byte[] entropy, String passphrase, long creationTimeSecs) {
this(entropy, passphrase, creationTimeSecs > 0 ? Instant.ofEpochSecond(creationTimeSecs) : null);
}

private static byte[] getEntropy(SecureRandom random, int bits) {
checkArgument(bits <= MAX_SEED_ENTROPY_BITS, () ->
"requested entropy size too large");
Expand Down Expand Up @@ -291,17 +267,6 @@ public void clearCreationTime() {
this.creationTime = null;
}

/** @deprecated use {@link #setCreationTime(Instant)} */
@Deprecated
public void setCreationTimeSeconds(long creationTimeSecs) {
if (creationTimeSecs > 0)
setCreationTime(Instant.ofEpochSecond(creationTimeSecs));
else if (creationTimeSecs == 0)
clearCreationTime();
else
throw new IllegalArgumentException("Cannot set creation time to negative value: " + creationTimeSecs);
}

public DeterministicSeed encrypt(KeyCrypter keyCrypter, AesKey aesKey) {
checkState(encryptedMnemonicCode == null, () ->
"trying to encrypt seed twice");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ public KeyTimeCoinSelector(Wallet wallet, Instant time, boolean ignorePending) {
this.ignorePending = ignorePending;
}

/** @deprecated use {@link #KeyTimeCoinSelector(Wallet, Instant, boolean)} */
@Deprecated
public KeyTimeCoinSelector(Wallet wallet, long timeSecs, boolean ignorePending) {
this(wallet, Instant.ofEpochSecond(timeSecs), ignorePending);
}

@Override
public CoinSelection select(Coin target, List<TransactionOutput> candidates) {
try {
Expand Down
Loading

0 comments on commit 3daf169

Please sign in to comment.