Skip to content

Commit d78709e

Browse files
authored
start trade period from unlock time instead of first confirmation
1 parent 34b55bc commit d78709e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

core/src/main/java/haveno/core/trade/Trade.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,18 +2167,19 @@ private void setStartTimeFromUnlockedTxs() {
21672167
if (daemonRpc == null) throw new RuntimeException("Cannot set start time for trade " + getId() + " because it has no connection to monerod");
21682168
if (getMakerDepositTx() == null || (getTakerDepositTx() == null && !hasBuyerAsTakerWithoutDeposit())) throw new RuntimeException("Cannot set start time for trade " + getId() + " because its unlocked deposit tx is null. Is client connected to a daemon?");
21692169

2170-
long maxHeight = Math.max(getMakerDepositTx().getHeight(), hasBuyerAsTakerWithoutDeposit() ? 0l : getTakerDepositTx().getHeight());
2171-
long blockTime = daemonRpc.getBlockByHeight(maxHeight).getTimestamp();
2170+
// get unlock time of last deposit tx
2171+
long unlockHeight = Math.max(getMakerDepositTx().getHeight() + XmrWalletService.NUM_BLOCKS_UNLOCK - 1, hasBuyerAsTakerWithoutDeposit() ? 0l : getTakerDepositTx().getHeight() + XmrWalletService.NUM_BLOCKS_UNLOCK - 1);
2172+
long unlockTime = daemonRpc.getBlockByHeight(unlockHeight).getTimestamp() * 1000;
21722173

21732174
// If block date is in future (Date in blocks can be off by +/- 2 hours) we use our current date.
21742175
// If block date is earlier than our trade date we use our trade date.
2175-
if (blockTime > now)
2176+
if (unlockTime > now)
21762177
startTime = now;
21772178
else
2178-
startTime = Math.max(blockTime, tradeTime);
2179+
startTime = Math.max(unlockTime, tradeTime);
21792180

21802181
log.debug("We set the start for the trade period to {}. Trade started at: {}. Block got mined at: {}",
2181-
new Date(startTime), new Date(tradeTime), new Date(blockTime));
2182+
new Date(startTime), new Date(tradeTime), new Date(unlockTime));
21822183
}
21832184

21842185
public boolean hasFailed() {

0 commit comments

Comments
 (0)