mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-01-03 17:40:10 +00:00
fix npe on startup without monerod connection
This commit is contained in:
parent
052180eed7
commit
e33d93eee8
1 changed files with 8 additions and 2 deletions
|
@ -229,16 +229,16 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
||||||
.ifPresent(errorMsg -> invalidOffers.add(new Tuple2<>(openOffer, errorMsg))));
|
.ifPresent(errorMsg -> invalidOffers.add(new Tuple2<>(openOffer, errorMsg))));
|
||||||
|
|
||||||
// process unposted offers
|
// process unposted offers
|
||||||
lastUnlockedBalance = xmrWalletService.getWallet().getUnlockedBalance(0);
|
|
||||||
processUnpostedOffers((transaction) -> {}, (errMessage) -> {
|
processUnpostedOffers((transaction) -> {}, (errMessage) -> {
|
||||||
log.warn("Error processing unposted offers on new unlocked balance: " + errMessage);
|
log.warn("Error processing unposted offers on new unlocked balance: " + errMessage);
|
||||||
});
|
});
|
||||||
|
|
||||||
// register to process unposted offers when unlocked balance increases
|
// register to process unposted offers when unlocked balance increases
|
||||||
|
if (xmrWalletService.getWallet() != null) lastUnlockedBalance = xmrWalletService.getWallet().getUnlockedBalance(0);
|
||||||
xmrWalletService.addWalletListener(new MoneroWalletListener() {
|
xmrWalletService.addWalletListener(new MoneroWalletListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onBalancesChanged(BigInteger newBalance, BigInteger newUnlockedBalance) {
|
public void onBalancesChanged(BigInteger newBalance, BigInteger newUnlockedBalance) {
|
||||||
if (lastUnlockedBalance.compareTo(newUnlockedBalance) < 0) {
|
if (lastUnlockedBalance == null || lastUnlockedBalance.compareTo(newUnlockedBalance) < 0) {
|
||||||
processUnpostedOffers((transaction) -> {}, (errMessage) -> {
|
processUnpostedOffers((transaction) -> {}, (errMessage) -> {
|
||||||
log.warn("Error processing unposted offers on new unlocked balance: " + 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) {
|
private void processUnpostedOffer(OpenOffer openOffer, TransactionResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
// done processing if wallet not initialized
|
||||||
|
if (xmrWalletService.getWallet() == null) {
|
||||||
|
resultHandler.handleResult(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// get offer reserve amount
|
// get offer reserve amount
|
||||||
Coin offerReserveAmountCoin = openOffer.getOffer().getReserveAmount();
|
Coin offerReserveAmountCoin = openOffer.getOffer().getReserveAmount();
|
||||||
BigInteger offerReserveAmount = ParsingUtils.centinerosToAtomicUnits(offerReserveAmountCoin.value);
|
BigInteger offerReserveAmount = ParsingUtils.centinerosToAtomicUnits(offerReserveAmountCoin.value);
|
||||||
|
|
Loading…
Reference in a new issue