From 829656b1533347e97bb3e5f05576b3eee8697255 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Mon, 10 Mar 2014 17:36:32 +0100 Subject: [PATCH] Correct maven instruction in the README file and make ForwardingService work on mainnet again by fixing command line arg parsing. Resolves issue 523. --- README | 7 +++++-- .../com/google/bitcoin/examples/ForwardingService.java | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README b/README index 13b2d9e3..63e004fc 100644 --- a/README +++ b/README @@ -11,10 +11,13 @@ find your unzipped Maven install directory. Now try running one of the example apps: cd examples - mvn exec:java -Dexec.mainClass=com.google.bitcoin.examples.ForwardingService + mvn exec:java -Dexec.mainClass=com.google.bitcoin.examples.ForwardingService -Dexec.args="" It will download the block chain and eventually print a Bitcoin address. If you send coins to it, -it will forward them on to the address you specified. +it will forward them on to the address you specified. Note that this example app does not use +checkpointing, so the initial chain sync will be pretty slow. You can make an app that starts up and +does the initial sync much faster by including a checkpoints file; see the documentation for +more info on this. Now you are ready to follow the tutorial: diff --git a/examples/src/main/java/com/google/bitcoin/examples/ForwardingService.java b/examples/src/main/java/com/google/bitcoin/examples/ForwardingService.java index 065b0f2c..8fadab7c 100644 --- a/examples/src/main/java/com/google/bitcoin/examples/ForwardingService.java +++ b/examples/src/main/java/com/google/bitcoin/examples/ForwardingService.java @@ -43,7 +43,7 @@ public class ForwardingService { public static void main(String[] args) throws Exception { // This line makes the log output more compact and easily read, especially when using the JDK log adapter. BriefLogFormatter.init(); - if (args.length < 2) { + if (args.length < 1) { System.err.println("Usage: address-to-send-back-to [regtest|testnet]"); return; } @@ -51,10 +51,10 @@ public class ForwardingService { // Figure out which network we should connect to. Each one gets its own set of files. NetworkParameters params; String filePrefix; - if (args[1].equals("testnet")) { + if (args.length > 1 && args[1].equals("testnet")) { params = TestNet3Params.get(); filePrefix = "forwarding-service-testnet"; - } else if (args[1].equals("regtest")) { + } else if (args.length > 1 && args[1].equals("regtest")) { params = RegTestParams.get(); filePrefix = "forwarding-service-regtest"; } else {