mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-10-01 01:35:48 -04:00
fix npe on startup without monerod connection
This commit is contained in:
parent
052180eed7
commit
e33d93eee8
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user