mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-10 17:26:28 +01:00
WalletTool: use net
over params
where possible
Note that `params` is initialized from `net`.
This commit is contained in:
parent
04ff5335cf
commit
23d1ce97b5
1 changed files with 6 additions and 7 deletions
|
@ -24,7 +24,6 @@ import org.bitcoinj.crypto.AesKey;
|
||||||
import org.bitcoinj.base.internal.ByteUtils;
|
import org.bitcoinj.base.internal.ByteUtils;
|
||||||
import org.bitcoinj.core.TransactionOutput;
|
import org.bitcoinj.core.TransactionOutput;
|
||||||
import org.bitcoinj.crypto.*;
|
import org.bitcoinj.crypto.*;
|
||||||
import org.bitcoinj.params.RegTestParams;
|
|
||||||
import org.bitcoinj.protocols.payments.PaymentProtocol;
|
import org.bitcoinj.protocols.payments.PaymentProtocol;
|
||||||
import org.bitcoinj.protocols.payments.PaymentProtocolException;
|
import org.bitcoinj.protocols.payments.PaymentProtocolException;
|
||||||
import org.bitcoinj.protocols.payments.PaymentSession;
|
import org.bitcoinj.protocols.payments.PaymentSession;
|
||||||
|
@ -555,7 +554,7 @@ public class WalletTool implements Callable<Integer> {
|
||||||
String[] xpubkeys = xpubKeysStr.split(",");
|
String[] xpubkeys = xpubKeysStr.split(",");
|
||||||
List<DeterministicKey> keys = new ArrayList<>();
|
List<DeterministicKey> keys = new ArrayList<>();
|
||||||
for (String xpubkey : xpubkeys) {
|
for (String xpubkey : xpubkeys) {
|
||||||
keys.add(DeterministicKey.deserializeB58(null, xpubkey.trim(), params));
|
keys.add(DeterministicKey.deserializeB58(null, xpubkey.trim(), net));
|
||||||
}
|
}
|
||||||
MarriedKeyChain chain = MarriedKeyChain.builder()
|
MarriedKeyChain chain = MarriedKeyChain.builder()
|
||||||
.random(new SecureRandom())
|
.random(new SecureRandom())
|
||||||
|
@ -639,7 +638,7 @@ public class WalletTool implements Callable<Integer> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Address address = LegacyAddress.fromBase58(addrStr, params.network());
|
Address address = LegacyAddress.fromBase58(addrStr, net);
|
||||||
// If no creation time is specified, assume genesis (zero).
|
// If no creation time is specified, assume genesis (zero).
|
||||||
getCreationTime().ifPresentOrElse(
|
getCreationTime().ifPresentOrElse(
|
||||||
creationTime -> wallet.addWatchedAddress(address, creationTime),
|
creationTime -> wallet.addWatchedAddress(address, creationTime),
|
||||||
|
@ -1016,7 +1015,7 @@ public class WalletTool implements Callable<Integer> {
|
||||||
peerGroup = new PeerGroup(net, chain);
|
peerGroup = new PeerGroup(net, chain);
|
||||||
}
|
}
|
||||||
peerGroup.setUserAgent("WalletTool", "1.0");
|
peerGroup.setUserAgent("WalletTool", "1.0");
|
||||||
if (params == RegTestParams.get())
|
if (net == BitcoinNetwork.REGTEST)
|
||||||
peerGroup.setMinBroadcastConnections(1);
|
peerGroup.setMinBroadcastConnections(1);
|
||||||
peerGroup.addWallet(wallet);
|
peerGroup.addWallet(wallet);
|
||||||
if (peersStr != null) {
|
if (peersStr != null) {
|
||||||
|
@ -1132,7 +1131,7 @@ public class WalletTool implements Callable<Integer> {
|
||||||
Optional<Instant> creationTime = getCreationTime();
|
Optional<Instant> creationTime = getCreationTime();
|
||||||
if (privKeyStr != null) {
|
if (privKeyStr != null) {
|
||||||
try {
|
try {
|
||||||
DumpedPrivateKey dpk = DumpedPrivateKey.fromBase58(params.network(), privKeyStr); // WIF
|
DumpedPrivateKey dpk = DumpedPrivateKey.fromBase58(net, privKeyStr); // WIF
|
||||||
key = dpk.getKey();
|
key = dpk.getKey();
|
||||||
} catch (AddressFormatException e) {
|
} catch (AddressFormatException e) {
|
||||||
byte[] decode = parseAsHexOrBase58(privKeyStr);
|
byte[] decode = parseAsHexOrBase58(privKeyStr);
|
||||||
|
@ -1174,9 +1173,9 @@ public class WalletTool implements Callable<Integer> {
|
||||||
if (!key.isCompressed())
|
if (!key.isCompressed())
|
||||||
System.out.println("WARNING: Importing an uncompressed key");
|
System.out.println("WARNING: Importing an uncompressed key");
|
||||||
wallet.importKey(key);
|
wallet.importKey(key);
|
||||||
System.out.print("Addresses: " + key.toAddress(ScriptType.P2PKH, params.network()));
|
System.out.print("Addresses: " + key.toAddress(ScriptType.P2PKH, net));
|
||||||
if (key.isCompressed())
|
if (key.isCompressed())
|
||||||
System.out.print("," + key.toAddress(ScriptType.P2WPKH, params.network()));
|
System.out.print("," + key.toAddress(ScriptType.P2WPKH, net));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue