From e33d93eee8790a64553a248f8602d43865772ae4 Mon Sep 17 00:00:00 2001 From: woodser Date: Sat, 21 May 2022 07:17:17 -0400 Subject: [PATCH] fix npe on startup without monerod connection --- .../main/java/bisq/core/offer/OpenOfferManager.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/bisq/core/offer/OpenOfferManager.java b/core/src/main/java/bisq/core/offer/OpenOfferManager.java index ce32c9d8..e1751897 100644 --- a/core/src/main/java/bisq/core/offer/OpenOfferManager.java +++ b/core/src/main/java/bisq/core/offer/OpenOfferManager.java @@ -229,16 +229,16 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe .ifPresent(errorMsg -> invalidOffers.add(new Tuple2<>(openOffer, errorMsg)))); // process unposted offers - lastUnlockedBalance = xmrWalletService.getWallet().getUnlockedBalance(0); processUnpostedOffers((transaction) -> {}, (errMessage) -> { log.warn("Error processing unposted offers on new unlocked balance: " + errMessage); }); // register to process unposted offers when unlocked balance increases + if (xmrWalletService.getWallet() != null) lastUnlockedBalance = xmrWalletService.getWallet().getUnlockedBalance(0); xmrWalletService.addWalletListener(new MoneroWalletListener() { @Override public void onBalancesChanged(BigInteger newBalance, BigInteger newUnlockedBalance) { - if (lastUnlockedBalance.compareTo(newUnlockedBalance) < 0) { + if (lastUnlockedBalance == null || lastUnlockedBalance.compareTo(newUnlockedBalance) < 0) { processUnpostedOffers((transaction) -> {}, (errMessage) -> { log.warn("Error processing unposted offers on new unlocked balance: " + errMessage); }); @@ -642,6 +642,12 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe private void processUnpostedOffer(OpenOffer openOffer, TransactionResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) { try { + // done processing if wallet not initialized + if (xmrWalletService.getWallet() == null) { + resultHandler.handleResult(null); + return; + } + // get offer reserve amount Coin offerReserveAmountCoin = openOffer.getOffer().getReserveAmount(); BigInteger offerReserveAmount = ParsingUtils.centinerosToAtomicUnits(offerReserveAmountCoin.value);