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


Java WalletAppKit类代码示例

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


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

示例1: startDownload

import org.bitcoinj.kits.WalletAppKit; //导入依赖的package包/类
public void startDownload() {
    BriefLogFormatter.init();
    String filePrefix = "voting-wallet";
    File walletFile = new File(Environment.getExternalStorageDirectory() + "/" + Util.FOLDER_DIGITAL_VOTING_PASS);
    if (!walletFile.exists()) {
        walletFile.mkdirs();
    }
    kit = new WalletAppKit(params, walletFile, filePrefix);

    //set the observer
    kit.setDownloadListener(progressTracker);

    kit.setBlockingStartup(false);

    PeerAddress peer = new PeerAddress(params, peeraddr);
    kit.setPeerNodes(peer);
    kit.startAsync();
}
 
开发者ID:digital-voting-pass,项目名称:polling-station-app,代码行数:19,代码来源:BlockChain.java

示例2: execute

import org.bitcoinj.kits.WalletAppKit; //导入依赖的package包/类
/**
 *
 * @param callbacks
 */
@Override
public void execute(CoinActionCallback<CurrencyCoin>... callbacks) {
    _callbacks = callbacks;
   // reinitWallet();

    final DeterministicSeed seed = createDeterministicSeed();

    _bitcoinManager.getCurrencyCoin().getWalletManager().addListener(new Service.Listener() {
        @Override
        public void terminated(Service.State from) {
            super.terminated(from);
            WalletAppKit appKit = setupWallet();

            appKit.setDownloadListener(BitcoinRecoverAction.this)
                    .setBlockingStartup(false)
                    .setUserAgent(ServiceConsts.SERVICE_APP_NAME, "0.1")
                    .restoreWalletFromSeed(seed);

            _bitcoinManager.getCurrencyCoin().setWalletManager(appKit);
            _bitcoinManager.getCurrencyCoin().getWalletManager().startAsync();
        }
    }, Executors.newSingleThreadExecutor());

    _bitcoinManager.getCurrencyCoin().getWalletManager().stopAsync();
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:30,代码来源:BitcoinRecoverAction.java

示例3: setupWallet

import org.bitcoinj.kits.WalletAppKit; //导入依赖的package包/类
/**
 *
 */
private WalletAppKit setupWallet() {

    final WalletAppKit appKit = new WalletAppKit(Constants.NETWORK_PARAMETERS,
            _bitcoinManager.getCurrencyCoin().getDataDir(),
            ServiceConsts.SERVICE_APP_NAME + "-" + Constants.NETWORK_PARAMETERS.getPaymentProtocolId()) {
        @Override
        protected void onSetupCompleted() {
            super.onSetupCompleted();

            peerGroup().setFastCatchupTimeSecs(wallet().getEarliestKeyCreationTime());
           // wallet().allowSpendingUnconfirmedTransactions();
        }
    };

    return appKit;
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:20,代码来源:BitcoinRecoverAction.java

示例4: setupWalletKit

import org.bitcoinj.kits.WalletAppKit; //导入依赖的package包/类
public void setupWalletKit(@Nullable DeterministicSeed seed) {
    // If seed is non-null it means we are restoring from backup.
    bitcoin = new WalletAppKit(params, new File("."), WALLET_FILE_NAME) {
        @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();
            Platform.runLater(controller::onBitcoinSetup);
        }
    };
    // 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.
    if (params == RegTestParams.get()) {
        bitcoin.connectToLocalHost();   // You should run a regtest mode bitcoind locally.
    } else if (params == TestNet3Params.get()) {
        // As an example!
        bitcoin.useTor();
        // bitcoin.setDiscovery(new HttpDiscovery(params, URI.create("http://localhost:8080/peers"), ECKey.fromPublicOnly(BaseEncoding.base16().decode("02cba68cfd0679d10b186288b75a59f9132b1b3e222f6332717cb8c4eb2040f940".toUpperCase()))));
    }
    bitcoin.setDownloadListener(controller.progressBarUpdater())
           .setBlockingStartup(false)
           .setUserAgent(APP_NAME, "1.0");
    if (seed != null)
        bitcoin.restoreWalletFromSeed(seed);
}
 
开发者ID:Grant-Redmond,项目名称:cryptwallet,代码行数:27,代码来源:Main.java

示例5: run

import org.bitcoinj.kits.WalletAppKit; //导入依赖的package包/类
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);
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:26,代码来源:ExamplePaymentChannelServer.java

