From 3daf1692ad71000a50d3542cc12d22c195923e9a Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Mon, 2 Sep 2024 13:23:37 +0200 Subject: [PATCH] core: remove deprecated methods that take instants or duration as long and TimeUnit --- .../main/java/org/bitcoinj/core/Block.java | 18 ----- .../org/bitcoinj/core/CheckpointManager.java | 13 ---- .../src/main/java/org/bitcoinj/core/Peer.java | 9 --- .../java/org/bitcoinj/core/PeerAddress.java | 6 -- .../org/bitcoinj/core/PeerFilterProvider.java | 7 -- .../java/org/bitcoinj/core/PeerGroup.java | 21 ------ .../org/bitcoinj/crypto/EncryptableItem.java | 7 -- .../java/org/bitcoinj/kits/WalletAppKit.java | 1 - .../bitcoinj/net/BlockingClientManager.java | 6 -- .../bitcoinj/net/discovery/PeerDiscovery.java | 9 --- .../bitcoinj/params/BitcoinNetworkParams.java | 1 - .../main/java/org/bitcoinj/script/Script.java | 6 -- .../org/bitcoinj/testing/FakeTxBuilder.java | 21 ------ .../bitcoinj/utils/ExponentialBackoff.java | 9 --- .../org/bitcoinj/wallet/BasicKeyChain.java | 13 ---- .../wallet/DeterministicKeyChain.java | 7 -- .../bitcoinj/wallet/DeterministicSeed.java | 35 ---------- .../bitcoinj/wallet/KeyTimeCoinSelector.java | 6 -- .../main/java/org/bitcoinj/wallet/Wallet.java | 65 ------------------- .../java/org/bitcoinj/wallet/WalletFiles.java | 6 -- .../net/discovery/DnsDiscoveryTest.java | 1 - 21 files changed, 267 deletions(-) diff --git a/core/src/main/java/org/bitcoinj/core/Block.java b/core/src/main/java/org/bitcoinj/core/Block.java index 3cacdd0fc..6422501f7 100644 --- a/core/src/main/java/org/bitcoinj/core/Block.java +++ b/core/src/main/java/org/bitcoinj/core/Block.java @@ -230,24 +230,6 @@ public class Block extends BaseMessage { 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 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()); } diff --git a/core/src/main/java/org/bitcoinj/core/CheckpointManager.java b/core/src/main/java/org/bitcoinj/core/CheckpointManager.java index cb36d8fef..534291bf9 100644 --- a/core/src/main/java/org/bitcoinj/core/CheckpointManager.java +++ b/core/src/main/java/org/bitcoinj/core/CheckpointManager.java @@ -166,12 +166,6 @@ public class CheckpointManager { } } - /** @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(); @@ -207,11 +201,4 @@ public class CheckpointManager { 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)); - } } diff --git a/core/src/main/java/org/bitcoinj/core/Peer.java b/core/src/main/java/org/bitcoinj/core/Peer.java index 2d7274561..050746fcf 100644 --- a/core/src/main/java/org/bitcoinj/core/Peer.java +++ b/core/src/main/java/org/bitcoinj/core/Peer.java @@ -1354,15 +1354,6 @@ public class Peer extends PeerSocketHandler { } } - /** @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 diff --git a/core/src/main/java/org/bitcoinj/core/PeerAddress.java b/core/src/main/java/org/bitcoinj/core/PeerAddress.java index b64f45b96..71b02c8a5 100644 --- a/core/src/main/java/org/bitcoinj/core/PeerAddress.java +++ b/core/src/main/java/org/bitcoinj/core/PeerAddress.java @@ -414,12 +414,6 @@ public class PeerAddress { return time; } - /** @deprecated use {@link #time()} */ - @Deprecated - public long getTime() { - return time.getEpochSecond(); - } - @Override public String toString() { if (hostname != null) { diff --git a/core/src/main/java/org/bitcoinj/core/PeerFilterProvider.java b/core/src/main/java/org/bitcoinj/core/PeerFilterProvider.java index 12155d545..0a9cb39bd 100644 --- a/core/src/main/java/org/bitcoinj/core/PeerFilterProvider.java +++ b/core/src/main/java/org/bitcoinj/core/PeerFilterProvider.java @@ -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 diff --git a/core/src/main/java/org/bitcoinj/core/PeerGroup.java b/core/src/main/java/org/bitcoinj/core/PeerGroup.java index 817d2b0ef..8c41522d6 100644 --- a/core/src/main/java/org/bitcoinj/core/PeerGroup.java +++ b/core/src/main/java/org/bitcoinj/core/PeerGroup.java @@ -511,15 +511,6 @@ public class PeerGroup implements TransactionBroadcaster { 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 @@ -1774,12 +1765,6 @@ public class PeerGroup implements TransactionBroadcaster { } } - /** @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 @@ -1795,12 +1780,6 @@ public class PeerGroup implements TransactionBroadcaster { } } - /** @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; diff --git a/core/src/main/java/org/bitcoinj/crypto/EncryptableItem.java b/core/src/main/java/org/bitcoinj/crypto/EncryptableItem.java index 3dd3d38fd..c5b1368b5 100644 --- a/core/src/main/java/org/bitcoinj/crypto/EncryptableItem.java +++ b/core/src/main/java/org/bitcoinj/crypto/EncryptableItem.java @@ -44,11 +44,4 @@ public interface EncryptableItem { /** Returns the time at which this encryptable item was first created/derived, or empty of unknown. */ Optional getCreationTime(); - - /** @deprecated use {@link #getCreationTime()} */ - @Deprecated - default long getCreationTimeSeconds() { - Optional creationTime = getCreationTime(); - return creationTime.isPresent() ? creationTime.get().getEpochSecond() : 0; - } } diff --git a/core/src/main/java/org/bitcoinj/kits/WalletAppKit.java b/core/src/main/java/org/bitcoinj/kits/WalletAppKit.java index 54a1a8745..1e31bfd7d 100644 --- a/core/src/main/java/org/bitcoinj/kits/WalletAppKit.java +++ b/core/src/main/java/org/bitcoinj/kits/WalletAppKit.java @@ -60,7 +60,6 @@ import java.util.Collections; 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; diff --git a/core/src/main/java/org/bitcoinj/net/BlockingClientManager.java b/core/src/main/java/org/bitcoinj/net/BlockingClientManager.java index 44b19f359..6ce9161ca 100644 --- a/core/src/main/java/org/bitcoinj/net/BlockingClientManager.java +++ b/core/src/main/java/org/bitcoinj/net/BlockingClientManager.java @@ -73,12 +73,6 @@ public class BlockingClientManager extends AbstractIdleService implements Client this.connectTimeout = connectTimeout; } - /** @deprecated use {@link #setConnectTimeout(Duration)} */ - @Deprecated - public void setConnectTimeoutMillis(int connectTimeoutMillis) { - setConnectTimeout(Duration.ofMillis(connectTimeoutMillis)); - } - @Override protected void startUp() throws Exception { } diff --git a/core/src/main/java/org/bitcoinj/net/discovery/PeerDiscovery.java b/core/src/main/java/org/bitcoinj/net/discovery/PeerDiscovery.java index bfe9411bf..d437c63ee 100644 --- a/core/src/main/java/org/bitcoinj/net/discovery/PeerDiscovery.java +++ b/core/src/main/java/org/bitcoinj/net/discovery/PeerDiscovery.java @@ -23,7 +23,6 @@ import org.bitcoinj.core.VersionMessage; 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 @@ -40,14 +39,6 @@ public interface PeerDiscovery { */ List getPeers(long services, Duration timeout) throws PeerDiscoveryException; - /** - * @deprecated use {@link #getPeers(long, Duration)} - */ - @Deprecated - default List 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(); } diff --git a/core/src/main/java/org/bitcoinj/params/BitcoinNetworkParams.java b/core/src/main/java/org/bitcoinj/params/BitcoinNetworkParams.java index 4b49f65bb..11cd5fbdf 100644 --- a/core/src/main/java/org/bitcoinj/params/BitcoinNetworkParams.java +++ b/core/src/main/java/org/bitcoinj/params/BitcoinNetworkParams.java @@ -42,7 +42,6 @@ import java.time.Duration; 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; diff --git a/core/src/main/java/org/bitcoinj/script/Script.java b/core/src/main/java/org/bitcoinj/script/Script.java index 4533750a2..ff6434bc9 100644 --- a/core/src/main/java/org/bitcoinj/script/Script.java +++ b/core/src/main/java/org/bitcoinj/script/Script.java @@ -382,12 +382,6 @@ public class Script { 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 "<empty>". */ diff --git a/core/src/main/java/org/bitcoinj/testing/FakeTxBuilder.java b/core/src/main/java/org/bitcoinj/testing/FakeTxBuilder.java index 44e2b21ec..d229f2903 100644 --- a/core/src/main/java/org/bitcoinj/testing/FakeTxBuilder.java +++ b/core/src/main/java/org/bitcoinj/testing/FakeTxBuilder.java @@ -277,13 +277,6 @@ public class FakeTxBuilder { 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) { @@ -305,14 +298,6 @@ public class FakeTxBuilder { } } - /** @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); } @@ -326,12 +311,6 @@ public class FakeTxBuilder { } } - /** @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) { diff --git a/core/src/main/java/org/bitcoinj/utils/ExponentialBackoff.java b/core/src/main/java/org/bitcoinj/utils/ExponentialBackoff.java index d5831b640..72f827927 100644 --- a/core/src/main/java/org/bitcoinj/utils/ExponentialBackoff.java +++ b/core/src/main/java/org/bitcoinj/utils/ExponentialBackoff.java @@ -95,15 +95,6 @@ public class ExponentialBackoff implements Comparable { 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() diff --git a/core/src/main/java/org/bitcoinj/wallet/BasicKeyChain.java b/core/src/main/java/org/bitcoinj/wallet/BasicKeyChain.java index 7d864c73f..8b95f05c5 100644 --- a/core/src/main/java/org/bitcoinj/wallet/BasicKeyChain.java +++ b/core/src/main/java/org/bitcoinj/wallet/BasicKeyChain.java @@ -650,13 +650,6 @@ public class BasicKeyChain implements EncryptableKeyChain { } } - /** @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 findKeysBefore(Instant time) { lock.lock(); @@ -674,12 +667,6 @@ public class BasicKeyChain implements EncryptableKeyChain { } } - /** @deprecated use {@link #findKeysBefore(Instant)} */ - @Deprecated - public List findKeysBefore(long timeSecs) { - return findKeysBefore(Instant.ofEpochSecond(timeSecs)); - } - public String toString(boolean includePrivateKeys, @Nullable AesKey aesKey, Network network) { final StringBuilder builder = new StringBuilder(); List keys = getKeys(); diff --git a/core/src/main/java/org/bitcoinj/wallet/DeterministicKeyChain.java b/core/src/main/java/org/bitcoinj/wallet/DeterministicKeyChain.java index a3a98a57f..3464a6091 100644 --- a/core/src/main/java/org/bitcoinj/wallet/DeterministicKeyChain.java +++ b/core/src/main/java/org/bitcoinj/wallet/DeterministicKeyChain.java @@ -219,13 +219,6 @@ public class DeterministicKeyChain implements EncryptableKeyChain { 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. diff --git a/core/src/main/java/org/bitcoinj/wallet/DeterministicSeed.java b/core/src/main/java/org/bitcoinj/wallet/DeterministicSeed.java index bc4f149c0..df02a40e2 100644 --- a/core/src/main/java/org/bitcoinj/wallet/DeterministicSeed.java +++ b/core/src/main/java/org/bitcoinj/wallet/DeterministicSeed.java @@ -141,12 +141,6 @@ public class DeterministicSeed implements EncryptableItem { 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 mnemonic, @Nullable Instant creationTime) { this.seed = Objects.requireNonNull(seed); @@ -165,23 +159,11 @@ public class DeterministicSeed implements EncryptableItem { 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 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 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) { @@ -200,12 +182,6 @@ public class DeterministicSeed implements EncryptableItem { 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"); @@ -291,17 +267,6 @@ public class DeterministicSeed implements EncryptableItem { 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"); diff --git a/core/src/main/java/org/bitcoinj/wallet/KeyTimeCoinSelector.java b/core/src/main/java/org/bitcoinj/wallet/KeyTimeCoinSelector.java index 5656711fe..f82810528 100644 --- a/core/src/main/java/org/bitcoinj/wallet/KeyTimeCoinSelector.java +++ b/core/src/main/java/org/bitcoinj/wallet/KeyTimeCoinSelector.java @@ -57,12 +57,6 @@ public class KeyTimeCoinSelector implements CoinSelector { 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 candidates) { try { diff --git a/core/src/main/java/org/bitcoinj/wallet/Wallet.java b/core/src/main/java/org/bitcoinj/wallet/Wallet.java index 0b93f9362..7fe0d09c7 100644 --- a/core/src/main/java/org/bitcoinj/wallet/Wallet.java +++ b/core/src/main/java/org/bitcoinj/wallet/Wallet.java @@ -134,7 +134,6 @@ import java.util.TreeSet; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.Executor; -import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.ReentrantLock; import java.util.stream.Collectors; @@ -497,16 +496,6 @@ public class Wallet extends BaseTaggableObject return fromWatchingKeyB58(params.network(), watchKeyB58); } - /** - * @deprecated Use {@link #fromWatchingKeyB58(Network, String, Instant)} or {@link #fromWatchingKeyB58(Network, String)} - */ - @Deprecated - public static Wallet fromWatchingKeyB58(NetworkParameters params, String watchKeyB58, long creationTimeSeconds) { - return (creationTimeSeconds == 0) - ? fromWatchingKeyB58(params.network(), watchKeyB58) - : fromWatchingKeyB58(params.network(), watchKeyB58, Instant.ofEpochSecond(creationTimeSeconds)); - } - /** * Creates a wallet that tracks payments to and from the HD key hierarchy rooted by the given spending key. This HAS * to be an account key as returned by {@link DeterministicKeyChain#getWatchingKey()}. This wallet can also spend. @@ -570,16 +559,6 @@ public class Wallet extends BaseTaggableObject return fromSpendingKeyB58(params.network(), spendingKeyB58); } - /** - * @deprecated Use {@link #fromSpendingKeyB58(Network, String, Instant)} or {@link #fromSpendingKeyB58(Network, String)} - */ - @Deprecated - public static Wallet fromSpendingKeyB58(NetworkParameters params, String spendingKeyB58, long creationTimeSeconds) { - return (creationTimeSeconds == 0) - ? fromSpendingKeyB58(params.network(), spendingKeyB58) - : fromSpendingKeyB58(params.network(), spendingKeyB58, Instant.ofEpochSecond(creationTimeSeconds)); - } - /** * Creates a spending wallet that tracks payments to and from a BIP32-style HD key hierarchy rooted by {@code masterKey} and * {@code accountNumber}. The account path must be directly below the master key as in BIP-32. @@ -1189,14 +1168,6 @@ public class Wallet extends BaseTaggableObject return addWatchedAddresses(Collections.singletonList(address), creationTime) == 1; } - /** @deprecated use {@link #addWatchedAddress(Address, Instant)} or {@link #addWatchedAddress(Address)} */ - @Deprecated - public boolean addWatchedAddress(final Address address, long creationTime) { - return creationTime > 0 ? - addWatchedAddress(address, Instant.ofEpochSecond(creationTime)) : - addWatchedAddress(address); - } - /** * Adds the given addresses to the wallet to be watched. Outputs can be retrieved * by {@link #getWatchedOutputs(boolean)}. @@ -1228,14 +1199,6 @@ public class Wallet extends BaseTaggableObject return addWatchedScripts(scripts); } - /** @deprecated use {@link #addWatchedAddresses(List, Instant)} or {@link #addWatchedAddresses(List)} */ - @Deprecated - public int addWatchedAddresses(final List
addresses, long creationTime) { - return creationTime > 0 ? - addWatchedAddresses(addresses, creationTime) : - addWatchedAddresses(addresses); - } - /** * Adds the given output scripts to the wallet to be watched. Outputs can be retrieved by {@link #getWatchedOutputs(boolean)}. * If a script is already being watched, the object is replaced with the one in the given list. As {@link Script} @@ -1859,12 +1822,6 @@ public class Wallet extends BaseTaggableObject } } - /** @deprecated use {@link #autosaveToFile(File, Duration, WalletFiles.Listener)} */ - @Deprecated - public WalletFiles autosaveToFile(File f, long delayTime, TimeUnit timeUnit, @Nullable WalletFiles.Listener eventListener) { - return autosaveToFile(f, Duration.ofMillis(timeUnit.toMillis(delayTime)), eventListener); - } - /** *

* Disables auto-saving, after it had been enabled with @@ -3855,13 +3812,6 @@ public class Wallet extends BaseTaggableObject } } - /** @deprecated use {@link #setLastBlockSeenTime(Instant)} or {@link #clearLastBlockSeenTime()} */ - @Deprecated - public void setLastBlockSeenTimeSecs(long timeSecs) { - checkArgument(timeSecs > 0); - setLastBlockSeenTime(Instant.ofEpochSecond(timeSecs)); - } - /** * Returns time extracted from the last best seen block header, or empty. This timestamp * is not the local time at which the block was first observed by this application but rather what the block @@ -3878,12 +3828,6 @@ public class Wallet extends BaseTaggableObject } } - /** @deprecated use {@link #lastBlockSeenTime()} */ - @Deprecated - public long getLastBlockSeenTimeSecs() { - return lastBlockSeenTime().map(Instant::getEpochSecond).orElse((long) 0); - } - /** * Returns the height of the last seen best-chain block. Can be 0 if a wallet is brand new or -1 if the wallet * is old and doesn't have that data. @@ -5667,15 +5611,6 @@ public class Wallet extends BaseTaggableObject saveNow(); } - /** @deprecated use {@link #setKeyRotationTime(Instant)} */ - @Deprecated - public void setKeyRotationTime(long timeSecs) { - if (timeSecs == 0) - setKeyRotationTime((Instant) null); - else - setKeyRotationTime(Instant.ofEpochSecond(timeSecs)); - } - /** * Returns the key rotation time, or empty if unconfigured. See {@link #setKeyRotationTime(Instant)} for a description * of the field. diff --git a/core/src/main/java/org/bitcoinj/wallet/WalletFiles.java b/core/src/main/java/org/bitcoinj/wallet/WalletFiles.java index 97e51bc92..f33432b86 100644 --- a/core/src/main/java/org/bitcoinj/wallet/WalletFiles.java +++ b/core/src/main/java/org/bitcoinj/wallet/WalletFiles.java @@ -104,12 +104,6 @@ public class WalletFiles { }; } - /** @deprecated use {@link #WalletFiles(Wallet, File, Duration)} */ - @Deprecated - public WalletFiles(final Wallet wallet, File file, long delayTime, TimeUnit timeUnit) { - this(wallet, file, Duration.ofMillis(timeUnit.toMillis(delayTime))); - } - /** Get the {@link Wallet} this {@link WalletFiles} is managing. */ public Wallet getWallet() { return wallet; diff --git a/core/src/test/java/org/bitcoinj/net/discovery/DnsDiscoveryTest.java b/core/src/test/java/org/bitcoinj/net/discovery/DnsDiscoveryTest.java index 8fdd542b3..fb301ae60 100644 --- a/core/src/test/java/org/bitcoinj/net/discovery/DnsDiscoveryTest.java +++ b/core/src/test/java/org/bitcoinj/net/discovery/DnsDiscoveryTest.java @@ -22,7 +22,6 @@ import org.junit.Test; import java.net.InetSocketAddress; import java.time.Duration; import java.util.List; -import java.util.concurrent.TimeUnit; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue;