diff --git a/core/src/main/java/haveno/core/offer/CreateOfferService.java b/core/src/main/java/haveno/core/offer/CreateOfferService.java index f79c4c7f56..afd4366a3b 100644 --- a/core/src/main/java/haveno/core/offer/CreateOfferService.java +++ b/core/src/main/java/haveno/core/offer/CreateOfferService.java @@ -203,7 +203,7 @@ public class CreateOfferService { bankId, acceptedBanks, Version.VERSION, - xmrWalletService.getWallet().getHeight(), + xmrWalletService.getHeight(), maxTradeLimit, maxTradePeriod, useAutoClose, diff --git a/core/src/main/java/haveno/core/offer/OpenOfferManager.java b/core/src/main/java/haveno/core/offer/OpenOfferManager.java index 0bd4b0b169..d1f576fabb 100644 --- a/core/src/main/java/haveno/core/offer/OpenOfferManager.java +++ b/core/src/main/java/haveno/core/offer/OpenOfferManager.java @@ -472,7 +472,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe }); // register to process unposted offers when unlocked balance increases - if (xmrWalletService.getWallet() != null) lastUnlockedBalance = xmrWalletService.getWallet().getUnlockedBalance(0); + if (xmrWalletService.getWallet() != null) lastUnlockedBalance = xmrWalletService.getAvailableBalance(); xmrWalletService.addWalletListener(new MoneroWalletListener() { @Override public void onBalancesChanged(BigInteger newBalance, BigInteger newUnlockedBalance) { @@ -916,7 +916,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe } else { // handle sufficient balance - boolean hasSufficientBalance = xmrWalletService.getWallet().getUnlockedBalance(0).compareTo(amountNeeded) >= 0; + boolean hasSufficientBalance = xmrWalletService.getAvailableBalance().compareTo(amountNeeded) >= 0; if (hasSufficientBalance) { signAndPostOffer(openOffer, true, resultHandler, errorMessageHandler); return; @@ -1025,7 +1025,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe private void splitOrSchedule(List openOffers, OpenOffer openOffer, BigInteger offerReserveAmount) { // handle sufficient available balance to split output - boolean sufficientAvailableBalance = xmrWalletService.getWallet().getUnlockedBalance(0).compareTo(offerReserveAmount) >= 0; + boolean sufficientAvailableBalance = xmrWalletService.getAvailableBalance().compareTo(offerReserveAmount) >= 0; if (sufficientAvailableBalance) { log.info("Splitting and scheduling outputs for offer {} at subaddress {}", openOffer.getShortId()); splitAndSchedule(openOffer); @@ -1073,7 +1073,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe // check for sufficient balance - scheduled offers amount BigInteger offerReserveAmount = openOffer.getOffer().getAmountNeeded(); - if (xmrWalletService.getWallet().getBalance(0).subtract(getScheduledAmount(openOffers)).compareTo(offerReserveAmount) < 0) { + if (xmrWalletService.getBalance().subtract(getScheduledAmount(openOffers)).compareTo(offerReserveAmount) < 0) { throw new RuntimeException("Not enough money in Haveno wallet"); } @@ -1105,7 +1105,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe for (OpenOffer openOffer : openOffers) { if (openOffer.getState() != OpenOffer.State.SCHEDULED) continue; if (openOffer.getScheduledTxHashes() == null) continue; - List fundingTxs = xmrWalletService.getWallet().getTxs(openOffer.getScheduledTxHashes()); + List fundingTxs = xmrWalletService.getTxs(openOffer.getScheduledTxHashes()); for (MoneroTxWallet fundingTx : fundingTxs) { if (fundingTx.getIncomingTransfers() != null) { for (MoneroIncomingTransfer transfer : fundingTx.getIncomingTransfers()) { diff --git a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java index b1780134c1..29c6fe8872 100644 --- a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java +++ b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java @@ -1140,6 +1140,10 @@ public class XmrWalletService { xmrAddressEntryList.requestPersistence(); } + public long getHeight() { + return walletHeight.get(); + } + public List getTxs(boolean includeFailed) { List txs = getTxs(); if (includeFailed) return txs; @@ -1158,6 +1162,10 @@ public class XmrWalletService { return cachedTxs.stream().filter(tx -> query.meetsCriteria(tx)).collect(Collectors.toList()); } + public List getTxs(List txIds) { + return getTxs(new MoneroTxQuery().setHashes(txIds)); + } + public MoneroTxWallet getTx(String txId) { List txs = getTxs(new MoneroTxQuery().setHash(txId)); return txs.isEmpty() ? null : txs.get(0); diff --git a/desktop/src/main/java/haveno/desktop/components/AddressTextField.java b/desktop/src/main/java/haveno/desktop/components/AddressTextField.java index 96a7aecc43..ec6f284379 100644 --- a/desktop/src/main/java/haveno/desktop/components/AddressTextField.java +++ b/desktop/src/main/java/haveno/desktop/components/AddressTextField.java @@ -22,7 +22,6 @@ import de.jensd.fx.fontawesome.AwesomeDude; import de.jensd.fx.fontawesome.AwesomeIcon; import haveno.common.util.Utilities; import haveno.core.locale.Res; -import haveno.core.trade.HavenoUtils; import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.util.GUIUtil; import javafx.beans.property.ObjectProperty; @@ -158,7 +157,6 @@ public class AddressTextField extends AnchorPane { return GUIUtil.getMoneroURI( address.get(), amount.get(), - paymentLabel.get(), - HavenoUtils.havenoSetup.getXmrWalletService().getWallet()); + paymentLabel.get()); } } diff --git a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferView.java b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferView.java index a3e27d3000..d9b41071ee 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferView.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferView.java @@ -1214,8 +1214,7 @@ public abstract class MutableOfferView> exten return GUIUtil.getMoneroURI( addressTextField.getAddress(), model.getDataModel().getMissingCoin().get(), - model.getPaymentLabel(), - model.dataModel.getXmrWalletService().getWallet()); + model.getPaymentLabel()); } private void addAmountPriceFields() { diff --git a/desktop/src/main/java/haveno/desktop/main/offer/takeoffer/TakeOfferView.java b/desktop/src/main/java/haveno/desktop/main/offer/takeoffer/TakeOfferView.java index 7599faad7e..a4d65bc73d 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/takeoffer/TakeOfferView.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/takeoffer/TakeOfferView.java @@ -950,8 +950,7 @@ public class TakeOfferView extends ActivatableViewAndModel