Java 类org.bitcoinj.core.WalletExtension 实例源码

项目:namecoinj    文件:ExamplePaymentChannelServer.java   
public void run() throws Exception {
    NetworkParameters params = RegTestParams.get();

    // 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_server") {
        @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 StoredPaymentChannelServerStates(null));
        }
    };
    appKit.connectToLocalHost();
    appKit.startAsync();
    appKit.awaitRunning();

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

    // We provide a peer group, a wallet, a timeout in seconds, the amount we require to start a channel and
    // an implementation of HandlerFactory, which we just implement ourselves.
    new PaymentChannelServerListener(appKit.peerGroup(), appKit.wallet(), 15, Coin.valueOf(100000), this).bindAndStart(4242);
}
项目:digibytej-alice    文件:ExamplePaymentChannelServer.java   
public void run() throws Exception {
    NetworkParameters params = RegTestParams.get();

    // 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_server") {
        @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 StoredPaymentChannelServerStates(null));
        }
    };
    appKit.connectToLocalHost();
    appKit.startAsync();
    appKit.awaitRunning();

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

    // We provide a peer group, a wallet, a timeout in seconds, the amount we require to start a channel and
    // an implementation of HandlerFactory, which we just implement ourselves.
    new PaymentChannelServerListener(appKit.peerGroup(), appKit.wallet(), 15, Coin.valueOf(100000), this).bindAndStart(4242);
}