Wallet implements Serializable, BlockChainListener, PeerFilterProvider, IsMultiBitClass { public void addEventListener(WalletEventListener listener) { addEventListener(listener, Threading.USER_THREAD); } Wallet(NetworkParameters params);  Wallet(NetworkParameters params, KeyCrypter keyCrypter); NetworkParameters getNetworkParameters(); void setNetworkParameters(NetworkParameters params); NetworkParameters getParams(); List<ECKey> getKeys(); List<Script> getWatchedScripts(); boolean removeKey(ECKey key); List<ECKey> getKeychain(); int getKeychainSize(); void saveToFile(File temp, File destFile); void saveToFile(File f); void setAcceptRiskyTransactions(boolean acceptRiskyTransactions); boolean doesAcceptRiskyTransactions(); void setRiskAnalyzer(RiskAnalysis.Analyzer analyzer); RiskAnalysis.Analyzer getRiskAnalyzer(); WalletFiles autosaveToFile(File f, long delayTime, TimeUnit timeUnit,
                                      @Nullable WalletFiles.Listener eventListener); void shutdownAutosaveAndWait(); void saveToFileStream(OutputStream f); static Wallet loadFromFile(File f); boolean isConsistent(); static Wallet loadFromFileStream(InputStream stream); void notifyTransactionIsInBlock(Sha256Hash txHash, StoredBlock block,
                                           BlockChain.NewBlockType blockType,
                                           int relativityOffset); void receivePending(Transaction tx, @Nullable List<Transaction> dependencies, boolean overrideIsRelevant); boolean isTransactionRisky(Transaction tx, @Nullable List<Transaction> dependencies); void receivePending(Transaction tx, @Nullable List<Transaction> dependencies); boolean isPendingTransactionRelevant(Transaction tx); boolean isTransactionRelevant(Transaction tx); @Override void receiveFromBlock(Transaction tx, StoredBlock block,
                                 BlockChain.NewBlockType blockType,
                                 int relativityOffset); void notifyNewBestBlock(StoredBlock block); void addEventListener(WalletEventListener listener); void addEventListener(WalletEventListener listener, Executor executor); boolean removeEventListener(WalletEventListener listener); boolean maybeCommitTx(Transaction tx); void commitTx(Transaction tx); Set<Transaction> getTransactions(boolean includeDead); Iterable<WalletTransaction> getWalletTransactions(); void addWalletTransaction(WalletTransaction wtx); List<Transaction> getTransactionsByTime(); List<Transaction> getRecentTransactions(int numTransactions, boolean includeDead); @Nullable Transaction getTransaction(Sha256Hash hash); void clearTransactions(int fromHeight); void cleanup(); Transaction createSend(Address address, BigInteger nanocoins); Transaction sendCoinsOffline(SendRequest request); SendResult sendCoins(TransactionBroadcaster broadcaster, Address to, BigInteger value); SendResult sendCoins(TransactionBroadcaster broadcaster, SendRequest request); void completeTx(SendRequest req); SendResult sendCoins(SendRequest request); Transaction sendCoins(Peer peer, SendRequest request); void completeTx(SendRequest req, boolean sign); void sign(SendRequest sendRequest); LinkedList<TransactionOutput> calculateAllSpendCandidates(boolean excludeImmatureCoinbases); LinkedList<TransactionOutput> getWatchedOutputs(boolean excludeImmatureCoinbases); Address getChangeAddress(); boolean addKey(final ECKey key); int addKeys(final List<ECKey> keys); boolean isAddressWatched(Address address); boolean addWatchedAddress(final Address address); boolean addWatchedAddress(final Address address, long creationTime); int addWatchedAddresses(final List<Address> addresses, long creationTime); int addWatchedScripts(final List<Script> scripts); @Nullable ECKey findKeyFromPubHash(byte[] pubkeyHash); boolean hasKey(ECKey key); boolean isPubKeyHashMine(byte[] pubkeyHash); boolean isWatchedScript(Script script); @Nullable ECKey findKeyFromPubKey(byte[] pubkey); boolean isPubKeyMine(byte[] pubkey); BigInteger getBalance(); BigInteger getBalance(BalanceType balanceType); BigInteger getBalance(CoinSelector selector); BigInteger getWatchedBalance(); BigInteger getWatchedBalance(CoinSelector selector); @Override String toString(); String toString(boolean includePrivateKeys, boolean includeTransactions, boolean includeExtensions,
                           @Nullable AbstractBlockChain chain); void reorganize(StoredBlock splitPoint, List<StoredBlock> oldBlocks, List<StoredBlock> newBlocks); Collection<Transaction> getPendingTransactions(); @Override long getEarliestKeyCreationTime(); @Nullable Sha256Hash getLastBlockSeenHash(); void setLastBlockSeenHash(@Nullable Sha256Hash lastBlockSeenHash); void setLastBlockSeenHeight(int lastBlockSeenHeight); void setLastBlockSeenTimeSecs(long timeSecs); long getLastBlockSeenTimeSecs(); @Nullable Date getLastBlockSeenTime(); int getLastBlockSeenHeight(); synchronized void clearTransactions(Date fromDate); KeyParameter encrypt(CharSequence password); void encrypt(KeyCrypter keyCrypter, KeyParameter aesKey); void decrypt(KeyParameter aesKey); ECKey addNewEncryptedKey(KeyCrypter keyCrypter, KeyParameter aesKey); ECKey addNewEncryptedKey(CharSequence password); boolean checkPassword(CharSequence password); boolean checkAESKey(KeyParameter aesKey); KeyCrypter getKeyCrypter(); void setKeyCrypter(KeyCrypter keyCrypter); EncryptionType getEncryptionType(); boolean isEncrypted(); MultiBitWalletVersion getVersion(); void setVersion(MultiBitWalletVersion version); void setDescription(String description); String getDescription(); @Override int getBloomFilterElementCount(); @Override boolean isRequiringUpdateAllBloomFilter(); BloomFilter getBloomFilter(double falsePositiveRate); @Override BloomFilter getBloomFilter(int size, double falsePositiveRate, long nTweak); CoinSelector getCoinSelector(); void setCoinSelector(@Nonnull CoinSelector coinSelector); void allowSpendingUnconfirmedTransactions(); ListenableFuture<BigInteger> getBalanceFuture(final BigInteger value, final BalanceType type); void addExtension(WalletExtension extension); WalletExtension addOrGetExistingExtension(WalletExtension extension); void addOrUpdateExtension(WalletExtension extension); Map<String, WalletExtension> getExtensions(); TransactionConfidence.Listener getTxConfidenceListener(); void setTransactionBroadcaster(@Nullable com.google.bitcoin.core.TransactionBroadcaster broadcaster); void setKeyRotationTime(Date time); Date getKeyRotationTime(); void setKeyRotationTime(long unixTimeSeconds); void setKeyRotationEnabled(boolean enabled); boolean isKeyRotating(ECKey key);  }
@Test public void exceptionsDoNotBlockAllListeners() throws Exception { wallet.addEventListener(new AbstractWalletEventListener() { @Override public void onCoinsReceived(Wallet wallet, Transaction tx, BigInteger prevBalance, BigInteger newBalance) { log.info("onCoinsReceived 1"); throw new RuntimeException("barf"); } }); final AtomicInteger flag = new AtomicInteger(); wallet.addEventListener(new AbstractWalletEventListener() { @Override public void onCoinsReceived(Wallet wallet, Transaction tx, BigInteger prevBalance, BigInteger newBalance) { log.info("onCoinsReceived 2"); flag.incrementAndGet(); } }); sendMoneyToWallet(Utils.toNanoCoins(1, 0), AbstractBlockChain.NewBlockType.BEST_CHAIN); log.info("Wait for user thread"); Threading.waitForUserCode(); log.info("... and test flag."); assertEquals(1, flag.get()); }