Skip to content

Commit

Permalink
optimize imports
Browse files Browse the repository at this point in the history
  • Loading branch information
schildbach committed Aug 21, 2024
1 parent e51f163 commit ba60554
Show file tree
Hide file tree
Showing 49 changed files with 303 additions and 254 deletions.
15 changes: 7 additions & 8 deletions core/src/main/java/org/bitcoinj/base/LegacyAddress.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@

package org.bitcoinj.base;

import org.bitcoinj.base.BitcoinNetwork;
import org.bitcoinj.base.exceptions.AddressFormatException;
import org.bitcoinj.base.internal.ByteUtils;
import org.bitcoinj.crypto.ECKey;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.crypto.ECKey;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand All @@ -31,8 +32,6 @@
import java.util.Objects;
import java.util.stream.Stream;

import static org.bitcoinj.base.BitcoinNetwork.*;

/**
* <p>A Bitcoin address looks like 1MsScoe2fTJoq4ZPdQgqyhgWeoNamYPevy and is derived from an elliptic curve public key
* plus a set of network parameters. Not to be confused with a {@link org.bitcoinj.core.PeerAddress}
Expand Down Expand Up @@ -295,9 +294,9 @@ public int compareTo(Address o) {
* Address header of legacy P2PKH addresses for standard Bitcoin networks.
*/
public enum AddressHeader {
X0(0, MAINNET),
X111(111, TESTNET, REGTEST),
X6F(0x6f, SIGNET);
X0(0, BitcoinNetwork.MAINNET),
X111(111, BitcoinNetwork.TESTNET, BitcoinNetwork.REGTEST),
X6F(0x6f, BitcoinNetwork.SIGNET);

private final int headerByte;
private final EnumSet<BitcoinNetwork> networks;
Expand Down Expand Up @@ -327,8 +326,8 @@ public int headerByte() {
* Address header of legacy P2SH addresses for standard Bitcoin networks.
*/
public enum P2SHHeader {
X5(5, MAINNET),
X196(196, TESTNET, SIGNET, REGTEST);
X5(5, BitcoinNetwork.MAINNET),
X196(196, BitcoinNetwork.TESTNET, BitcoinNetwork.SIGNET, BitcoinNetwork.REGTEST);

private final int headerByte;
private final EnumSet<BitcoinNetwork> networks;
Expand Down
11 changes: 5 additions & 6 deletions core/src/main/java/org/bitcoinj/base/SegwitAddress.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@

package org.bitcoinj.base;

import org.bitcoinj.base.BitcoinNetwork;
import org.bitcoinj.base.exceptions.AddressFormatException;
import org.bitcoinj.base.internal.ByteUtils;
import org.bitcoinj.crypto.ECKey;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.crypto.ECKey;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand All @@ -30,8 +31,6 @@
import java.util.Optional;
import java.util.stream.Stream;

import static org.bitcoinj.base.BitcoinNetwork.*;

/**
* <p>Implementation of native segwit addresses. They are composed of two parts:</p>
*
Expand Down Expand Up @@ -64,9 +63,9 @@ public class SegwitAddress implements Address {
* <a href="https://github.com/bitcoin/bitcoin/issues/12314">Bitcoin Core Issue 1234 - discussion of {@code bcrt} HRP</a> for details.
*/
public enum SegwitHrp {
BC(MAINNET),
TB(TESTNET, SIGNET),
BCRT(REGTEST);
BC(BitcoinNetwork.MAINNET),
TB(BitcoinNetwork.TESTNET, BitcoinNetwork.SIGNET),
BCRT(BitcoinNetwork.REGTEST);

private final EnumSet<BitcoinNetwork> networks;

Expand Down
3 changes: 2 additions & 1 deletion core/src/test/java/org/bitcoinj/core/LockTimeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
import java.time.Instant;
import java.time.temporal.ChronoUnit;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

@RunWith(JUnitParamsRunner.class)
public class LockTimeTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/

import org.bitcoinj.base.BitcoinNetwork
import org.bitcoinj.base.Address
import org.bitcoinj.base.Coin
import org.bitcoinj.base.AddressParser
import org.bitcoinj.base.BitcoinNetwork
import org.bitcoinj.base.Coin
import org.bitcoinj.core.Context
import org.bitcoinj.core.Transaction
import org.bitcoinj.core.TransactionBroadcast
Expand Down
7 changes: 5 additions & 2 deletions examples/src/main/java/org/bitcoinj/examples/DoubleSpend.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@

import org.bitcoinj.base.Address;
import org.bitcoinj.base.BitcoinNetwork;
import org.bitcoinj.core.*;
import org.bitcoinj.core.Peer;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.utils.BriefLogFormatter;
import org.bitcoinj.utils.Threading;
import org.bitcoinj.wallet.Wallet;

import java.io.File;

import static org.bitcoinj.base.Coin.*;
import static org.bitcoinj.base.Coin.CENT;
import static org.bitcoinj.base.Coin.COIN;
import static org.bitcoinj.base.Coin.SATOSHI;

/**
* This is a little test app that waits for a coin on a local regtest node, then generates two transactions that double
Expand Down
4 changes: 2 additions & 2 deletions examples/src/main/java/org/bitcoinj/examples/DumpWallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

package org.bitcoinj.examples;

import java.io.File;

import org.bitcoinj.wallet.Wallet;

import java.io.File;

/**
* DumpWallet loads a serialized wallet and prints information about what it contains.
*/
Expand Down
8 changes: 6 additions & 2 deletions examples/src/main/java/org/bitcoinj/examples/FetchBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@
import org.bitcoinj.base.BitcoinNetwork;
import org.bitcoinj.base.Network;
import org.bitcoinj.base.Sha256Hash;
import org.bitcoinj.core.*;
import org.bitcoinj.core.Block;
import org.bitcoinj.core.BlockChain;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.Peer;
import org.bitcoinj.core.PeerAddress;
import org.bitcoinj.core.PeerGroup;
import org.bitcoinj.net.discovery.DnsDiscovery;
import org.bitcoinj.store.BlockStore;
import org.bitcoinj.store.MemoryBlockStore;
import org.bitcoinj.utils.BriefLogFormatter;
import picocli.CommandLine;

import java.net.InetAddress;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@
import org.bitcoinj.base.BitcoinNetwork;
import org.bitcoinj.base.Network;
import org.bitcoinj.base.Sha256Hash;
import org.bitcoinj.core.*;
import org.bitcoinj.core.BlockChain;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.Peer;
import org.bitcoinj.core.PeerAddress;
import org.bitcoinj.core.PeerGroup;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.store.BlockStore;
import org.bitcoinj.store.MemoryBlockStore;
import org.bitcoinj.utils.BriefLogFormatter;

import java.net.InetAddress;
import java.util.List;
import java.util.concurrent.Future;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@

package org.bitcoinj.examples;

import org.bitcoinj.base.BitcoinNetwork;
import org.bitcoinj.base.Address;
import org.bitcoinj.base.Coin;
import org.bitcoinj.base.AddressParser;
import org.bitcoinj.base.BitcoinNetwork;
import org.bitcoinj.base.Coin;
import org.bitcoinj.core.Context;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.core.TransactionBroadcast;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.utils.BriefLogFormatter;
import org.bitcoinj.wallet.CoinSelection;
import org.bitcoinj.wallet.CoinSelector;
import org.bitcoinj.wallet.SendRequest;
import org.bitcoinj.wallet.Wallet;
Expand All @@ -36,9 +35,6 @@
import java.util.Objects;
import java.util.concurrent.CompletableFuture;

import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toList;

/**
* ForwardingService demonstrates basic usage of bitcoinj. It creates an SPV Wallet, listens on the network
* and when it receives coins, simply sends them onwards to the address given on the command line.
Expand Down
24 changes: 12 additions & 12 deletions examples/src/main/java/org/bitcoinj/examples/GenerateLowSTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,36 @@

package org.bitcoinj.examples;

import java.io.IOException;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.EnumSet;
import java.util.Objects;

import org.bitcoinj.base.BitcoinNetwork;
import org.bitcoinj.base.Coin;
import org.bitcoinj.base.Network;
import org.bitcoinj.base.ScriptType;
import org.bitcoinj.base.internal.ByteUtils;
import org.bitcoinj.base.Coin;
import org.bitcoinj.crypto.ECKey;
import org.bitcoinj.crypto.SignatureDecodeException;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.core.TransactionInput;
import org.bitcoinj.core.TransactionOutput;
import org.bitcoinj.core.VerificationException;
import org.bitcoinj.crypto.ECKey;
import org.bitcoinj.crypto.SignatureDecodeException;
import org.bitcoinj.crypto.TransactionSignature;
import org.bitcoinj.script.Script;
import org.bitcoinj.script.ScriptBuilder;
import org.bitcoinj.script.ScriptChunk;
import org.bitcoinj.script.ScriptException;

import static org.bitcoinj.script.ScriptOpCodes.getOpCodeName;
import org.bitcoinj.signers.LocalTransactionSigner;
import org.bitcoinj.signers.TransactionSigner.ProposedTransaction;
import org.bitcoinj.wallet.KeyBag;
import org.bitcoinj.wallet.RedeemData;

import java.io.IOException;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.EnumSet;
import java.util.Objects;

import static org.bitcoinj.script.ScriptOpCodes.getOpCodeName;

/**
* Test case generator for transactions with low-S and high-S signatures, to
* test the LOW_S script validation flag.
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/java/org/bitcoinj/examples/Kit.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.bitcoinj.examples;

import org.bitcoinj.base.BitcoinNetwork;
import org.bitcoinj.core.*;
import org.bitcoinj.core.TransactionConfidence;
import org.bitcoinj.kits.WalletAppKit;

import java.io.File;
Expand Down
17 changes: 14 additions & 3 deletions examples/src/main/java/org/bitcoinj/examples/PeerMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,31 @@
package org.bitcoinj.examples;

import org.bitcoinj.base.BitcoinNetwork;
import org.bitcoinj.base.Coin;
import org.bitcoinj.base.Network;
import org.bitcoinj.core.AddressMessage;
import org.bitcoinj.base.Coin;
import org.bitcoinj.core.Peer;
import org.bitcoinj.core.PeerAddress;
import org.bitcoinj.core.PeerGroup;
import org.bitcoinj.net.discovery.DnsDiscovery;
import org.bitcoinj.utils.BriefLogFormatter;

import javax.swing.*;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
import javax.swing.JTable;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.time.Duration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import org.bitcoinj.core.Peer;
import org.bitcoinj.core.PeerAddress;
import org.bitcoinj.core.VersionMessage;
import org.bitcoinj.net.NioClientManager;
import org.bitcoinj.net.discovery.DnsDiscovery;
import org.bitcoinj.net.discovery.PeerDiscoveryException;
import org.bitcoinj.net.NioClientManager;
import org.bitcoinj.utils.BriefLogFormatter;

import java.net.InetAddress;
Expand Down
9 changes: 4 additions & 5 deletions examples/src/main/java/org/bitcoinj/examples/PrivateKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,21 @@

package org.bitcoinj.examples;

import org.bitcoinj.base.Address;
import org.bitcoinj.base.Base58;
import org.bitcoinj.base.BitcoinNetwork;
import org.bitcoinj.base.Network;
import org.bitcoinj.base.ScriptType;
import org.bitcoinj.base.Address;
import org.bitcoinj.base.Base58;
import org.bitcoinj.core.BlockChain;
import org.bitcoinj.crypto.DumpedPrivateKey;
import org.bitcoinj.crypto.ECKey;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.PeerAddress;
import org.bitcoinj.core.PeerGroup;
import org.bitcoinj.crypto.DumpedPrivateKey;
import org.bitcoinj.crypto.ECKey;
import org.bitcoinj.store.MemoryBlockStore;
import org.bitcoinj.wallet.Wallet;

import java.math.BigInteger;
import java.net.InetAddress;

/**
* This example shows how to solve the challenge Hal posted here:<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
import org.bitcoinj.base.BitcoinNetwork;
import org.bitcoinj.base.Coin;
import org.bitcoinj.base.Network;
import org.bitcoinj.core.*;
import org.bitcoinj.core.BlockChain;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.PeerGroup;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.store.BlockStore;
import org.bitcoinj.store.MemoryBlockStore;
import org.bitcoinj.wallet.Wallet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
import org.bitcoinj.base.BitcoinNetwork;
import org.bitcoinj.base.Network;
import org.bitcoinj.base.ScriptType;
import org.bitcoinj.core.BlockChain;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.PeerGroup;
import org.bitcoinj.core.listeners.DownloadProgressTracker;
import org.bitcoinj.core.*;
import org.bitcoinj.net.discovery.DnsDiscovery;
import org.bitcoinj.store.SPVBlockStore;
import org.bitcoinj.wallet.DeterministicSeed;
import org.bitcoinj.wallet.KeyChainGroupStructure;
import org.bitcoinj.wallet.Wallet;

import java.io.File;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.bitcoinj.base.Address;
import org.bitcoinj.base.BitcoinNetwork;
import org.bitcoinj.base.Coin;
import org.bitcoinj.core.*;
import org.bitcoinj.core.InsufficientMoneyException;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.wallet.Wallet;
import org.bitcoinj.wallet.Wallet.BalanceType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.bitcoinj.testing.TestWithNetworkConnections;
import org.bitcoinj.utils.Threading;
import org.bitcoinj.wallet.Wallet;
import org.checkerframework.checker.units.qual.A;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package org.bitcoinj.examples;

import org.bitcoinj.base.Address;
import org.bitcoinj.base.BitcoinNetwork;
import org.bitcoinj.base.ScriptType;
import org.bitcoinj.base.Address;
import org.bitcoinj.core.Context;
import org.bitcoinj.crypto.ECKey;
import org.junit.jupiter.api.BeforeEach;
Expand Down
Loading

0 comments on commit ba60554

Please sign in to comment.