stagenet deployment fixes

execute protocol tasks off main thread
fix confirmation progress indicators
fix expected unlock height
process sign contract request after contract signature requested
deposit listener only advances trade state
This commit is contained in:
woodser 2022-07-26 01:03:19 -04:00
parent 3dcaf67edd
commit a3a5b96c06
21 changed files with 259 additions and 223 deletions

View file

@ -40,7 +40,7 @@ import javafx.scene.layout.AnchorPane;
import lombok.Getter;
import lombok.Setter;
import monero.wallet.model.MoneroTxWallet;
import monero.daemon.model.MoneroTx;
import monero.wallet.model.MoneroWalletListener;
import javax.annotation.Nullable;
@ -176,9 +176,10 @@ public class TxIdTextField extends AnchorPane {
}
private void updateConfidence(String txId) {
MoneroTxWallet tx = null;
MoneroTx tx = null;
try {
tx = xmrWalletService.getWallet().getTx(txId);
tx = xmrWalletService.getDaemon().getTx(txId); // TODO: cache results and don't re-fetch
tx.setNumConfirmations(tx.isConfirmed() ? xmrWalletService.getConnectionsService().getLastInfo().getHeight() - tx.getHeight() : 0l); // TODO: use tx.getNumConfirmations() when MoneroDaemonRpc supports it
} catch (Exception e) {
// do nothing
}
@ -188,6 +189,10 @@ public class TxIdTextField extends AnchorPane {
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

View file

@ -640,11 +640,7 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
if (item != null && !empty) {
trade = item.getTrade();
listener = (observable, oldValue, newValue) -> Platform.runLater(new Runnable() {
@Override public void run() {
update();
}
});
listener = (observable, oldValue, newValue) -> UserThread.execute(() -> update());
trade.stateProperty().addListener(listener);
update();
} else {
@ -805,7 +801,6 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
@Override
public void updateItem(final PendingTradesListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
setGraphic(new AutoTooltipLabel(item.getMarketDescription()));
} else {

View file

@ -98,8 +98,8 @@ public abstract class TradeStepView extends AnchorPane {
private TxIdTextField selfTxIdTextField;
private TxIdTextField peerTxIdTextField;
private TradeStepInfo tradeStepInfo;
private Subscription makerTxIdSubscription;
private Subscription takerTxIdSubscription;
private Subscription selfTxIdSubscription;
private Subscription peerTxIdSubscription;
private ClockWatcher.Listener clockListener;
private final ChangeListener<String> errorMessageListener;
protected Label infoLabel;
@ -175,15 +175,11 @@ public abstract class TradeStepView extends AnchorPane {
}
public void activate() {
UserThread.execute(() -> { activateAux(); });
}
private void activateAux() {
if (selfTxIdTextField != null) {
if (makerTxIdSubscription != null)
makerTxIdSubscription.unsubscribe();
if (selfTxIdSubscription != null)
selfTxIdSubscription.unsubscribe();
makerTxIdSubscription = EasyBind.subscribe(model.dataModel.makerTxId, id -> {
selfTxIdSubscription = EasyBind.subscribe(model.dataModel.isMaker() ? model.dataModel.makerTxId : model.dataModel.takerTxId, id -> {
if (!id.isEmpty())
selfTxIdTextField.setup(id);
else
@ -191,10 +187,10 @@ public abstract class TradeStepView extends AnchorPane {
});
}
if (peerTxIdTextField != null) {
if (takerTxIdSubscription != null)
takerTxIdSubscription.unsubscribe();
if (peerTxIdSubscription != null)
peerTxIdSubscription.unsubscribe();
takerTxIdSubscription = EasyBind.subscribe(model.dataModel.takerTxId, id -> {
selfTxIdSubscription = EasyBind.subscribe(model.dataModel.isMaker() ? model.dataModel.takerTxId : model.dataModel.makerTxId, id -> {
if (!id.isEmpty())
peerTxIdTextField.setup(id);
else
@ -288,10 +284,10 @@ public abstract class TradeStepView extends AnchorPane {
}
public void deactivate() {
if (makerTxIdSubscription != null)
makerTxIdSubscription.unsubscribe();
if (takerTxIdSubscription != null)
takerTxIdSubscription.unsubscribe();
if (selfTxIdSubscription != null)
selfTxIdSubscription.unsubscribe();
if (peerTxIdSubscription != null)
peerTxIdSubscription.unsubscribe();
if (selfTxIdTextField != null)
selfTxIdTextField.cleanup();

View file

@ -155,7 +155,7 @@ public class BuyerStep2View extends TradeStepView {
if (timeoutTimer != null)
timeoutTimer.stop();
if (trade.isDepositConfirmed() && !trade.isPaymentSent()) {
if (trade.isDepositUnlocked() && !trade.isPaymentSent()) {
showPopup();
} else if (state.ordinal() <= Trade.State.BUYER_SEND_FAILED_PAYMENT_SENT_MSG.ordinal()) {
if (!trade.hasFailed()) {

View file

@ -136,6 +136,7 @@ public class SellerStep3View extends TradeStepView {
busyAnimation.stop();
statusLabel.setText(Res.get("shared.messageArrived"));
break;
case SELLER_STORED_IN_MAILBOX_PAYMENT_RECEIVED_MSG:
case SELLER_STORED_IN_MAILBOX_PAYOUT_TX_PUBLISHED_MSG:
busyAnimation.stop();
statusLabel.setText(Res.get("shared.messageStoredInMailbox"));

View file

@ -65,7 +65,6 @@ import bisq.common.util.Utilities;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.Coin;
import org.bitcoinj.core.TransactionConfidence;
import org.bitcoinj.uri.BitcoinURI;
import com.googlecode.jcsv.CSVStrategy;
@ -135,7 +134,7 @@ import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import lombok.extern.slf4j.Slf4j;
import monero.wallet.model.MoneroTxWallet;
import monero.daemon.model.MoneroTx;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
@ -567,7 +566,7 @@ public class GUIUtil {
};
}
public static void updateConfidence(MoneroTxWallet tx,
public static void updateConfidence(MoneroTx tx,
Tooltip tooltip,
TxConfidenceIndicator txConfidenceIndicator) {
if (tx != null) {