use of org.bitcoinj.core.TransactionConfidence in project bitsquare by bitsquare.
the class Trade method setupConfidenceListener.
///////////////////////////////////////////////////////////////////////////////////////////
// Private
///////////////////////////////////////////////////////////////////////////////////////////
private void setupConfidenceListener() {
log.debug("setupConfidenceListener");
if (depositTx != null) {
TransactionConfidence transactionConfidence = depositTx.getConfidence();
log.debug("transactionConfidence " + transactionConfidence.getDepthInBlocks());
if (transactionConfidence.getDepthInBlocks() > 0) {
setConfirmedState();
} else {
ListenableFuture<TransactionConfidence> future = transactionConfidence.getDepthFuture(1);
Futures.addCallback(future, new FutureCallback<TransactionConfidence>() {
@Override
public void onSuccess(TransactionConfidence result) {
log.debug("transactionConfidence " + transactionConfidence.getDepthInBlocks());
log.debug("state " + state);
setConfirmedState();
}
@Override
public void onFailure(@NotNull Throwable t) {
t.printStackTrace();
log.error(t.getMessage());
Throwables.propagate(t);
}
});
}
} else {
log.error("depositTx == null. That must not happen.");
}
}
use of org.bitcoinj.core.TransactionConfidence in project bitsquare by bitsquare.
the class BalanceWithConfirmationTextField method setup.
public void setup(Address address, BSFormatter formatter) {
this.formatter = formatter;
confidenceListener = new AddressConfidenceListener(address) {
@Override
public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
updateConfidence(confidence);
}
};
walletService.addAddressConfidenceListener(confidenceListener);
updateConfidence(walletService.getConfidenceForAddress(address));
balanceListener = new BalanceListener(address) {
@Override
public void onBalanceChanged(Coin balance, Transaction tx) {
updateBalance(balance);
}
};
walletService.addBalanceListener(balanceListener);
updateBalance(walletService.getBalanceForAddress(address));
}
use of org.bitcoinj.core.TransactionConfidence in project bitsquare by bitsquare.
the class TxIdTextField method setup.
public void setup(String txID) {
if (txConfidenceListener != null)
walletService.removeTxConfidenceListener(txConfidenceListener);
txConfidenceListener = new TxConfidenceListener(txID) {
@Override
public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
updateConfidence(confidence);
}
};
walletService.addTxConfidenceListener(txConfidenceListener);
updateConfidence(walletService.getConfidenceForTxId(txID));
textField.setText(txID);
textField.setOnMouseClicked(mouseEvent -> openBlockExplorer(txID));
blockExplorerIcon.setOnMouseClicked(mouseEvent -> openBlockExplorer(txID));
copyIcon.setOnMouseClicked(e -> Utilities.copyToClipboard(txID));
}
use of org.bitcoinj.core.TransactionConfidence in project bisq-core by bisq-network.
the class BtcCompensationRequestFeeCoinSelector method isSelectable.
public boolean isSelectable(Transaction tx) {
if (tx != null) {
// Only pick chain-included transactions, or transactions that are ours and pending.
TransactionConfidence confidence = tx.getConfidence();
TransactionConfidence.ConfidenceType type = confidence.getConfidenceType();
return type.equals(TransactionConfidence.ConfidenceType.BUILDING) || type.equals(TransactionConfidence.ConfidenceType.PENDING) && confidence.getSource().equals(TransactionConfidence.Source.SELF) && // TODO: The value 1 below dates from a time when transactions we broadcast *to* were counted, set to 0
(confidence.numBroadcastPeers() > 1 || tx.getParams() == RegTestParams.get());
} else {
return true;
}
}
use of org.bitcoinj.core.TransactionConfidence in project bisq-core by bisq-network.
the class BisqDefaultCoinSelector method isTxSpendable.
// We allow spending own pending txs and if permitForeignPendingTx is set as well foreign unconfirmed txs.
protected boolean isTxSpendable(Transaction tx) {
TransactionConfidence confidence = tx.getConfidence();
TransactionConfidence.ConfidenceType type = confidence.getConfidenceType();
boolean isConfirmed = type.equals(TransactionConfidence.ConfidenceType.BUILDING);
boolean isPending = type.equals(TransactionConfidence.ConfidenceType.PENDING);
boolean isOwnTx = confidence.getSource().equals(TransactionConfidence.Source.SELF);
return isConfirmed || (isPending && (permitForeignPendingTx || isOwnTx));
}
Aggregations