Class NativeWalletCoinsSentEventListener

  • All Implemented Interfaces:
    WalletCoinsSentEventListener

    public class NativeWalletCoinsSentEventListener
    extends java.lang.Object
    implements WalletCoinsSentEventListener
    An event listener that relays events to a native C++ object. A pointer to that object is stored in this class using JNI on the native side, thus several instances of this can point to different actual native implementations.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      long ptr  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void onCoinsSent​(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance)
      This is called when a transaction is seen that sends coins from this wallet, either because it was broadcast across the network or because a block was received.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ptr

        public long ptr
    • Constructor Detail

      • NativeWalletCoinsSentEventListener

        public NativeWalletCoinsSentEventListener()
    • Method Detail

      • onCoinsSent

        public void onCoinsSent​(Wallet wallet,
                                Transaction tx,
                                Coin prevBalance,
                                Coin newBalance)
        Description copied from interface: WalletCoinsSentEventListener
        This is called when a transaction is seen that sends coins from this wallet, either because it was broadcast across the network or because a block was received. This may at first glance seem useless, because in the common case you already know about such transactions because you created them with the Wallets createSend/sendCoins methods. However when you have a wallet containing only keys, and you wish to replay the block chain to fill it with transactions, it's useful to find out when a transaction is discovered that sends coins from the wallet.

        It's safe to modify the wallet from inside this callback, but if you're replaying the block chain you should be careful to avoid such modifications. Otherwise your changes may be overridden by new data from the chain.

        Specified by:
        onCoinsSent in interface WalletCoinsSentEventListener
        Parameters:
        wallet - The wallet object that this callback relates to (that sent the coins).
        tx - The transaction that sent the coins to someone else.
        prevBalance - The wallets balance before this transaction was seen.
        newBalance - The wallets balance after this transaction was seen. This is the 'estimated' balance.