Class NativeTransactionConfidenceEventListener

  • All Implemented Interfaces:

    public class NativeTransactionConfidenceEventListener
    extends java.lang.Object
    implements TransactionConfidenceEventListener
    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 Detail

      • ptr

        public long ptr
    • Constructor Detail

      • NativeTransactionConfidenceEventListener

        public NativeTransactionConfidenceEventListener()
    • Method Detail

      • onTransactionConfidenceChanged

        public void onTransactionConfidenceChanged​(Wallet wallet,
                                                   Transaction tx)
        Description copied from interface: TransactionConfidenceEventListener
        Called when a transaction changes its confidence level. You can also attach event listeners to the individual transactions, if you don't care about all of them. Usually you would save the wallet to disk after receiving this callback unless you already set up autosaving.

        You should pay attention to this callback in case a transaction becomes dead, that is, a transaction you believed to be active (send or receive) becomes overridden by the network. This can happen if:

        1. You are sharing keys between wallets and accidentally create/broadcast a double spend.
        2. Somebody is attacking the network and reversing transactions, ie, the user is a victim of fraud.
        3. A bug: for example you create a transaction, broadcast it but fail to commit it. The Wallet will then re-use the same outputs when creating the next spend.
        To find if the transaction is dead, you can use:
         tx.getConfidence().getConfidenceType() == TransactionConfidence.ConfidenceType.DEAD
        If it is, you should notify the user in some way so they know the thing they bought may not arrive/the thing they sold should not be dispatched.

        Note that this callback will be invoked for every transaction in the wallet, for every new block that is received (because the depth has changed). If you want to update a UI view from the contents of the wallet it is more efficient to use onWalletChanged instead.

        Specified by:
        onTransactionConfidenceChanged in interface TransactionConfidenceEventListener