- All Implemented Interfaces:
public class NativeTransactionConfidenceEventListener extends java.lang.Object implements TransactionConfidenceEventListenerAn 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.
Fields Modifier and Type Field Description
Constructors Constructor Description
All Methods Instance Methods Concrete Methods Modifier and Type Method Description
onTransactionConfidenceChanged(Wallet wallet, Transaction tx)Called when a transaction changes its confidence level.
public void onTransactionConfidenceChanged(Wallet wallet, Transaction tx)Description copied from interface:
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
- You are sharing keys between wallets and accidentally create/broadcast a double spend.
- Somebody is attacking the network and reversing transactions, ie, the user is a victim of fraud.
- A bug: for example you create a transaction, broadcast it but fail to commit it. The
Walletwill 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.