use of bisq.core.btc.listeners.TxConfidenceListener in project bisq-desktop by bisq-network.
the class ProposalListItem method setupConfidence.
private void setupConfidence() {
final Tx tx = readableBsqBlockChain.getTxMap().get(proposal.getProposalPayload().getTxId());
if (tx != null) {
final String txId = tx.getId();
// We cache the walletTransaction once found
if (walletTransaction == null) {
final Optional<Transaction> transactionOptional = bsqWalletService.isWalletTransaction(txId);
transactionOptional.ifPresent(transaction -> walletTransaction = transaction);
}
if (walletTransaction != null) {
// It is our tx so we get confidence updates
if (txConfidenceListener == null) {
txConfidenceListener = new TxConfidenceListener(txId) {
@Override
public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
updateConfidence(confidence.getConfidenceType(), confidence.getDepthInBlocks(), confidence.numBroadcastPeers());
}
};
bsqWalletService.addTxConfidenceListener(txConfidenceListener);
}
} else {
// tx from other users, we dont get confidence updates but as we have the bsq tx we can calculate it
// we get setupConfidence called at each new block from above listener so no need to register a new listener
int depth = bsqWalletService.getChainHeightProperty().get() - tx.getBlockHeight() + 1;
if (depth > 0)
updateConfidence(TransactionConfidence.ConfidenceType.BUILDING, depth, -1);
// log.error("name={}, id ={}, depth={}", compensationRequest.getPayload().getName(), compensationRequest.getPayload().getUid(), depth);
}
final TransactionConfidence confidence = bsqWalletService.getConfidenceForTxId(txId);
if (confidence != null)
updateConfidence(confidence, confidence.getDepthInBlocks());
}
}
use of bisq.core.btc.listeners.TxConfidenceListener in project bisq-desktop by bisq-network.
the class VoteListItem method setupConfidence.
private void setupConfidence() {
calculateStake();
final Tx tx = readableBsqBlockChain.getTxMap().get(myVote.getBlindVote().getTxId());
if (tx != null) {
final String txId = tx.getId();
// We cache the walletTransaction once found
if (walletTransaction == null) {
final Optional<Transaction> transactionOptional = bsqWalletService.isWalletTransaction(txId);
transactionOptional.ifPresent(transaction -> walletTransaction = transaction);
}
if (walletTransaction != null) {
// It is our tx so we get confidence updates
if (txConfidenceListener == null) {
txConfidenceListener = new TxConfidenceListener(txId) {
@Override
public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
updateConfidence(confidence.getConfidenceType(), confidence.getDepthInBlocks(), confidence.numBroadcastPeers());
}
};
bsqWalletService.addTxConfidenceListener(txConfidenceListener);
}
} else {
// tx from other users, we dont get confidence updates but as we have the bsq tx we can calculate it
// we get setupConfidence called at each new block from above listener so no need to register a new listener
int depth = bsqWalletService.getChainHeightProperty().get() - tx.getBlockHeight() + 1;
if (depth > 0)
updateConfidence(TransactionConfidence.ConfidenceType.BUILDING, depth, -1);
// log.error("name={}, id ={}, depth={}", compensationRequest.getPayload().getName(), compensationRequest.getPayload().getUid(), depth);
}
final TransactionConfidence confidence = bsqWalletService.getConfidenceForTxId(txId);
if (confidence != null)
updateConfidence(confidence, confidence.getDepthInBlocks());
}
}
use of bisq.core.btc.listeners.TxConfidenceListener in project bisq-desktop by bisq-network.
the class BsqTxListItem method setupConfidence.
private void setupConfidence(BsqWalletService bsqWalletService) {
txConfidenceIndicator = new TxConfidenceIndicator();
txConfidenceIndicator.setId("funds-confidence");
Tooltip tooltip = new Tooltip();
txConfidenceIndicator.setProgress(0);
txConfidenceIndicator.setPrefSize(24, 24);
txConfidenceIndicator.setTooltip(tooltip);
txConfidenceListener = new TxConfidenceListener(txId) {
@Override
public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
updateConfidence(confidence, tooltip);
}
};
bsqWalletService.addTxConfidenceListener(txConfidenceListener);
updateConfidence(bsqWalletService.getConfidenceForTxId(txId), tooltip);
}
use of bisq.core.btc.listeners.TxConfidenceListener in project bisq-desktop by bisq-network.
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));
}
Aggregations