public class NativeTransactionConfidenceEventListener extends Object implements TransactionConfidenceEventListener
Modifier and Type | Field and Description |
---|---|
long |
ptr |
Constructor and Description |
---|
NativeTransactionConfidenceEventListener() |
Modifier and Type | Method and Description |
---|---|
void |
onTransactionConfidenceChanged(Wallet wallet,
Transaction tx)
Called when a transaction changes its confidence level.
|
public NativeTransactionConfidenceEventListener()
public void onTransactionConfidenceChanged(Wallet wallet, Transaction tx)
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
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.
onTransactionConfidenceChanged
in interface TransactionConfidenceEventListener
Copyright © 2016. All rights reserved.