示例6: 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

示例7: setupWalletKit

import org.bitcoinj.kits.WalletAppKit; //导入依赖的package包/类
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 + "-" + params.getPaymentProtocolId() + CLIENTID) {
        @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();
            Platform.runLater(controller::onBitcoinSetup);

        }
    };

    bitcoin.setDownloadListener(controller.progressBarUpdater())
            .setBlockingStartup(false)
            .setUserAgent(APP_NAME, "1.0");
    if (seed != null) {
        bitcoin.restoreWalletFromSeed(seed);
    }

}
 
开发者ID:matsjj,项目名称:thundernetwork,代码行数:22,代码来源:Main.java

示例8: WalletRunnable

import org.bitcoinj.kits.WalletAppKit; //导入依赖的package包/类
public WalletRunnable()
{
    super();

    log.info("Starting wallet.");

    // https://stackoverflow.com/questions/5115339/tomcat-opts-environment-variable-and-system-getenv
    File walletLoc = ServerConfig.BITMESH_TEST ?
        new File("./") :
        new File(System.getenv("persistdir"));

    if(!walletLoc.canRead() || !walletLoc.canWrite())
    {
        log.error("Cannot read or write to wallet location.");
        return;
    }

    // Initialize wallet appkit with params, location and class name
    appKit = new WalletAppKit(MainNetParams.get(), walletLoc, "mainnet");
    appKit.setAutoSave(true);

    testAppKit = new WalletAppKit(TestNet3Params.get(), walletLoc, "testnet");
    testAppKit.setAutoSave(true);
}
 
开发者ID:adonley,项目名称:LockedTransactionServer,代码行数:25,代码来源:WalletRunnable.java

示例9: 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

示例10: setupWalletKit

import org.bitcoinj.kits.WalletAppKit; //导入依赖的package包/类
public void setupWalletKit(@Nullable DeterministicSeed seed) {
    // If seed is non-null it means we are restoring from backup.
    bitcoin = new WalletAppKit(params, new File("."), WALLET_FILE_NAME) {
        @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();
            Platform.runLater(controller::onBitcoinSetup);
        }
    };
    // 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.
    if (params == RegTestParams.get()) {
        bitcoin.connectToLocalHost();   // You should run a regtest mode bitcoind locally.
    }
    bitcoin.setDownloadListener(controller.progressBarUpdater())
           .setBlockingStartup(false)
           .setUserAgent(APP_NAME, "1.0");
    if (seed != null)
        bitcoin.restoreWalletFromSeed(seed);
}
 
开发者ID:bitcoinj,项目名称:bitcoinj,代码行数:23,代码来源:Main.java

示例11: 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

示例12: setupWalletKit

import org.bitcoinj.kits.WalletAppKit; //导入依赖的package包/类
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 + "-" + 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();
            Platform.runLater(controller::onBitcoinSetup);
        }
    };
    // 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.
    if (params == RegTestParams.get()) {
        bitcoin.connectToLocalHost();   // You should run a regtest mode bitcoind locally.
    } else if (params == TestNet3Params.get()) {
        // As an example!
        bitcoin.useTor();
        // bitcoin.setDiscovery(new HttpDiscovery(params, URI.create("http://localhost:8080/peers"), ECKey.fromPublicOnly(BaseEncoding.base16().decode("02cba68cfd0679d10b186288b75a59f9132b1b3e222f6332717cb8c4eb2040f940".toUpperCase()))));
    } else {
        bitcoin.useTor();
    }
    bitcoin.setDownloadListener(controller.progressBarUpdater())
           .setBlockingStartup(false)
           .setUserAgent(APP_NAME, "1.0");
    if (seed != null)
        bitcoin.restoreWalletFromSeed(seed);
}
 
