mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-01-18 13:22:42 +01:00
examples/tools: use explicit script type and wallet structure
* Explicitly use P2WPKH (this changes behavior to segwit) * Explicitly use BIP32 (this is the same behavior as before)
This commit is contained in:
parent
bd775eafad
commit
c3896e6caf
@ -20,8 +20,10 @@ import org.bitcoinj.core.listeners.PreMessageReceivedEventListener;
|
||||
import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.kits.WalletAppKit;
|
||||
import org.bitcoinj.params.RegTestParams;
|
||||
import org.bitcoinj.script.Script;
|
||||
import org.bitcoinj.utils.BriefLogFormatter;
|
||||
import org.bitcoinj.utils.Threading;
|
||||
import org.bitcoinj.wallet.KeyChainGroupStructure;
|
||||
import org.bitcoinj.wallet.Wallet;
|
||||
|
||||
import java.io.File;
|
||||
@ -37,7 +39,7 @@ public class DoubleSpend {
|
||||
public static void main(String[] args) throws Exception {
|
||||
BriefLogFormatter.init();
|
||||
final RegTestParams params = RegTestParams.get();
|
||||
WalletAppKit kit = new WalletAppKit(params, new File("."), "doublespend");
|
||||
WalletAppKit kit = new WalletAppKit(params, Script.ScriptType.P2WPKH, KeyChainGroupStructure.BIP32, new File("."), "doublespend");
|
||||
kit.connectToLocalHost();
|
||||
kit.setAutoSave(false);
|
||||
kit.startAsync();
|
||||
|
@ -29,7 +29,9 @@ import org.bitcoinj.kits.WalletAppKit;
|
||||
import org.bitcoinj.params.MainNetParams;
|
||||
import org.bitcoinj.params.RegTestParams;
|
||||
import org.bitcoinj.params.TestNet3Params;
|
||||
import org.bitcoinj.script.Script;
|
||||
import org.bitcoinj.utils.BriefLogFormatter;
|
||||
import org.bitcoinj.wallet.KeyChainGroupStructure;
|
||||
import org.bitcoinj.wallet.SendRequest;
|
||||
import org.bitcoinj.wallet.Wallet;
|
||||
import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
|
||||
@ -78,7 +80,7 @@ public class ForwardingService {
|
||||
System.out.println("Forwarding address: " + forwardingAddress);
|
||||
|
||||
// Start up a basic app using a class that automates some boilerplate.
|
||||
kit = new WalletAppKit(params, new File("."), filePrefix);
|
||||
kit = new WalletAppKit(params, Script.ScriptType.P2WPKH, KeyChainGroupStructure.BIP32, new File("."), filePrefix);
|
||||
|
||||
if (params == RegTestParams.get()) {
|
||||
// Regression test mode is designed for testing and development only, so there's no public network for it.
|
||||
|
@ -20,6 +20,7 @@ import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.kits.WalletAppKit;
|
||||
import org.bitcoinj.params.TestNet3Params;
|
||||
import org.bitcoinj.script.Script;
|
||||
import org.bitcoinj.wallet.KeyChainGroupStructure;
|
||||
import org.bitcoinj.wallet.Wallet;
|
||||
import org.bitcoinj.wallet.listeners.KeyChainEventListener;
|
||||
import org.bitcoinj.wallet.listeners.ScriptsChangeEventListener;
|
||||
@ -55,7 +56,7 @@ public class Kit {
|
||||
|
||||
// Now we initialize a new WalletAppKit. The kit handles all the boilerplate for us and is the easiest way to get everything up and running.
|
||||
// Have a look at the WalletAppKit documentation and its source to understand what's happening behind the scenes: https://github.com/bitcoinj/bitcoinj/blob/master/core/src/main/java/org/bitcoinj/kits/WalletAppKit.java
|
||||
WalletAppKit kit = new WalletAppKit(params, new File("."), "walletappkit-example");
|
||||
WalletAppKit kit = new WalletAppKit(params, Script.ScriptType.P2WPKH, KeyChainGroupStructure.BIP32, new File("."), "walletappkit-example");
|
||||
|
||||
// In case you want to connect with your local bitcoind tell the kit to connect to localhost.
|
||||
// You must do that in reg test mode.
|
||||
|
@ -19,6 +19,8 @@ package org.bitcoinj.examples;
|
||||
import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.kits.WalletAppKit;
|
||||
import org.bitcoinj.params.TestNet3Params;
|
||||
import org.bitcoinj.script.Script;
|
||||
import org.bitcoinj.wallet.KeyChainGroupStructure;
|
||||
import org.bitcoinj.wallet.Wallet;
|
||||
import org.bitcoinj.wallet.Wallet.BalanceType;
|
||||
|
||||
@ -34,7 +36,7 @@ public class SendRequest {
|
||||
|
||||
// We use the WalletAppKit that handles all the boilerplate for us. Have a look at the Kit.java example for more details.
|
||||
NetworkParameters params = TestNet3Params.get();
|
||||
WalletAppKit kit = new WalletAppKit(params, new File("."), "sendrequest-example");
|
||||
WalletAppKit kit = new WalletAppKit(params, Script.ScriptType.P2WPKH, KeyChainGroupStructure.BIP32, new File("."), "sendrequest-example");
|
||||
kit.startAsync();
|
||||
kit.awaitRunning();
|
||||
|
||||
|
@ -21,7 +21,9 @@ import org.bitcoinj.core.listeners.PeerConnectedEventListener;
|
||||
import org.bitcoinj.core.listeners.PeerDisconnectedEventListener;
|
||||
import org.bitcoinj.kits.WalletAppKit;
|
||||
import org.bitcoinj.params.MainNetParams;
|
||||
import org.bitcoinj.script.Script;
|
||||
import org.bitcoinj.utils.BriefLogFormatter;
|
||||
import org.bitcoinj.wallet.KeyChainGroupStructure;
|
||||
import org.bitcoinj.wallet.SendRequest;
|
||||
import org.bitcoinj.wallet.Wallet;
|
||||
|
||||
@ -47,7 +49,7 @@ public class TestFeeLevel {
|
||||
Coin feeRateToTest = Coin.valueOf(Long.parseLong(args[0]));
|
||||
System.out.println("Fee rate to test is " + feeRateToTest.toFriendlyString() + "/kB");
|
||||
|
||||
kit = new WalletAppKit(PARAMS, new File("."), "testfeelevel");
|
||||
kit = new WalletAppKit(PARAMS, Script.ScriptType.P2WPKH, KeyChainGroupStructure.BIP32, new File("."), "testfeelevel");
|
||||
kit.startAsync();
|
||||
kit.awaitRunning();
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user