From ad022f00acb48a6b3323b43c5a08e96411cd3c78 Mon Sep 17 00:00:00 2001
From: Andreas Schildbach
Date: Mon, 2 Sep 2024 13:23:37 +0200
Subject: [PATCH] remove all usages of long as Instant or Duration
---
.../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 | 23 +-----
.../org/bitcoinj/crypto/EncryptableItem.java | 7 --
.../bitcoinj/net/BlockingClientManager.java | 6 --
.../bitcoinj/net/discovery/PeerDiscovery.java | 9 ---
.../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 | 74 ++-----------------
.../java/org/bitcoinj/wallet/WalletFiles.java | 6 --
.../java/org/bitcoinj/core/BlockTest.java | 3 +-
.../org/bitcoinj/store/SPVBlockStoreTest.java | 2 +-
.../java/org/bitcoinj/wallet/WalletTest.java | 4 +-
21 files changed, 11 insertions(+), 273 deletions(-)
diff --git a/core/src/main/java/org/bitcoinj/core/Block.java b/core/src/main/java/org/bitcoinj/core/Block.java
index 3cacdd0fc0b..6422501f701 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 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 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 cb36d8fefbc..534291bf9c7 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 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();
@@ -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));
- }
}
diff --git a/core/src/main/java/org/bitcoinj/core/Peer.java b/core/src/main/java/org/bitcoinj/core/Peer.java
index 2d7274561e2..050746fcf6b 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 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
diff --git a/core/src/main/java/org/bitcoinj/core/PeerAddress.java b/core/src/main/java/org/bitcoinj/core/PeerAddress.java
index b64f45b9641..71b02c8a530 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 Instant time() {
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 12155d54583..0a9cb39bd3e 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 b83c02e5085..8c41522d602 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 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
@@ -1255,7 +1246,7 @@ public void dropAllPeers() {
*
* - So the wallet receives broadcast transactions.
* - Announcing pending transactions that didn't get into the chain yet to our peers.
- * - Set the fast catchup time using {@link PeerGroup#setFastCatchupTimeSecs(long)}, to optimize chain
+ *
- Set the fast catchup time using {@link PeerGroup#setFastCatchupTime(Instant)}, to optimize chain
* download.
*
*
@@ -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
@@ -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;
diff --git a/core/src/main/java/org/bitcoinj/crypto/EncryptableItem.java b/core/src/main/java/org/bitcoinj/crypto/EncryptableItem.java
index 3dd3d38fdd9..c5b1368b503 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/net/BlockingClientManager.java b/core/src/main/java/org/bitcoinj/net/BlockingClientManager.java
index 44b19f359fb..6ce9161ca2a 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 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 { }
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 bfe9411bfbe..d437c63eee9 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 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/script/Script.java b/core/src/main/java/org/bitcoinj/script/Script.java
index 4533750a2ef..ff6434bc92b 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 Optional 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 "<empty>".
*/
diff --git a/core/src/main/java/org/bitcoinj/testing/FakeTxBuilder.java b/core/src/main/java/org/bitcoinj/testing/FakeTxBuilder.java
index 44e2b21ec44..d229f29031a 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 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) {
@@ -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);
}
@@ -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) {
diff --git a/core/src/main/java/org/bitcoinj/utils/ExponentialBackoff.java b/core/src/main/java/org/bitcoinj/utils/ExponentialBackoff.java
index d5831b64088..72f82792718 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 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()
diff --git a/core/src/main/java/org/bitcoinj/wallet/BasicKeyChain.java b/core/src/main/java/org/bitcoinj/wallet/BasicKeyChain.java
index 7d864c73f81..8b95f05c5ea 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 Optional 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 findKeysBefore(Instant time) {
lock.lock();
@@ -674,12 +667,6 @@ public List findKeysBefore(Instant time) {
}
}
- /** @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 a3a98a57f93..3464a609123 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 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.
diff --git a/core/src/main/java/org/bitcoinj/wallet/DeterministicSeed.java b/core/src/main/java/org/bitcoinj/wallet/DeterministicSeed.java
index bc4f149c0f5..df02a40e27a 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 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 mnemonic, @Nullable Instant creationTime) {
this.seed = Objects.requireNonNull(seed);
@@ -165,23 +159,11 @@ private DeterministicSeed(byte[] seed, List 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 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 @@ 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");
@@ -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");
diff --git a/core/src/main/java/org/bitcoinj/wallet/KeyTimeCoinSelector.java b/core/src/main/java/org/bitcoinj/wallet/KeyTimeCoinSelector.java
index 5656711fe50..f82810528c6 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 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 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 de3a0300929..a7343433c25 100644
--- a/core/src/main/java/org/bitcoinj/wallet/Wallet.java
+++ b/core/src/main/java/org/bitcoinj/wallet/Wallet.java
@@ -178,7 +178,7 @@
* auto-save feature that simplifies this for you although you're still responsible for manually triggering a save when
* your app is about to quit because the auto-save feature waits a moment before actually committing to disk to avoid IO
* thrashing when the wallet is changing very fast (e.g. due to a block chain sync). See
- * {@link Wallet#autosaveToFile(File, long, TimeUnit, WalletFiles.Listener)}
+ * {@link Wallet#autosaveToFile(File, Duration, WalletFiles.Listener)}
* for more information about this.
*/
public class Wallet extends BaseTaggableObject
@@ -497,16 +497,6 @@ public static Wallet fromWatchingKeyB58(NetworkParameters params, String watchKe
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 +560,6 @@ public static Wallet fromSpendingKeyB58(NetworkParameters params, String spendin
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.
@@ -1051,7 +1031,7 @@ public boolean importKey(ECKey key) {
/**
* Imports the given keys to the wallet.
- * If {@link Wallet#autosaveToFile(File, long, TimeUnit, WalletFiles.Listener)}
+ * If {@link Wallet#autosaveToFile(File, Duration, WalletFiles.Listener)}
* has been called, triggers an auto save bypassing the normal coalescing delay and event handlers.
* Returns the number of keys added, after duplicates are ignored. The onKeyAdded event will be called for each key
* in the list that was not already present.
@@ -1172,7 +1152,7 @@ public boolean isAddressWatched(Address address) {
}
/**
- * Same as {@link #addWatchedAddress(Address, long)} with the current time as the creation time.
+ * Same as {@link #addWatchedAddress(Address, Instant)} with the current time as the creation time.
*/
public boolean addWatchedAddress(final Address address) {
Instant now = TimeUtils.currentTime();
@@ -1189,14 +1169,6 @@ public boolean addWatchedAddress(final Address address, Instant creationTime) {
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 +1200,6 @@ public int addWatchedAddresses(final List addresses) {
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}
@@ -1834,7 +1798,7 @@ public RiskAnalysis.Analyzer getRiskAnalyzer() {
* In this way disk IO can be rate limited. It's a good idea to set this as otherwise the wallet can change very
* frequently, e.g. if there are a lot of transactions in it or during block sync, and there will be a lot of redundant
* writes. Note that when a new key is added, that always results in an immediate save regardless of
- * delayTime. You should still save the wallet manually using {@link Wallet#saveToFile(File)} when your program
+ * delay. You should still save the wallet manually using {@link Wallet#saveToFile(File)} when your program
* is about to shut down as the JVM will not wait for the background thread.
*
* An event listener can be provided. It will be called on a background thread
@@ -1859,16 +1823,10 @@ public WalletFiles autosaveToFile(File f, Duration delay, @Nullable WalletFiles.
}
}
- /** @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
- * {@link Wallet#autosaveToFile(File, long, TimeUnit, WalletFiles.Listener)}
+ * {@link Wallet#autosaveToFile(File, Duration, WalletFiles.Listener)}
* before. This method blocks until finished.
*
*/
@@ -3855,13 +3813,6 @@ public void clearLastBlockSeenTime() {
}
}
- /** @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 +3829,6 @@ public Optional lastBlockSeenTime() {
}
}
- /** @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 +5612,6 @@ public void setKeyRotationTime(@Nullable Instant keyRotationTime) {
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 97e51bc9290..f33432b86b0 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 WalletFiles(final Wallet wallet, File file, Duration delay) {
};
}
- /** @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/core/BlockTest.java b/core/src/test/java/org/bitcoinj/core/BlockTest.java
index a523416c878..f9a0a5c98f0 100644
--- a/core/src/test/java/org/bitcoinj/core/BlockTest.java
+++ b/core/src/test/java/org/bitcoinj/core/BlockTest.java
@@ -312,7 +312,8 @@ public void isBIPs() throws Exception {
@Test
public void parseBlockWithHugeDeclaredTransactionsSize() {
Context.propagate(new Context(100, Transaction.DEFAULT_TX_FEE, false, true));
- Block block = new Block(1, Sha256Hash.ZERO_HASH, Sha256Hash.ZERO_HASH, 1, 1, 1, new ArrayList()) {
+ Block block = new Block(1, Sha256Hash.ZERO_HASH, Sha256Hash.ZERO_HASH, Instant.EPOCH, 1, 1,
+ new ArrayList()) {
@Override
protected void bitcoinSerializeToStream(OutputStream stream) throws IOException {
ByteUtils.writeInt32LE(getVersion(), stream);
diff --git a/core/src/test/java/org/bitcoinj/store/SPVBlockStoreTest.java b/core/src/test/java/org/bitcoinj/store/SPVBlockStoreTest.java
index 73b450c9fe7..e31b03be8f5 100644
--- a/core/src/test/java/org/bitcoinj/store/SPVBlockStoreTest.java
+++ b/core/src/test/java/org/bitcoinj/store/SPVBlockStoreTest.java
@@ -154,7 +154,7 @@ public void performanceTest() throws BlockStoreException {
Stopwatch watch = Stopwatch.start();
for (int i = 0; i < ITERATIONS; i++) {
// Using i as the nonce so that the block hashes are different.
- Block block = new Block(0, Sha256Hash.ZERO_HASH, Sha256Hash.ZERO_HASH, 0, 0, i,
+ Block block = new Block(0, Sha256Hash.ZERO_HASH, Sha256Hash.ZERO_HASH, Instant.EPOCH, 0, i,
Collections.emptyList());
StoredBlock b = new StoredBlock(block, BigInteger.ZERO, i);
store.put(b);
diff --git a/core/src/test/java/org/bitcoinj/wallet/WalletTest.java b/core/src/test/java/org/bitcoinj/wallet/WalletTest.java
index f16439287ef..e0880e1fee4 100644
--- a/core/src/test/java/org/bitcoinj/wallet/WalletTest.java
+++ b/core/src/test/java/org/bitcoinj/wallet/WalletTest.java
@@ -1708,7 +1708,7 @@ public void autosaveImmediate() throws Exception {
File f = File.createTempFile("bitcoinj-unit-test", null);
Sha256Hash hash1 = Sha256Hash.of(f);
// Start with zero delay and ensure the wallet file changes after adding a key.
- wallet.autosaveToFile(f, 0, TimeUnit.SECONDS, null);
+ wallet.autosaveToFile(f, Duration.ZERO, null);
ECKey key = wallet.freshReceiveKey();
Sha256Hash hash2 = Sha256Hash.of(f);
assertFalse("Wallet not saved after generating fresh key", hash1.equals(hash2)); // File has changed.
@@ -1729,7 +1729,7 @@ public void autosaveDelayed() throws Exception {
final CountDownLatch latch = new CountDownLatch(3);
File f = File.createTempFile("bitcoinj-unit-test", null);
Sha256Hash hash1 = Sha256Hash.of(f);
- wallet.autosaveToFile(f, 1, TimeUnit.SECONDS,
+ wallet.autosaveToFile(f, Duration.ofSeconds(1),
new WalletFiles.Listener() {
@Override
public void onBeforeAutoSave(File tempFile) {