当前位置: 首页>>代码示例>>Java>>正文


Java WalletAppKit.setCheckpoints方法代码示例

本文整理汇总了Java中com.google.bitcoin.kits.WalletAppKit.setCheckpoints方法的典型用法代码示例。如果您正苦于以下问题:Java WalletAppKit.setCheckpoints方法的具体用法?Java WalletAppKit.setCheckpoints怎么用?Java WalletAppKit.setCheckpoints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.bitcoin.kits.WalletAppKit的用法示例。


在下文中一共展示了WalletAppKit.setCheckpoints方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import com.google.bitcoin.kits.WalletAppKit; //导入方法依赖的package包/类
private void init(Stage mainWindow) throws IOException {
    if (System.getProperty("os.name").toLowerCase().contains("mac")) {
        AquaFx.style();
    }
    // Load the GUI. The Controller class will be automagically created and wired up.
    URL location = getClass().getResource("main.fxml");
    FXMLLoader loader = new FXMLLoader(location);
    mainUI = loader.load();
    Controller controller = loader.getController();
    // Configure the window with a StackPane so we can overlay things on top of the main UI.
    uiStack = new StackPane(mainUI);
    mainWindow.setTitle(APP_NAME);
    final Scene scene = new Scene(uiStack);
    TextFieldValidator.configureScene(scene);   // Add CSS that we need.
    mainWindow.setScene(scene);

    // Make log output concise.
    BriefLogFormatter.init();
    // Tell bitcoinj to run event handlers on the JavaFX UI thread. This keeps things simple and means
    // we cannot forget to switch threads when adding event handlers. Unfortunately, the DownloadListener
    // we give to the app kit is currently an exception and runs on a library thread. It'll get fixed in
    // a future version.
    Threading.USER_THREAD = Platform::runLater;
    // Create the app kit. It won't do any heavyweight initialization until after we start it.
    bitcoin = new WalletAppKit(params, new File("."), APP_NAME);
    if (params == RegTestParams.get()) {
        bitcoin.connectToLocalHost();   // You should run a regtest mode bitcoind locally.
    } else if (params == MainNetParams.get()) {
        // Checkpoints are block headers that ship inside our app: for a new user, we pick the last header
        // in the checkpoints file and then download the rest from the network. It makes things much faster.
        // Checkpoint files are made using the BuildCheckpoints tool and usually we have to download the
        // last months worth or more (takes a few seconds).
        bitcoin.setCheckpoints(getClass().getResourceAsStream("checkpoints"));
    }

    // Now configure and start the appkit. This will take a second or two - we could show a temporary splash screen
    // or progress widget to keep the user engaged whilst we initialise, but we don't.
    bitcoin.setDownloadListener(controller.progressBarUpdater())
           .setBlockingStartup(false)
           .setUserAgent(APP_NAME, "1.0")
           .startAndWait();
    // Don't make the user wait for confirmations for now, as the intention is they're sending it their own money!
    bitcoin.wallet().allowSpendingUnconfirmedTransactions();
    bitcoin.peerGroup().setMaxConnections(11);
    System.out.println(bitcoin.wallet());
    controller.onBitcoinSetup();
    mainWindow.show();
}
 
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:49,代码来源:Main.java

示例2: init

import com.google.bitcoin.kits.WalletAppKit; //导入方法依赖的package包/类
private void init(Stage mainWindow) throws IOException {
    if (System.getProperty("os.name").toLowerCase().contains("mac")) {
        AquaFx.style();
    }
    // Load the GUI. The Controller class will be automagically created and wired up.
    URL location = getClass().getResource("main.fxml");
    FXMLLoader loader = new FXMLLoader(location);
    mainUI = loader.load();
    Controller controller = loader.getController();
    // Configure the window with a StackPane so we can overlay things on top of the main UI.
    uiStack = new StackPane(mainUI);
    mainWindow.setTitle(APP_NAME);
    final Scene scene = new Scene(uiStack);
    TextFieldValidator.configureScene(scene);   // Add CSS that we need.
    mainWindow.setScene(scene);

    // Make log output concise.
    BriefLogFormatter.init();
    // Tell bitcoinj to run event handlers on the JavaFX UI thread. This keeps things simple and means
    // we cannot forget to switch threads when adding event handlers. Unfortunately, the DownloadListener
    // we give to the app kit is currently an exception and runs on a library thread. It'll get fixed in
    // a future version.
    Threading.USER_THREAD = Platform::runLater;
    // Create the app kit. It won't do any heavyweight initialization until after we start it.
    bitcoin = new WalletAppKit(params, new File("."), APP_NAME);
    if (params == RegTestParams.get()) {
        bitcoin.connectToLocalHost();   // You should run a regtest mode bitcoind locally.
    } else if (params == MainNetParams.get()) {
        // Checkpoints are block headers that ship inside our app: for a new user, we pick the last header
        // in the checkpoints file and then download the rest from the network. It makes things much faster.
        // Checkpoint files are made using the BuildCheckpoints tool and usually we have to download the
        // last months worth or more (takes a few seconds).
        bitcoin.setCheckpoints(getClass().getResourceAsStream("checkpoints"));
        // As an example!
        bitcoin.useTor();
    }

    // Now configure and start the appkit. This will take a second or two - we could show a temporary splash screen
    // or progress widget to keep the user engaged whilst we initialise, but we don't.
    bitcoin.setDownloadListener(controller.progressBarUpdater())
           .setBlockingStartup(false)
           .setUserAgent(APP_NAME, "1.0");
    bitcoin.startAsync();
    bitcoin.awaitRunning();
    // Don't make the user wait for confirmations for now, as the intention is they're sending it their own money!
    bitcoin.wallet().allowSpendingUnconfirmedTransactions();
    bitcoin.peerGroup().setMaxConnections(11);
    System.out.println(bitcoin.wallet());
    controller.onBitcoinSetup();
    mainWindow.show();
}
 
开发者ID:HashEngineering,项目名称:quarkcoinj,代码行数:52,代码来源:Main.java


注:本文中的com.google.bitcoin.kits.WalletAppKit.setCheckpoints方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。