3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-11 17:55:53 +00:00

WalletTemplate: don't override default PeerGroup params as they should be appropriate out of the box. Propagate WAK startup errors to the UI.

This commit is contained in:
Mike Hearn 2015-01-21 15:48:42 +01:00
parent 101ad83906
commit 71e9a2d4b2

View File

@ -1,9 +1,9 @@
package wallettemplate;
import com.google.common.util.concurrent.*;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.params.RegTestParams;
import org.bitcoinj.params.TestNet3Params;
import org.bitcoinj.params.*;
import org.bitcoinj.utils.BriefLogFormatter;
import org.bitcoinj.utils.Threading;
import org.bitcoinj.wallet.DeterministicSeed;
@ -29,7 +29,7 @@ import static wallettemplate.utils.GuiUtils.*;
public class Main extends Application {
public static String APP_NAME = "WalletTemplate";
public static NetworkParameters params = TestNet3Params.get();
public static NetworkParameters params = MainNetParams.get();
public static WalletAppKit bitcoin;
public static Main instance;
@ -95,20 +95,23 @@ public class Main extends Application {
mainWindow.show();
bitcoin.addListener(new Service.Listener() {
@Override
public void failed(Service.State from, Throwable failure) {
GuiUtils.crashAlert(failure);
}
}, Platform::runLater);
bitcoin.startAsync();
}
public void setupWalletKit(@Nullable DeterministicSeed seed) {
// If seed is non-null it means we are restoring from backup.
bitcoin = new WalletAppKit(params, new File("."), APP_NAME) {
bitcoin = new WalletAppKit(params, new File("."), APP_NAME + "-" + params.getPaymentProtocolId()) {
@Override
protected void onSetupCompleted() {
// Don't make the user wait for confirmations for now, as the intention is they're sending it
// their own money!
bitcoin.wallet().allowSpendingUnconfirmedTransactions();
if (params != RegTestParams.get())
bitcoin.peerGroup().setMaxConnections(11);
bitcoin.peerGroup().setBloomFilterFalsePositiveRate(0.00001);
Platform.runLater(controller::onBitcoinSetup);
}
};