@Test public void testHandleAddressQueueItem() throws Exception { ECKey key = new ECKey(); String address = key.toAddress(params).toString(); SettableFuture<StratumMessage> addressFuture = SettableFuture.create(); expect(client.call("blockchain.address.get_history", address)).andReturn(addressFuture); control.replay(); ArrayList<JsonNode> params = Lists.newArrayList(); params.add(TextNode.valueOf(address)); multiWallet.handleAddressQueueItem( new StratumMessage(1L, "blockchain.address.subscribe", params, TextNode.valueOf("aaaa"), mapper)); control.verify(); }
@VisibleForTesting void handleAddressQueueItem(StratumMessage item) throws JsonProcessingException { if (item.params.size() < 1) { log.error("got address subscription update with no params"); return; } final String address = item.params.get(0).asText(); if (address.isEmpty()) { log.error("got address subscription update with no address"); return; } JsonNode result = item.result; if (result == null) result = item.params.get(1); if (result.isNull()) { SettableFuture<Integer> future = downloadFutures.get(address); if (future != null && !future.isDone()) { future.set(0); } } else { retrieveAddressHistory(address); } }
ElectrumMultiWallet extends SmartMultiWallet implements WalletExtension, StratumChain.Listener { @VisibleForTesting void handleAddressQueueItem(StratumMessage item) throws JsonProcessingException { if (item.params.size() < 1) { log.error("got address subscription update with no params"); return; } final String address = item.params.get(0).asText(); if (address.isEmpty()) { log.error("got address subscription update with no address"); return; } JsonNode result = item.result; if (result == null) result = item.params.get(1); if (result.isNull()) { SettableFuture<Integer> future = downloadFutures.get(address); if (future != null && !future.isDone()) { future.set(0); } } else { retrieveAddressHistory(address); } } }
ElectrumMultiWallet extends SmartMultiWallet implements WalletExtension, StratumChain.Listener { @VisibleForTesting void handleAddressQueueItem(StratumMessage item) throws JsonProcessingException { if (item.params.size() < 1) { log.error("got address subscription update with no params"); return; } final String address = item.params.get(0).asText(); if (address.isEmpty()) { log.error("got address subscription update with no address"); return; } JsonNode result = item.result; if (result == null) result = item.params.get(1); if (result.isNull()) { SettableFuture<Integer> future = downloadFutures.get(address); if (future != null && !future.isDone()) { future.set(0); } } else { retrieveAddressHistory(address); } } ElectrumMultiWallet(SmartWallet wallet, File baseDirectory);  ElectrumMultiWallet(SmartWallet wallet); }
ElectrumMultiWallet extends SmartMultiWallet implements WalletExtension, StratumChain.Listener { @VisibleForTesting void handleAddressQueueItem(StratumMessage item) throws JsonProcessingException { if (item.params.size() < 1) { log.error("got address subscription update with no params"); return; } final String address = item.params.get(0).asText(); if (address.isEmpty()) { log.error("got address subscription update with no address"); return; } JsonNode result = item.result; if (result == null) result = item.params.get(1); if (result.isNull()) { SettableFuture<Integer> future = downloadFutures.get(address); if (future != null && !future.isDone()) { future.set(0); } } else { retrieveAddressHistory(address); } } ElectrumMultiWallet(SmartWallet wallet, File baseDirectory);  ElectrumMultiWallet(SmartWallet wallet); @Override void addEventListener(MultiWalletEventListener listener, Executor executor); void setCheckpoints(CheckpointManager checkpoints); void setInitialStore(URL url); @Override boolean removeEventListener(MultiWalletEventListener listener); @Override Set<Transaction> getTransactions(); @Override Transaction getTransaction(Sha256Hash hash); @Override Map<Sha256Hash, Transaction> getTransactionPool(WalletTransaction.Pool pool); @Override void markKeysAsUsed(Transaction tx); @Override void completeTx(Wallet.SendRequest req); @Override void commitTx(Transaction tx); @Override List<TransactionOutput> calculateAllSpendCandidates(boolean excludeImmatureCoinbases, boolean excludeUnsignable); @Override ListenableFuture<Transaction> broadcastTransaction(final Transaction tx); @Override void start(); @Override void startAsync(); @Override void stopAsync(); void stop(); @Override void resetBlockchain(); void safeAwaitClientTerminated(); @Override void awaitDownload(); @Override String getWalletExtensionID(); @Override boolean isWalletExtensionMandatory(); @Override byte[] serializeWalletExtension(); @Override void deserializeWalletExtension(Wallet containingWallet, byte[] data); @Override void onHeight(long height, Block block, boolean isSynced); int currentHeight(); @Override boolean isSynced(); @Override List<VersionMessage> getPeers(); @Override List<StoredBlock> getRecentBlocks(int maxBlocks); }
ElectrumMultiWallet extends SmartMultiWallet implements WalletExtension, StratumChain.Listener { @VisibleForTesting void handleAddressQueueItem(StratumMessage item) throws JsonProcessingException { if (item.params.size() < 1) { log.error("got address subscription update with no params"); return; } final String address = item.params.get(0).asText(); if (address.isEmpty()) { log.error("got address subscription update with no address"); return; } JsonNode result = item.result; if (result == null) result = item.params.get(1); if (result.isNull()) { SettableFuture<Integer> future = downloadFutures.get(address); if (future != null && !future.isDone()) { future.set(0); } } else { retrieveAddressHistory(address); } } ElectrumMultiWallet(SmartWallet wallet, File baseDirectory);  ElectrumMultiWallet(SmartWallet wallet); @Override void addEventListener(MultiWalletEventListener listener, Executor executor); void setCheckpoints(CheckpointManager checkpoints); void setInitialStore(URL url); @Override boolean removeEventListener(MultiWalletEventListener listener); @Override Set<Transaction> getTransactions(); @Override Transaction getTransaction(Sha256Hash hash); @Override Map<Sha256Hash, Transaction> getTransactionPool(WalletTransaction.Pool pool); @Override void markKeysAsUsed(Transaction tx); @Override void completeTx(Wallet.SendRequest req); @Override void commitTx(Transaction tx); @Override List<TransactionOutput> calculateAllSpendCandidates(boolean excludeImmatureCoinbases, boolean excludeUnsignable); @Override ListenableFuture<Transaction> broadcastTransaction(final Transaction tx); @Override void start(); @Override void startAsync(); @Override void stopAsync(); void stop(); @Override void resetBlockchain(); void safeAwaitClientTerminated(); @Override void awaitDownload(); @Override String getWalletExtensionID(); @Override boolean isWalletExtensionMandatory(); @Override byte[] serializeWalletExtension(); @Override void deserializeWalletExtension(Wallet containingWallet, byte[] data); @Override void onHeight(long height, Block block, boolean isSynced); int currentHeight(); @Override boolean isSynced(); @Override List<VersionMessage> getPeers(); @Override List<StoredBlock> getRecentBlocks(int maxBlocks); static final String EXTENSION_ID; static final int CHECKPOINT_TIME_BUFFER; }