mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-01-03 17:40:10 +00:00
process unposted offers after app bootstrapped
This commit is contained in:
parent
290912c333
commit
5c6ef41511
1 changed files with 32 additions and 32 deletions
|
@ -287,38 +287,6 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanUpAddressEntries();
|
cleanUpAddressEntries();
|
||||||
|
|
||||||
// TODO: add to invalid offers on failure
|
|
||||||
// openOffers.stream()
|
|
||||||
// .forEach(openOffer -> OfferUtil.getInvalidMakerFeeTxErrorMessage(openOffer.getOffer(), btcWalletService)
|
|
||||||
// .ifPresent(errorMsg -> invalidOffers.add(new Tuple2<>(openOffer, errorMsg))));
|
|
||||||
|
|
||||||
// process unposted offers
|
|
||||||
processUnpostedOffers((transaction) -> {}, (errorMessage) -> {
|
|
||||||
log.warn("Error processing unposted offers: " + errorMessage);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 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 == null || lastUnlockedBalance.compareTo(newUnlockedBalance) < 0) {
|
|
||||||
processUnpostedOffers((transaction) -> {}, (errorMessage) -> {
|
|
||||||
log.warn("Error processing unposted offers on new unlocked balance: " + errorMessage); // TODO: popup to notify user that offer did not post
|
|
||||||
});
|
|
||||||
}
|
|
||||||
lastUnlockedBalance = newUnlockedBalance;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// initialize key image poller for signed offers
|
|
||||||
maybeInitializeKeyImagePoller();
|
|
||||||
|
|
||||||
// poll spent status of key images
|
|
||||||
for (SignedOffer signedOffer : signedOffers.getList()) {
|
|
||||||
signedOfferKeyImagePoller.addKeyImages(signedOffer.getReserveTxKeyImages());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanUpAddressEntries() {
|
private void cleanUpAddressEntries() {
|
||||||
|
@ -449,6 +417,38 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
||||||
REPUBLISH_AGAIN_AT_STARTUP_DELAY_SEC);
|
REPUBLISH_AGAIN_AT_STARTUP_DELAY_SEC);
|
||||||
|
|
||||||
p2PService.getPeerManager().addListener(this);
|
p2PService.getPeerManager().addListener(this);
|
||||||
|
|
||||||
|
// TODO: add to invalid offers on failure
|
||||||
|
// openOffers.stream()
|
||||||
|
// .forEach(openOffer -> OfferUtil.getInvalidMakerFeeTxErrorMessage(openOffer.getOffer(), btcWalletService)
|
||||||
|
// .ifPresent(errorMsg -> invalidOffers.add(new Tuple2<>(openOffer, errorMsg))));
|
||||||
|
|
||||||
|
// process unposted offers
|
||||||
|
processUnpostedOffers((transaction) -> {}, (errorMessage) -> {
|
||||||
|
log.warn("Error processing unposted offers: " + errorMessage);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 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 == null || lastUnlockedBalance.compareTo(newUnlockedBalance) < 0) {
|
||||||
|
processUnpostedOffers((transaction) -> {}, (errorMessage) -> {
|
||||||
|
log.warn("Error processing unposted offers on new unlocked balance: " + errorMessage); // TODO: popup to notify user that offer did not post
|
||||||
|
});
|
||||||
|
}
|
||||||
|
lastUnlockedBalance = newUnlockedBalance;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// initialize key image poller for signed offers
|
||||||
|
maybeInitializeKeyImagePoller();
|
||||||
|
|
||||||
|
// poll spent status of key images
|
||||||
|
for (SignedOffer signedOffer : signedOffers.getList()) {
|
||||||
|
signedOfferKeyImagePoller.addKeyImages(signedOffer.getReserveTxKeyImages());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue