Skip to content

Commit 222dada

Browse files
committed
reset state before nacking payment received message
1 parent ec08906 commit 222dada

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ public MoneroTxWallet createPayoutTx() {
12851285
MoneroRpcConnection sourceConnection = xmrConnectionService.getConnection();
12861286
try {
12871287
MoneroTxWallet unsignedPayoutTx = doCreatePayoutTx();
1288-
log.info("Created unsigned payout tx for {} {}");
1288+
log.info("Done creating unsigned payout tx for {} {}", getClass().getSimpleName(), getShortId());
12891289
return unsignedPayoutTx;
12901290
} catch (IllegalArgumentException | IllegalStateException e) {
12911291
throw e;
@@ -2873,6 +2873,10 @@ else if (hasFailedTx && isPayoutPublished()) {
28732873
}
28742874
}
28752875

2876+
public boolean onPayoutError(boolean syncAndPoll) {
2877+
return onPayoutError(syncAndPoll, false);
2878+
}
2879+
28762880
/**
28772881
* Handle a payout error due to NACK or the transaction failing (e.g. due to reorg).
28782882
*
@@ -2883,15 +2887,21 @@ else if (hasFailedTx && isPayoutPublished()) {
28832887
public boolean onPayoutError(boolean syncAndPoll, boolean autoMarkPaymentReceived) {
28842888
log.warn("Handling payout error for {} {}", getClass().getSimpleName(), getId());
28852889
if (isPayoutPublished()) return false;
2886-
if (syncAndPoll) syncAndPollWallet();
2890+
if (syncAndPoll) {
2891+
try {
2892+
syncAndPollWallet();
2893+
} catch (Exception e) {
2894+
log.warn("Error syncing and polling wallet for {} {}: {}", getClass().getSimpleName(), getId(), e.getMessage());
2895+
}
2896+
}
28872897
if (isPayoutPublished() || !isPaymentReceived()) return false;
28882898

28892899
// reset trade state
2890-
log.warn("Resetting state to payment sent for {} {}", getClass().getSimpleName(), getId());
2900+
log.warn("Resetting state to PAYMENT_SENT for {} {}", getClass().getSimpleName(), getId());
28912901
resetToPaymentSentState();
28922902
getProcessModel().setPaymentSentPayoutTxStale(true);
28932903
getSelf().setUnsignedPayoutTxHex(null);
2894-
requestPersistence();
2904+
persistNow(null);
28952905

28962906
// automatically mark payment received
28972907
if (autoMarkPaymentReceived) {

core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import haveno.common.handlers.ErrorMessageHandler;
4343
import haveno.common.proto.network.NetworkEnvelope;
4444
import haveno.common.taskrunner.Task;
45-
import haveno.core.network.MessageState;
4645
import haveno.core.offer.OpenOffer;
4746
import haveno.core.support.messages.ChatMessage;
4847
import haveno.core.trade.ArbitratorTrade;
@@ -683,7 +682,12 @@ private void handle(PaymentReceivedMessage message, NodeAddress peer, boolean re
683682
}, trade.getReprocessDelayInSeconds(reprocessPaymentReceivedMessageCount));
684683
}
685684
} else {
686-
trade.exportMultisigHex(); // export fresh multisig info for nack
685+
686+
// export fresh multisig info for nack
687+
trade.exportMultisigHex();
688+
689+
// handle payout error
690+
trade.onPayoutError(false, false);
687691
handleTaskRunnerFault(peer, message, null, errorMessage, trade.getSelf().getUpdatedMultisigHex()); // send nack
688692
}
689693
unlatchTrade();

0 commit comments

Comments
 (0)