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


Java WalletAppKit.awaitTerminated方法代码示例

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


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

示例1: main

import org.bitcoinj.kits.WalletAppKit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    BriefLogFormatter.init();
    if (args.length == 0) {
        System.err.println("Specify the fee level to test in satoshis as the first argument.");
        return;
    }

    Coin feeToTest = Coin.valueOf(Long.parseLong(args[0]));

    kit = new WalletAppKit(PARAMS, new File("."), "testfeelevel");
    kit.startAsync();
    kit.awaitRunning();
    try {
        go(feeToTest);
    } finally {
        kit.stopAsync();
        kit.awaitTerminated();
    }
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:20,代码来源:TestFeeLevel.java

示例2: main

import org.bitcoinj.kits.WalletAppKit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    BriefLogFormatter.initWithSilentBitcoinJ();
    if (args.length == 0) {
        System.err.println("Specify the fee level to test in satoshis as the first argument.");
        return;
    }

    Coin feeToTest = Coin.valueOf(Long.parseLong(args[0]));
    System.out.println("Fee to test is " + feeToTest.toFriendlyString());

    kit = new WalletAppKit(PARAMS, new File("."), "testfeelevel");
    kit.startAsync();
    kit.awaitRunning();
    try {
        go(feeToTest, NUM_OUTPUTS);
    } finally {
        kit.stopAsync();
        kit.awaitTerminated();
    }
}
 
开发者ID:HashEngineering,项目名称:dashj,代码行数:21,代码来源:TestFeeLevel.java

示例3: main

import org.bitcoinj.kits.WalletAppKit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    BriefLogFormatter.initWithSilentBitcoinJ();
    if (args.length == 0) {
        System.err.println("Specify the fee rate to test in satoshis/kB as the first argument.");
        return;
    }

    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.startAsync();
    kit.awaitRunning();
    try {
        go(feeRateToTest, NUM_OUTPUTS);
    } finally {
        kit.stopAsync();
        kit.awaitTerminated();
    }
}
 
开发者ID:bitcoinj,项目名称:bitcoinj,代码行数:21,代码来源:TestFeeLevel.java

示例4: run

