mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-09 07:02:24 -04:00
fix confirmation progress in ui
fix my role label to show during trade initialization support arbitrator role label
This commit is contained in:
parent
247087ef46
commit
4fb62d8669
13 changed files with 60 additions and 277 deletions
|
@ -30,7 +30,6 @@ import bisq.common.util.Utilities;
|
|||
|
||||
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
import java.math.BigInteger;
|
||||
import com.jfoenix.controls.JFXTextField;
|
||||
|
||||
import javafx.scene.control.Label;
|
||||
|
@ -135,17 +134,13 @@ public class TxIdTextField extends AnchorPane {
|
|||
// TODO: this only listens for new blocks, listen for double spend
|
||||
txUpdater = new MoneroWalletListener() {
|
||||
@Override
|
||||
public void onNewBlock(long height) {
|
||||
updateConfidence(txId);
|
||||
}
|
||||
@Override
|
||||
public void onBalancesChanged(BigInteger newBalance, BigInteger newUnlockedBalance) {
|
||||
updateConfidence(txId);
|
||||
public void onNewBlock(long lastBlockHeight) {
|
||||
updateConfidence(txId, false, lastBlockHeight + 1);
|
||||
}
|
||||
};
|
||||
xmrWalletService.addWalletListener(txUpdater);
|
||||
|
||||
updateConfidence(txId);
|
||||
updateConfidence(txId, true, null);
|
||||
|
||||
textField.setText(txId);
|
||||
textField.setOnMouseClicked(mouseEvent -> openBlockExplorer(txId));
|
||||
|
@ -175,31 +170,22 @@ public class TxIdTextField extends AnchorPane {
|
|||
}
|
||||
}
|
||||
|
||||
private void updateConfidence(String txId) {
|
||||
private void updateConfidence(String txId, boolean useCache, Long height) {
|
||||
MoneroTx tx = null;
|
||||
try {
|
||||
tx = xmrWalletService.getTxWithCache(txId);
|
||||
tx.setNumConfirmations(tx.isConfirmed() ? xmrWalletService.getConnectionsService().getLastInfo().getHeight() - tx.getHeight() : 0l); // TODO: use tx.getNumConfirmations() when MoneroDaemonRpc supports it
|
||||
tx = useCache ? xmrWalletService.getTxWithCache(txId) : xmrWalletService.getTx(txId);
|
||||
tx.setNumConfirmations(tx.isConfirmed() ? (height == null ? xmrWalletService.getConnectionsService().getLastInfo().getHeight() : height) - tx.getHeight(): 0l); // TODO: don't set if tx.getNumConfirmations() works reliably on non-local testnet
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
GUIUtil.updateConfidence(tx, progressIndicatorTooltip, txConfidenceIndicator);
|
||||
if (tx != null) {
|
||||
if (txConfidenceIndicator.getProgress() != 0) {
|
||||
txConfidenceIndicator.setVisible(true);
|
||||
AnchorPane.setRightAnchor(txConfidenceIndicator, 0.0);
|
||||
}
|
||||
if (txConfidenceIndicator.getProgress() >= 1.0 && txUpdater != null) {
|
||||
xmrWalletService.removeWalletListener(txUpdater); // unregister listener
|
||||
txUpdater = null;
|
||||
}
|
||||
} else {
|
||||
//TODO we should show some placeholder in case of a tx which we are not aware of but which can be
|
||||
// confirmed already. This is for instance the case of the other peers trade fee tx, as it is not related
|
||||
// to our wallet we don't have a confidence object but we should show that it is in an unknown state instead
|
||||
// of not showing anything which causes confusion that the tx was not broadcasted. Best would be to request
|
||||
// it from a block explorer service but that is a bit too heavy for that use case...
|
||||
// Maybe a question mark with a tooltip explaining why we don't know about the confidence might be ok...
|
||||
if (txConfidenceIndicator.getProgress() != 0) {
|
||||
txConfidenceIndicator.setVisible(true);
|
||||
AnchorPane.setRightAnchor(txConfidenceIndicator, 0.0);
|
||||
}
|
||||
if (txConfidenceIndicator.getProgress() >= 1.0 && txUpdater != null) {
|
||||
xmrWalletService.removeWalletListener(txUpdater); // unregister listener
|
||||
txUpdater = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -376,18 +376,18 @@ public class PendingTradesDataModel extends ActivatableDataModel {
|
|||
return;
|
||||
}
|
||||
|
||||
MoneroTx makerDepositTx = selectedTrade.getMakerDepositTx();
|
||||
MoneroTx takerDepositTx = selectedTrade.getTakerDepositTx();
|
||||
String tradeId = selectedTrade.getId();
|
||||
tradeStateChangeListener = (observable, oldValue, newValue) -> {
|
||||
if (makerDepositTx != null && takerDepositTx != null) { // TODO (woodser): this treats separate deposit ids as one unit, being both available or unavailable
|
||||
makerTxId.set(makerDepositTx.getHash());
|
||||
takerTxId.set(takerDepositTx.getHash());
|
||||
String makerDepositTxHash = selectedTrade.getMaker().getDepositTxHash();
|
||||
String takerDepositTxHash = selectedTrade.getTaker().getDepositTxHash();
|
||||
if (makerDepositTxHash != null && takerDepositTxHash != null) { // TODO (woodser): this treats separate deposit ids as one unit, being both available or unavailable
|
||||
makerTxId.set(makerDepositTxHash);
|
||||
takerTxId.set(takerDepositTxHash);
|
||||
notificationCenter.setSelectedTradeId(tradeId);
|
||||
selectedTrade.stateProperty().removeListener(tradeStateChangeListener);
|
||||
} else {
|
||||
makerTxId.set("");
|
||||
takerTxId.set("");
|
||||
makerTxId.set("");
|
||||
takerTxId.set("");
|
||||
}
|
||||
};
|
||||
selectedTrade.stateProperty().addListener(tradeStateChangeListener);
|
||||
|
@ -399,9 +399,11 @@ public class PendingTradesDataModel extends ActivatableDataModel {
|
|||
}
|
||||
|
||||
isMaker = tradeManager.isMyOffer(offer);
|
||||
if (makerDepositTx != null && takerDepositTx != null) {
|
||||
makerTxId.set(makerDepositTx.getHash());
|
||||
takerTxId.set(takerDepositTx.getHash());
|
||||
String makerDepositTxHash = selectedTrade.getMaker().getDepositTxHash();
|
||||
String takerDepositTxHash = selectedTrade.getTaker().getDepositTxHash();
|
||||
if (makerDepositTxHash != null && takerDepositTxHash != null) {
|
||||
makerTxId.set(makerDepositTxHash);
|
||||
takerTxId.set(takerDepositTxHash);
|
||||
} else {
|
||||
makerTxId.set("");
|
||||
takerTxId.set("");
|
||||
|
|
|
@ -299,18 +299,7 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||
//
|
||||
|
||||
String getMyRole(PendingTradesListItem item) {
|
||||
Trade trade = item.getTrade();
|
||||
Contract contract = trade.getContract();
|
||||
if (contract != null) {
|
||||
Offer offer = trade.getOffer();
|
||||
checkNotNull(offer);
|
||||
checkNotNull(offer.getCurrencyCode());
|
||||
return tradeUtil.getRole(contract.isBuyerMakerAndSellerTaker(),
|
||||
dataModel.isMaker(offer),
|
||||
offer.getCurrencyCode());
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
return tradeUtil.getRole(item.getTrade());
|
||||
}
|
||||
|
||||
String getPaymentMethod(PendingTradesListItem item) {
|
||||
|
@ -425,7 +414,8 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||
}
|
||||
|
||||
switch (tradeState) {
|
||||
// preparation
|
||||
|
||||
// initialization
|
||||
case PREPARATION:
|
||||
case MULTISIG_PREPARED:
|
||||
case MULTISIG_MADE:
|
||||
|
@ -433,16 +423,13 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||
case MULTISIG_COMPLETED:
|
||||
case CONTRACT_SIGNATURE_REQUESTED:
|
||||
case CONTRACT_SIGNED:
|
||||
sellerState.set(UNDEFINED);
|
||||
buyerState.set(BuyerState.UNDEFINED);
|
||||
break;
|
||||
|
||||
// deposit requested
|
||||
case SENT_PUBLISH_DEPOSIT_TX_REQUEST:
|
||||
case SEND_FAILED_PUBLISH_DEPOSIT_TX_REQUEST:
|
||||
case SAW_ARRIVED_PUBLISH_DEPOSIT_TX_REQUEST:
|
||||
sellerState.set(UNDEFINED); // TODO: show view while trade initializes?
|
||||
buyerState.set(BuyerState.UNDEFINED);
|
||||
break;
|
||||
|
||||
// deposit published
|
||||
case ARBITRATOR_PUBLISHED_DEPOSIT_TXS:
|
||||
case DEPOSIT_TXS_SEEN_IN_NETWORK:
|
||||
case DEPOSIT_TXS_CONFIRMED_IN_BLOCKCHAIN: // TODO: separate step to wait for first confirmation
|
||||
|
@ -451,7 +438,7 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||
break;
|
||||
|
||||
// buyer and seller step 2
|
||||
// deposit unlocked
|
||||
// deposits unlocked
|
||||
case DEPOSIT_TXS_UNLOCKED_IN_BLOCKCHAIN:
|
||||
sellerState.set(SellerState.STEP2);
|
||||
buyerState.set(BuyerState.STEP2);
|
||||
|
|
|
@ -191,7 +191,7 @@ public abstract class TradeStepView extends AnchorPane {
|
|||
if (peerTxIdSubscription != null)
|
||||
peerTxIdSubscription.unsubscribe();
|
||||
|
||||
selfTxIdSubscription = EasyBind.subscribe(model.dataModel.isMaker() ? model.dataModel.takerTxId : model.dataModel.makerTxId, id -> {
|
||||
peerTxIdSubscription = EasyBind.subscribe(model.dataModel.isMaker() ? model.dataModel.takerTxId : model.dataModel.makerTxId, id -> {
|
||||
if (!id.isEmpty())
|
||||
peerTxIdTextField.setup(id);
|
||||
else
|
||||
|
|
|
@ -569,23 +569,21 @@ public class GUIUtil {
|
|||
public static void updateConfidence(MoneroTx tx,
|
||||
Tooltip tooltip,
|
||||
TxConfidenceIndicator txConfidenceIndicator) {
|
||||
if (tx != null) {
|
||||
if (!tx.isRelayed()) {
|
||||
tooltip.setText(Res.get("confidence.unknown"));
|
||||
txConfidenceIndicator.setProgress(0);
|
||||
} else if (tx.isFailed()) {
|
||||
tooltip.setText(Res.get("confidence.invalid"));
|
||||
txConfidenceIndicator.setProgress(0);
|
||||
} else if (tx.isConfirmed()) {
|
||||
tooltip.setText(Res.get("confidence.confirmed", tx.getNumConfirmations()));
|
||||
txConfidenceIndicator.setProgress(Math.min(1, tx.getNumConfirmations() / (double) XmrWalletService.NUM_BLOCKS_UNLOCK));
|
||||
} else {
|
||||
tooltip.setText(Res.get("confidence.seen", 0)); // TODO: replace with numBroadcastPeers
|
||||
txConfidenceIndicator.setProgress(-1.0);
|
||||
}
|
||||
|
||||
txConfidenceIndicator.setPrefSize(24, 24);
|
||||
if (tx != null && !tx.isRelayed()) {
|
||||
tooltip.setText(Res.get("confidence.unknown"));
|
||||
txConfidenceIndicator.setProgress(0);
|
||||
} else if (tx != null && tx.isFailed()) {
|
||||
tooltip.setText(Res.get("confidence.invalid"));
|
||||
txConfidenceIndicator.setProgress(0);
|
||||
} else if (tx != null && tx.isConfirmed()) {
|
||||
tooltip.setText(Res.get("confidence.confirmed", tx.getNumConfirmations()));
|
||||
txConfidenceIndicator.setProgress((double) tx.getNumConfirmations() / (double) XmrWalletService.NUM_BLOCKS_UNLOCK);
|
||||
} else {
|
||||
tooltip.setText(Res.get("confidence.seen", 0)); // TODO: replace with numBroadcastPeers
|
||||
txConfidenceIndicator.setProgress(-1.0);
|
||||
}
|
||||
|
||||
txConfidenceIndicator.setPrefSize(24, 24);
|
||||
}
|
||||
|
||||
public static void openWebPage(String target) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue