本文整理汇总了Java中org.bitcoinj.kits.WalletAppKit.setDownloadListener方法的典型用法代码示例。如果您正苦于以下问题:Java WalletAppKit.setDownloadListener方法的具体用法?Java WalletAppKit.setDownloadListener怎么用?Java WalletAppKit.setDownloadListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bitcoinj.kits.WalletAppKit
的用法示例。
在下文中一共展示了WalletAppKit.setDownloadListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: initWalletService
import org.bitcoinj.kits.WalletAppKit; //导入方法依赖的package包/类
private void initWalletService() {
Log.d(TAG, "initWalletService with app config: " + getAppConfig());
ClientUtils.fixECKeyComparator();
initLogging();
bitcoinjContext = new Context(getNetworkParameters());
Context.propagate(bitcoinjContext);
walletFile = walletFile();
Log.d(TAG, "Wallet file: " + walletFile + ", already exists: " + walletFile.exists());
kit = new WalletAppKit(bitcoinjContext, getFilesDir(), getAppConfig().getWalletFilesPrefix()) {
@Override
protected void onSetupCompleted() {
final long startTime = System.currentTimeMillis();
try {
wallet = kit.wallet();
peerGroup = kit.peerGroup();
blockChain = kit.chain();
blockStore = kit.store();
initWalletEventListener();
/*
* Check that we already have keys.
* - if yes: check whether current address is still locked. if no: create new one.
* - if no: (1) create client key, (2) execute key-exchange and store server key (3) init address
*/
boolean keysAlreadyExist = loadKeysIfExist();
if (!keysAlreadyExist) {
keyExchange();
loadKeysIfExist();
}
initAddresses();
initFiatCurrency();
// broadcast current wallet balance (not using serviceBinder!)
Coin coinBalance = wallet.getBalance();
broadcastBalanceChanged(coinBalance, exchangeRate.coinToFiat(coinBalance));
if(walletLRunnable!=null) {
walletLRunnable.run();
}
appKitInitDone = true;
broadcastBalanceChanged();
} catch (Exception e) {
String errorMessage = "Error during wallet initialization: " + e.getMessage();
Log.e(TAG, errorMessage, e);
broadcastWalletError(errorMessage);
} finally {
long duration = System.currentTimeMillis() - startTime;
Log.d(TAG, "WalletService - onSetupCompleted finished in "+duration+" ms");
}
}
};
setChainCheckpoints();
kit.setDownloadListener(new DownloadListener());
kit.setBlockingStartup(false);
kit.startAsync();
Log.d(TAG, "Wallet started");
}