import org.bitcoinj.kits.WalletAppKit; //导入方法依赖的package包/类
public void run(final String host) throws Exception {
    // Bring up all the objects we need, create/load a wallet, sync the chain, etc. We override WalletAppKit so we
    // can customize it by adding the extension objects - we have to do this before the wallet file is loaded so
    // the plugin that knows how to parse all the additional data is present during the load.
    appKit = new WalletAppKit(params, new File("."), "payment_channel_example_client") {
        @Override
        protected List<WalletExtension> provideWalletExtensions() {
            // The StoredPaymentChannelClientStates object is responsible for, amongst other things, broadcasting
            // the refund transaction if its lock time has expired. It also persists channels so we can resume them
            // after a restart.
            return ImmutableList.<WalletExtension>of(new StoredPaymentChannelClientStates(null, peerGroup()));
        }
    };
    appKit.connectToLocalHost();
    appKit.startAsync();
    appKit.awaitRunning();
    // We now have active network connections and a fully synced wallet.
    // Add a new key which will be used for the multisig contract.
    appKit.wallet().importKey(myKey);
    appKit.wallet().allowSpendingUnconfirmedTransactions();

    System.out.println(appKit.wallet());

    // Create the object which manages the payment channels protocol, client side. Tell it where the server to
    // connect to is, along with some reasonable network timeouts, the wallet and our temporary key. We also have
    // to pick an amount of value to lock up for the duration of the channel.
    //
    // Note that this may or may not actually construct a new channel. If an existing unclosed channel is found in
    // the wallet, then it'll re-use that one instead.
    final int timeoutSecs = 15;
    final InetSocketAddress server = new InetSocketAddress(host, 4242);

    waitForSufficientBalance(channelSize);
    final String channelID = host;
    // Do this twice as each one sends 1/10th of a bitcent 5 times, so to send a bitcent, we do it twice. This
    // demonstrates resuming a channel that wasn't closed yet. It should close automatically once we run out
    // of money on the channel.
    log.info("Round one ...");
    openAndSend(timeoutSecs, server, channelID, 5);
    log.info("Round two ...");
    log.info(appKit.wallet().toString());
    openAndSend(timeoutSecs, server, channelID, 4);   // 4 times because the opening of the channel made a payment.
    log.info("Stopping ...");
    appKit.stopAsync();
    appKit.awaitTerminated();
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:47,代码来源:ExamplePaymentChannelClient.java

示例5: run

import org.bitcoinj.kits.WalletAppKit; //导入方法依赖的package包/类
public void run(final String host) throws Exception {
    // Bring up all the objects we need, create/load a wallet, sync the chain, etc. We override WalletAppKit so we
    // can customize it by adding the extension objects - we have to do this before the wallet file is loaded so
    // the plugin that knows how to parse all the additional data is present during the load.
    appKit = new WalletAppKit(params, new File("."), "payment_channel_example_client") {
        @Override
        protected List<WalletExtension> provideWalletExtensions() {
            // The StoredPaymentChannelClientStates object is responsible for, amongst other things, broadcasting
            // the refund transaction if its lock time has expired. It also persists channels so we can resume them
            // after a restart.
            // We should not send a PeerGroup in the StoredPaymentChannelClientStates constructor
            // since WalletAppKit will find it for us.
            return ImmutableList.<WalletExtension>of(new StoredPaymentChannelClientStates(null));
        }
    };
    appKit.connectToLocalHost();
    appKit.startAsync();
    appKit.awaitRunning();
    // We now have active network connections and a fully synced wallet.
    // Add a new key which will be used for the multisig contract.
    appKit.wallet().importKey(myKey);
    appKit.wallet().allowSpendingUnconfirmedTransactions();

    System.out.println(appKit.wallet());

    // Create the object which manages the payment channels protocol, client side. Tell it where the server to
    // connect to is, along with some reasonable network timeouts, the wallet and our temporary key. We also have
    // to pick an amount of value to lock up for the duration of the channel.
    //
    // Note that this may or may not actually construct a new channel. If an existing unclosed channel is found in
    // the wallet, then it'll re-use that one instead.
    final int timeoutSecs = 15;
    final InetSocketAddress server = new InetSocketAddress(host, 4242);

    waitForSufficientBalance(channelSize);
    final String channelID = host;
    // Do this twice as each one sends 1/10th of a bitcent 5 times, so to send a bitcent, we do it twice. This
    // demonstrates resuming a channel that wasn't closed yet. It should close automatically once we run out
    // of money on the channel.
    log.info("Round one ...");
    openAndSend(timeoutSecs, server, channelID, 5);
    log.info("Round two ...");
    log.info(appKit.wallet().toString());
    openAndSend(timeoutSecs, server, channelID, 4);   // 4 times because the opening of the channel made a payment.
    log.info("Stopping ...");
    appKit.stopAsync();
    appKit.awaitTerminated();
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:49,代码来源:ExamplePaymentChannelClient.java

示例6: run

import org.bitcoinj.kits.WalletAppKit; //导入方法依赖的package包/类
public void run(final String host, PaymentChannelClient.VersionSelector versionSelector, final NetworkParameters params) throws Exception {
    // Bring up all the objects we need, create/load a wallet, sync the chain, etc. We override WalletAppKit so we
    // can customize it by adding the extension objects - we have to do this before the wallet file is loaded so
    // the plugin that knows how to parse all the additional data is present during the load.
    appKit = new WalletAppKit(params, new File("."), "payment_channel_example_client") {
        @Override
        protected List<WalletExtension> provideWalletExtensions() {
            // The StoredPaymentChannelClientStates object is responsible for, amongst other things, broadcasting
            // the refund transaction if its lock time has expired. It also persists channels so we can resume them
            // after a restart.
            // We should not send a PeerGroup in the StoredPaymentChannelClientStates constructor
            // since WalletAppKit will find it for us.
            return ImmutableList.<WalletExtension>of(new StoredPaymentChannelClientStates(null));
        }
    };
    // Broadcasting can take a bit of time so we up the timeout for "real" networks
    final int timeoutSeconds = params.getId().equals(NetworkParameters.ID_REGTEST) ? 15 : 150;
    if (params == RegTestParams.get()) {
        appKit.connectToLocalHost();
    }
    appKit.startAsync();
    appKit.awaitRunning();
    // We now have active network connections and a fully synced wallet.
    // Add a new key which will be used for the multisig contract.
    appKit.wallet().importKey(myKey);
    appKit.wallet().allowSpendingUnconfirmedTransactions();

    System.out.println(appKit.wallet());

    // Create the object which manages the payment channels protocol, client side. Tell it where the server to
    // connect to is, along with some reasonable network timeouts, the wallet and our temporary key. We also have
    // to pick an amount of value to lock up for the duration of the channel.
    //
    // Note that this may or may not actually construct a new channel. If an existing unclosed channel is found in
    // the wallet, then it'll re-use that one instead.
    final InetSocketAddress server = new InetSocketAddress(host, 4242);

    waitForSufficientBalance(channelSize);
    final String channelID = host;
    // Do this twice as each one sends 1/10th of a bitcent 5 times, so to send a bitcent, we do it twice. This
    // demonstrates resuming a channel that wasn't closed yet. It should close automatically once we run out
    // of money on the channel.
    log.info("Round one ...");
    openAndSend(timeoutSeconds, server, channelID, 5, versionSelector);
    log.info("Round two ...");
    log.info(appKit.wallet().toString());
    openAndSend(timeoutSeconds, server, channelID, 4, versionSelector);   // 4 times because the opening of the channel made a payment.
    log.info("Stopping ...");
    appKit.stopAsync();
    appKit.awaitTerminated();
}
 
开发者ID:HashEngineering,项目名称:dashj,代码行数:52,代码来源:ExamplePaymentChannelClient.java

示例7: run

import org.bitcoinj.kits.WalletAppKit; //导入方法依赖的package包/类
public void run(final String host, IPaymentChannelClient.ClientChannelProperties clientChannelProperties, final NetworkParameters params) throws Exception {
    // Bring up all the objects we need, create/load a wallet, sync the chain, etc. We override WalletAppKit so we
    // can customize it by adding the extension objects - we have to do this before the wallet file is loaded so
    // the plugin that knows how to parse all the additional data is present during the load.
    appKit = new WalletAppKit(params, new File("."), "payment_channel_example_client") {
        @Override
        protected List<WalletExtension> provideWalletExtensions() {
            // The StoredPaymentChannelClientStates object is responsible for, amongst other things, broadcasting
            // the refund transaction if its lock time has expired. It also persists channels so we can resume them
            // after a restart.
            // We should not send a PeerGroup in the StoredPaymentChannelClientStates constructor
            // since WalletAppKit will find it for us.
            return ImmutableList.<WalletExtension>of(new StoredPaymentChannelClientStates(null));
        }
    };
    // Broadcasting can take a bit of time so we up the timeout for "real" networks
    final int timeoutSeconds = params.getId().equals(NetworkParameters.ID_REGTEST) ? 15 : 150;
    if (params == RegTestParams.get()) {
        appKit.connectToLocalHost();
    }
    appKit.startAsync();
    appKit.awaitRunning();
    // We now have active network connections and a fully synced wallet.
    // Add a new key which will be used for the multisig contract.
    appKit.wallet().importKey(myKey);
    appKit.wallet().allowSpendingUnconfirmedTransactions();

    System.out.println(appKit.wallet());

    // Create the object which manages the payment channels protocol, client side. Tell it where the server to
    // connect to is, along with some reasonable network timeouts, the wallet and our temporary key. We also have
    // to pick an amount of value to lock up for the duration of the channel.
    //
    // Note that this may or may not actually construct a new channel. If an existing unclosed channel is found in
    // the wallet, then it'll re-use that one instead.
    final InetSocketAddress server = new InetSocketAddress(host, 4242);

    waitForSufficientBalance(channelSize);
    final String channelID = host;
    // Do this twice as each one sends 1/10th of a bitcent 5 times, so to send a bitcent, we do it twice. This
    // demonstrates resuming a channel that wasn't closed yet. It should close automatically once we run out
    // of money on the channel.
    log.info("Round one ...");
    openAndSend(timeoutSeconds, server, channelID, 5, clientChannelProperties);
    log.info("Round two ...");
    log.info(appKit.wallet().toString());
    openAndSend(timeoutSeconds, server, channelID, 4, clientChannelProperties);   // 4 times because the opening of the channel made a payment.
    log.info("Stopping ...");
    appKit.stopAsync();
    appKit.awaitTerminated();
}
 
开发者ID:bitcoinj,项目名称:bitcoinj,代码行数:52,代码来源:ExamplePaymentChannelClient.java


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