set height on trade initialization (#1960)

* set height on trade initialization

* avoid warning about assuming payouts finalized
This commit is contained in:
woodser 2025-09-15 14:00:44 -04:00 committed by GitHub
parent 298f48e6f6
commit a67e3d3dab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 3 deletions

View file

@ -814,6 +814,7 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
}
// poll wallet without network calls
walletHeight.set(wallet.getHeight());
doPollWallet(true);
// trade is initialized
@ -2464,6 +2465,7 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
// TODO: state can be past finalized (e.g. payment_sent) before the deposits are finalized, ideally use separate enum for deposits, or a single published state + num confirmations
if (minDepositTxConfirmations == null) {
log.warn("Assuming that deposit txs are finalized for trade {} {} because trade is in phase {} but has unknown confirmations", getClass().getSimpleName(), getShortId(), getState().getPhase());
Thread.dumpStack();
return true;
}
return minDepositTxConfirmations >= NUM_BLOCKS_DEPOSITS_FINALIZED;
@ -2804,7 +2806,7 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
if (getWallet() == null) throw new IllegalStateException("Cannot sync trade wallet because it doesn't exist for " + getClass().getSimpleName() + ", " + getId());
if (getWallet().getDaemonConnection() == null) throw new RuntimeException("Cannot sync trade wallet because it's not connected to a Monero daemon for " + getClass().getSimpleName() + ", " + getId());
if (isWalletBehind()) {
log.info("Syncing wallet for {} {}", getShortId(), getClass().getSimpleName());
log.info("Syncing wallet for {} {} from height {}", getShortId(), getClass().getSimpleName(), walletHeight.get());
long startTime = System.currentTimeMillis();
syncWalletIfBehind();
log.info("Done syncing wallet for {} {} in {} ms", getShortId(), getClass().getSimpleName(), System.currentTimeMillis() - startTime);

View file

@ -1462,7 +1462,7 @@ public class XmrWalletService extends XmrWalletBase {
}
// sync main wallet
log.info("Syncing main wallet");
log.info("Syncing main wallet from height " + walletHeight.get());
long time = System.currentTimeMillis();
MoneroRpcConnection sourceConnection = xmrConnectionService.getConnection();
try {

View file

@ -235,7 +235,7 @@ public class BuyerStep2View extends TradeStepView {
// attach grid pane based on current state
EasyBind.subscribe(trade.statePhaseProperty(), newValue -> {
if (trade.isDepositsFinalized() || trade.isPaymentSent() || model.getShowPaymentDetailsEarly()) {
if (trade.isPaymentSent() || model.getShowPaymentDetailsEarly() || trade.isDepositsFinalized()) {
attachPaymentDetailsGrid();
} else {
attachRecommendationGrid();