/** * Adds an event listener object called when coins are received. * Runs the listener methods in the user thread. */ public void addCoinsReceivedEventListener(WalletCoinsReceivedEventListener listener) { addCoinsReceivedEventListener(Threading.USER_THREAD, listener); }
/** * Adds an event listener object called when coins are received. * Runs the listener methods in the user thread. */ public void addCoinsReceivedEventListener(WalletCoinsReceivedEventListener listener) { addCoinsReceivedEventListener(Threading.USER_THREAD, listener); }
/** * Adds an event listener object called when coins are received. * Runs the listener methods in the user thread. */ public void addCoinsReceivedEventListener(WalletCoinsReceivedEventListener listener) { addCoinsReceivedEventListener(Threading.USER_THREAD, listener); }
/** * Adds an event listener object called when coins are received. * Runs the listener methods in the user thread. */ public void addCoinsReceivedEventListener(WalletCoinsReceivedEventListener listener) { addCoinsReceivedEventListener(Threading.USER_THREAD, listener); }
protected synchronized void initWalletListeners() { // Register a listener that watches out for the server closing the channel. if (storedChannel != null && storedChannel.close != null) { watchCloseConfirmations(); } wallet.addCoinsReceivedEventListener(Threading.SAME_THREAD, new WalletCoinsReceivedEventListener() { @Override public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) { synchronized (PaymentChannelClientState.this) { if (getContractInternal() == null) return; if (isSettlementTransaction(tx)) { log.info("Close: transaction {} closed contract {}", tx.getHash(), getContractInternal().getHash()); // Record the fact that it was closed along with the transaction that closed it. stateMachine.transition(State.CLOSED); if (storedChannel == null) return; storedChannel.close = tx; updateChannelInWallet(); watchCloseConfirmations(); } } } }); }
protected synchronized void initWalletListeners() { // Register a listener that watches out for the server closing the channel. if (storedChannel != null && storedChannel.close != null) { watchCloseConfirmations(); } wallet.addCoinsReceivedEventListener(Threading.SAME_THREAD, new WalletCoinsReceivedEventListener() { @Override public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) { synchronized (PaymentChannelClientState.this) { if (getContractInternal() == null) return; if (isSettlementTransaction(tx)) { log.info("Close: transaction {} closed contract {}", tx.getHash(), getContractInternal().getHash()); // Record the fact that it was closed along with the transaction that closed it. stateMachine.transition(State.CLOSED); if (storedChannel == null) return; storedChannel.close = tx; updateChannelInWallet(); watchCloseConfirmations(); } } } }); }
protected synchronized void initWalletListeners() { // Register a listener that watches out for the server closing the channel. if (storedChannel != null && storedChannel.close != null) { watchCloseConfirmations(); } wallet.addCoinsReceivedEventListener(Threading.SAME_THREAD, new WalletCoinsReceivedEventListener() { @Override public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) { synchronized (PaymentChannelClientState.this) { if (getContractInternal() == null) return; if (isSettlementTransaction(tx)) { log.info("Close: transaction {} closed contract {}", tx.getHash(), getContractInternal().getHash()); // Record the fact that it was closed along with the transaction that closed it. stateMachine.transition(State.CLOSED); if (storedChannel == null) return; storedChannel.close = tx; updateChannelInWallet(); watchCloseConfirmations(); } } } }); }
protected synchronized void initWalletListeners() { // Register a listener that watches out for the server closing the channel. if (storedChannel != null && storedChannel.close != null) { watchCloseConfirmations(); } wallet.addCoinsReceivedEventListener(Threading.SAME_THREAD, new WalletCoinsReceivedEventListener() { @Override public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) { synchronized (PaymentChannelClientState.this) { if (getContractInternal() == null) return; if (isSettlementTransaction(tx)) { log.info("Close: transaction {} closed contract {}", tx.getHash(), getContractInternal().getHash()); // Record the fact that it was closed along with the transaction that closed it. stateMachine.transition(State.CLOSED); if (storedChannel == null) return; storedChannel.close = tx; updateChannelInWallet(); watchCloseConfirmations(); } } } }); }
private void addWalletListeners() { wallet.addChangeEventListener(mWalletListener); wallet.addCoinsReceivedEventListener(mWalletListener); wallet.addCoinsSentEventListener(mWalletListener); wallet.addReorganizeEventListener(mWalletListener); }
/** Use the more specific listener methods instead */ @Deprecated public void addEventListener(WalletEventListener listener, Executor executor) { addCoinsReceivedEventListener(executor, listener); addCoinsSentEventListener(executor, listener); addChangeEventListener(executor, listener); addKeyChainEventListener(executor, listener); addReorganizeEventListener(executor, listener); addScriptChangeEventListener(executor, listener); addTransactionConfidenceEventListener(executor, listener); }
/** Use the more specific listener methods instead */ @Deprecated public void addEventListener(WalletEventListener listener, Executor executor) { addCoinsReceivedEventListener(executor, listener); addCoinsSentEventListener(executor, listener); addChangeEventListener(executor, listener); addKeyChainEventListener(executor, listener); addReorganizeEventListener(executor, listener); addScriptChangeEventListener(executor, listener); addTransactionConfidenceEventListener(executor, listener); }
/** Use the more specific listener methods instead */ @Deprecated public void addEventListener(WalletEventListener listener, Executor executor) { addCoinsReceivedEventListener(executor, listener); addCoinsSentEventListener(executor, listener); addChangeEventListener(executor, listener); addKeyChainEventListener(executor, listener); addReorganizeEventListener(executor, listener); addScriptChangeEventListener(executor, listener); addTransactionConfidenceEventListener(executor, listener); }
/** Use the more specific listener methods instead */ @Deprecated public void addEventListener(WalletEventListener listener, Executor executor) { addCoinsReceivedEventListener(executor, listener); addCoinsSentEventListener(executor, listener); addChangeEventListener(executor, listener); addKeyChainEventListener(executor, listener); addReorganizeEventListener(executor, listener); addScriptChangeEventListener(executor, listener); addTransactionConfidenceEventListener(executor, listener); }
@Test public void exceptionsDoNotBlockAllListeners() throws Exception { // Check that if a wallet listener throws an exception, the others still run. wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() { @Override public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) { log.info("onCoinsReceived 1"); throw new RuntimeException("barf"); } }); final AtomicInteger flag = new AtomicInteger(); wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() { @Override public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) { log.info("onCoinsReceived 2"); flag.incrementAndGet(); } }); sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, COIN); log.info("Wait for user thread"); Threading.waitForUserCode(); log.info("... and test flag."); assertEquals(1, flag.get()); }
/** * Adds an event listener object. Methods on this object are called when something interesting happens, * like receiving money. Runs the listener methods in the user thread. */ public void addEventListener(WalletEventListener listener) { addChangeEventListener(Threading.USER_THREAD, listener); addCoinsReceivedEventListener(Threading.USER_THREAD, listener); addCoinsSentEventListener(Threading.USER_THREAD, listener); addKeyChainEventListener(Threading.USER_THREAD, listener); addReorganizeEventListener(Threading.USER_THREAD, listener); addScriptChangeEventListener(Threading.USER_THREAD, listener); addTransactionConfidenceEventListener(Threading.USER_THREAD, listener); }
/** * Adds an event listener object. Methods on this object are called when something interesting happens, * like receiving money. Runs the listener methods in the user thread. */ public void addEventListener(WalletEventListener listener) { addChangeEventListener(Threading.USER_THREAD, listener); addCoinsReceivedEventListener(Threading.USER_THREAD, listener); addCoinsSentEventListener(Threading.USER_THREAD, listener); addKeyChainEventListener(Threading.USER_THREAD, listener); addReorganizeEventListener(Threading.USER_THREAD, listener); addScriptChangeEventListener(Threading.USER_THREAD, listener); addTransactionConfidenceEventListener(Threading.USER_THREAD, listener); }
/** * Adds an event listener object. Methods on this object are called when something interesting happens, * like receiving money. Runs the listener methods in the user thread. */ public void addEventListener(WalletEventListener listener) { addChangeEventListener(Threading.USER_THREAD, listener); addCoinsReceivedEventListener(Threading.USER_THREAD, listener); addCoinsSentEventListener(Threading.USER_THREAD, listener); addKeyChainEventListener(Threading.USER_THREAD, listener); addReorganizeEventListener(Threading.USER_THREAD, listener); addScriptChangeEventListener(Threading.USER_THREAD, listener); addTransactionConfidenceEventListener(Threading.USER_THREAD, listener); }
/** * Adds an event listener object. Methods on this object are called when something interesting happens, * like receiving money. Runs the listener methods in the user thread. */ public void addEventListener(WalletEventListener listener) { addChangeEventListener(Threading.USER_THREAD, listener); addCoinsReceivedEventListener(Threading.USER_THREAD, listener); addCoinsSentEventListener(Threading.USER_THREAD, listener); addKeyChainEventListener(Threading.USER_THREAD, listener); addReorganizeEventListener(Threading.USER_THREAD, listener); addScriptChangeEventListener(Threading.USER_THREAD, listener); addTransactionConfidenceEventListener(Threading.USER_THREAD, listener); }
@Test public void recursiveDependencyDownloadDisabled() throws Exception { peer.setDownloadTxDependencies(false); connect(); // Check that if we request dependency download to be disabled and receive a relevant tx, things work correctly. Transaction tx = FakeTxBuilder.createFakeTx(PARAMS, COIN, address); final Transaction[] result = new Transaction[1]; wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() { @Override public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) { result[0] = tx; } }); inbound(writeTarget, tx); pingAndWait(writeTarget); assertEquals(tx, result[0]); }
private void setupWalletListeners(Wallet wallet) { wallet.addCoinsReceivedEventListener((wallet1, tx, prevBalance, newBalance) -> { view.displayMyBalance(wallet.getBalance().toFriendlyString()); if(tx.getPurpose() == Transaction.Purpose.UNKNOWN) view.showToastMessage("Receive " + newBalance.minus(prevBalance).toFriendlyString()); }); wallet.addCoinsSentEventListener((wallet12, tx, prevBalance, newBalance) -> { view.displayMyBalance(wallet.getBalance().toFriendlyString()); view.clearAmount(); view.displayRecipientAddress(null); view.showToastMessage("Sent " + prevBalance.minus(newBalance).minus(tx.getFee()).toFriendlyString()); }); } }