mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-12 10:15:52 +00:00
WalletTool: bit more cleanup.
This commit is contained in:
parent
c0617b31b2
commit
fa53806ef5
@ -53,23 +53,17 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.LogManager;
|
import java.util.logging.LogManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A command line tool for manipulating wallets and working with Bitcoin.<p>
|
* A command line tool for manipulating wallets and working with Bitcoin.
|
||||||
*/
|
*/
|
||||||
public class WalletTool {
|
public class WalletTool {
|
||||||
private static final Logger log = LoggerFactory.getLogger(WalletTool.class);
|
private static final Logger log = LoggerFactory.getLogger(WalletTool.class);
|
||||||
|
|
||||||
private static OptionSpec<String> walletFileName;
|
|
||||||
private static OptionSpec<NetworkEnum> netFlag;
|
|
||||||
private static OptionSpec<Date> dateFlag;
|
private static OptionSpec<Date> dateFlag;
|
||||||
private static OptionSpec<Integer> unixtimeFlag;
|
private static OptionSpec<Integer> unixtimeFlag;
|
||||||
private static OptionSpec<WaitForEnum> waitForFlag;
|
|
||||||
private static OptionSpec<ValidationMode> modeFlag;
|
|
||||||
private static OptionSpec<String> conditionFlag;
|
|
||||||
|
|
||||||
private static NetworkParameters params;
|
private static NetworkParameters params;
|
||||||
private static File walletFile;
|
private static File walletFile;
|
||||||
private static OptionSet options;
|
private static OptionSet options;
|
||||||
private static java.util.logging.Logger logger;
|
|
||||||
private static BlockStore store;
|
private static BlockStore store;
|
||||||
private static AbstractBlockChain chain;
|
private static AbstractBlockChain chain;
|
||||||
private static PeerGroup peers;
|
private static PeerGroup peers;
|
||||||
@ -137,7 +131,6 @@ public class WalletTool {
|
|||||||
private static Condition condition;
|
private static Condition condition;
|
||||||
|
|
||||||
public enum ActionEnum {
|
public enum ActionEnum {
|
||||||
NONE,
|
|
||||||
DUMP,
|
DUMP,
|
||||||
RAW_DUMP,
|
RAW_DUMP,
|
||||||
CREATE,
|
CREATE,
|
||||||
@ -147,14 +140,14 @@ public class WalletTool {
|
|||||||
SYNC,
|
SYNC,
|
||||||
RESET,
|
RESET,
|
||||||
SEND
|
SEND
|
||||||
};
|
}
|
||||||
|
|
||||||
public enum WaitForEnum {
|
public enum WaitForEnum {
|
||||||
EVER,
|
EVER,
|
||||||
WALLET_TX,
|
WALLET_TX,
|
||||||
BLOCK,
|
BLOCK,
|
||||||
BALANCE
|
BALANCE
|
||||||
};
|
}
|
||||||
|
|
||||||
public enum NetworkEnum {
|
public enum NetworkEnum {
|
||||||
PROD,
|
PROD,
|
||||||
@ -172,10 +165,10 @@ public class WalletTool {
|
|||||||
parser.accepts("help");
|
parser.accepts("help");
|
||||||
parser.accepts("force");
|
parser.accepts("force");
|
||||||
parser.accepts("debuglog");
|
parser.accepts("debuglog");
|
||||||
walletFileName = parser.accepts("wallet")
|
OptionSpec<String> walletFileName = parser.accepts("wallet")
|
||||||
.withRequiredArg()
|
.withRequiredArg()
|
||||||
.defaultsTo("wallet");
|
.defaultsTo("wallet");
|
||||||
netFlag = parser.accepts("net")
|
OptionSpec<NetworkEnum> netFlag = parser.accepts("net")
|
||||||
.withOptionalArg()
|
.withOptionalArg()
|
||||||
.ofType(NetworkEnum.class)
|
.ofType(NetworkEnum.class)
|
||||||
.defaultsTo(NetworkEnum.PROD);
|
.defaultsTo(NetworkEnum.PROD);
|
||||||
@ -183,10 +176,10 @@ public class WalletTool {
|
|||||||
.withRequiredArg()
|
.withRequiredArg()
|
||||||
.ofType(Date.class)
|
.ofType(Date.class)
|
||||||
.withValuesConvertedBy(DateConverter.datePattern("yyyy/MM/dd"));
|
.withValuesConvertedBy(DateConverter.datePattern("yyyy/MM/dd"));
|
||||||
waitForFlag = parser.accepts("waitfor")
|
OptionSpec<WaitForEnum> waitForFlag = parser.accepts("waitfor")
|
||||||
.withRequiredArg()
|
.withRequiredArg()
|
||||||
.ofType(WaitForEnum.class);
|
.ofType(WaitForEnum.class);
|
||||||
modeFlag = parser.accepts("mode")
|
OptionSpec<ValidationMode> modeFlag = parser.accepts("mode")
|
||||||
.withRequiredArg()
|
.withRequiredArg()
|
||||||
.ofType(ValidationMode.class)
|
.ofType(ValidationMode.class)
|
||||||
.defaultsTo(ValidationMode.SPV);
|
.defaultsTo(ValidationMode.SPV);
|
||||||
@ -200,7 +193,7 @@ public class WalletTool {
|
|||||||
parser.accepts("value").withRequiredArg();
|
parser.accepts("value").withRequiredArg();
|
||||||
parser.accepts("fee").withRequiredArg();
|
parser.accepts("fee").withRequiredArg();
|
||||||
unixtimeFlag = parser.accepts("unixtime").withRequiredArg().ofType(Integer.class);
|
unixtimeFlag = parser.accepts("unixtime").withRequiredArg().ofType(Integer.class);
|
||||||
conditionFlag = parser.accepts("condition").withRequiredArg();
|
OptionSpec<String> conditionFlag = parser.accepts("condition").withRequiredArg();
|
||||||
parser.accepts("locktime").withRequiredArg();
|
parser.accepts("locktime").withRequiredArg();
|
||||||
parser.accepts("allow-unconfirmed");
|
parser.accepts("allow-unconfirmed");
|
||||||
parser.accepts("offline");
|
parser.accepts("offline");
|
||||||
@ -230,7 +223,7 @@ public class WalletTool {
|
|||||||
log.info("Starting up ...");
|
log.info("Starting up ...");
|
||||||
} else {
|
} else {
|
||||||
// Disable logspam unless there is a flag.
|
// Disable logspam unless there is a flag.
|
||||||
logger = LogManager.getLogManager().getLogger("");
|
java.util.logging.Logger logger = LogManager.getLogManager().getLogger("");
|
||||||
logger.setLevel(Level.SEVERE);
|
logger.setLevel(Level.SEVERE);
|
||||||
}
|
}
|
||||||
switch (netFlag.value(options)) {
|
switch (netFlag.value(options)) {
|
||||||
@ -538,6 +531,7 @@ public class WalletTool {
|
|||||||
try {
|
try {
|
||||||
latch.await();
|
latch.await();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
// Ignore.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user