fix reserved balance = frozen offer outputs + confirmed deposits

This commit is contained in:
woodser 2022-07-10 18:07:20 -04:00
parent 5ebafecd8f
commit 008210abf6

View file

@ -40,8 +40,10 @@ import javafx.collections.ListChangeListener;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.Getter; import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import monero.common.MoneroError;
import monero.wallet.model.MoneroOutputQuery; import monero.wallet.model.MoneroOutputQuery;
import monero.wallet.model.MoneroOutputWallet; import monero.wallet.model.MoneroOutputWallet;
import monero.wallet.model.MoneroTxWallet;
import org.bitcoinj.core.Coin; import org.bitcoinj.core.Coin;
@Slf4j @Slf4j
@ -128,6 +130,12 @@ public class Balances {
Coin sum = Coin.valueOf(0); Coin sum = Coin.valueOf(0);
List<Trade> openTrades = tradeManager.getTradesStreamWithFundsLockedIn().collect(Collectors.toList()); List<Trade> openTrades = tradeManager.getTradesStreamWithFundsLockedIn().collect(Collectors.toList());
for (Trade trade : openTrades) { for (Trade trade : openTrades) {
try {
MoneroTxWallet depositTx = xmrWalletService.getWallet().getTx(trade.getSelf().getDepositTxHash());
if (!depositTx.isConfirmed()) continue; // outputs are frozen until confirmed by arbitrator's broadcast
} catch (MoneroError e) {
continue;
}
if (trade.getContract() == null) continue; if (trade.getContract() == null) continue;
Long reservedAmt; Long reservedAmt;
OfferPayload offerPayload = trade.getContract().getOfferPayload(); OfferPayload offerPayload = trade.getContract().getOfferPayload();