refactor base wallet so trades can sync with progress timeout, etc

This commit is contained in:
woodser 2024-08-04 13:26:59 -04:00
parent 1b5c03bce8
commit ca7d596175
23 changed files with 247 additions and 226 deletions

View file

@ -197,7 +197,7 @@ public class TxIdTextField extends AnchorPane {
try {
if (trade == null) {
tx = useCache ? xmrWalletService.getDaemonTxWithCache(txId) : xmrWalletService.getDaemonTx(txId);
tx.setNumConfirmations(tx.isConfirmed() ? (height == null ? xmrWalletService.getConnectionService().getLastInfo().getHeight() : height) - tx.getHeight(): 0l); // TODO: don't set if tx.getNumConfirmations() works reliably on non-local testnet
tx.setNumConfirmations(tx.isConfirmed() ? (height == null ? xmrWalletService.getXmrConnectionService().getLastInfo().getHeight() : height) - tx.getHeight(): 0l); // TODO: don't set if tx.getNumConfirmations() works reliably on non-local testnet
} else {
if (txId.equals(trade.getMaker().getDepositTxHash())) tx = trade.getMakerDepositTx();
else if (txId.equals(trade.getTaker().getDepositTxHash())) tx = trade.getTakerDepositTx();

View file

@ -257,7 +257,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
// create tx
MoneroTxWallet tx = null;
for (int i = 0; i < TradeProtocol.MAX_ATTEMPTS; i++) {
MoneroRpcConnection sourceConnection = xmrWalletService.getConnectionService().getConnection();
MoneroRpcConnection sourceConnection = xmrWalletService.getXmrConnectionService().getConnection();
try {
log.info("Creating withdraw tx");
long startTime = System.currentTimeMillis();
@ -272,7 +272,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
if (isNotEnoughMoney(e.getMessage())) throw e;
log.warn("Error creating creating withdraw tx, attempt={}/{}, error={}", i + 1, TradeProtocol.MAX_ATTEMPTS, e.getMessage());
if (i == TradeProtocol.MAX_ATTEMPTS - 1) throw e;
if (xmrWalletService.getConnectionService().isConnected()) xmrWalletService.requestSwitchToNextBestConnection(sourceConnection);
if (xmrWalletService.getXmrConnectionService().isConnected()) xmrWalletService.requestSwitchToNextBestConnection(sourceConnection);
HavenoUtils.waitFor(TradeProtocol.REPROCESS_DELAY_MS); // wait before retrying
}
}

View file

@ -701,7 +701,7 @@ public class GUIUtil {
}
public static boolean isReadyForTxBroadcastOrShowPopup(XmrWalletService xmrWalletService) {
XmrConnectionService xmrConnectionService = xmrWalletService.getConnectionService();
XmrConnectionService xmrConnectionService = xmrWalletService.getXmrConnectionService();
if (!xmrConnectionService.hasSufficientPeersForBroadcast()) {
new Popup().information(Res.get("popup.warning.notSufficientConnectionsToXmrNetwork", xmrConnectionService.getMinBroadcastConnections())).show();
return false;