开发者ID:Techsoul192,项目名称:legendary-guide,代码行数:29,代码来源:Main.java

示例13: initWallet

import org.bitcoinj.kits.WalletAppKit; //导入依赖的package包/类
/**
     *
     */
    private void initWallet(final NetworkParameters netParams) {
        //File dataDir = getDir("consensus_folder", Context.MODE_PRIVATE);

      //  _bitcoinJContext = new org.bitcoinj.core.Context(netParams);

        // Start up a basic app using a class that automates some boilerplate. Ensure we always have at least one key.
        _walletKit = new WalletAppKit(Constants.NETWORK_PARAMETERS,
                _bitcoin.getDataDir(),
                ServiceConsts.SERVICE_APP_NAME + "-" + netParams.getPaymentProtocolId()) {

            /**
             *
             */
            @Override
            protected void onSetupCompleted() {
                System.out.println("Setting up wallet : " + wallet().toString());

                // This is called in a background thread after startAndWait is called, as setting up various objects
                // can do disk and network IO that may cause UI jank/stuttering in wallet apps if it were to be done
                // on the main thread.
                if (wallet().getKeyChainGroupSize() < 1)
                    wallet().importKey(new ECKey());

                peerGroup().setFastCatchupTimeSecs(wallet().getEarliestKeyCreationTime());
                peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));

//                wallet.removeCoinsReceivedEventListener(_bitcoinManger);
//                wallet.addCoinsReceivedEventListener(_bitcoinManger);

                _bitcoin.setWalletManager(_walletKit);
            }
        };
    }
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:37,代码来源:BitcoinSetupAction.java

示例14: initKit

import org.bitcoinj.kits.WalletAppKit; //导入依赖的package包/类
private WalletAppKit initKit(@Nullable DeterministicSeed seed) {
   //initialize files and stuff here, add our address to the watched ones
   WalletAppKit kit = new WalletAppKit(params, new File("./spv"), fileprefix);
   kit.setAutoSave(true);
   kit.useTor();
   kit.setDiscovery(new DnsDiscovery(params));
   // fresh restore if seed provided
   if (seed != null) {
      kit.restoreWalletFromSeed(seed);
   }
   // startUp WalletAppKit
   kit.startAndWait();
   return kit;
}
 
开发者ID:DanielKrawisz,项目名称:Shufflepuff,代码行数:15,代码来源:BitcoinCrypto.java

示例15: testSend

import org.bitcoinj.kits.WalletAppKit; //导入依赖的package包/类
@Test
public void testSend() throws Exception {
   WalletAppKit nomKit = bitcoinCryptoNoP.getKit();
   Wallet wallet = nomKit.wallet();
   System.out.println("Current Receive Address: " + wallet.currentReceiveAddress().toString() + "\nIssued Receive Addresses: \n" + wallet.getIssuedReceiveAddresses().toString() + "\nMnemonic: " + wallet.getActiveKeychain().getMnemonicCode().toString() + "\nWallets Balance: " + wallet.getBalance().toPlainString() + " BTC");
   // Get a ready to send TX in its Raw HEX format
   System.out.println("Raw TX HEX: " + bitcoinCryptoNoP.sendOffline("n2ooxjPCQ19f56ivrCBq93DM6a71TA89bc", 10000));
   // Create and send transaciton using the wallets broadcast
   org.bitcoinj.core.Transaction sentTransaction = bitcoinCryptoNoP.send("n2ooxjPCQ19f56ivrCBq93DM6a71TA89bc", 10000);
   System.out.println("Transaction sent. Find txid: " + sentTransaction.getHashAsString());
}
 
开发者ID:DanielKrawisz,项目名称:Shufflepuff,代码行数:12,代码来源:BitcoinCryptoTest.java


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