improve error handling on payment received message (#1327)

This commit is contained in:
woodser 2024-10-13 08:32:26 -04:00 committed by GitHub
parent a6c178c058
commit e811e2b224
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -161,11 +161,11 @@ public class ProcessPaymentReceivedMessage extends TradeTask {
// verify and publish payout tx // verify and publish payout tx
if (!trade.isPayoutPublished()) { if (!trade.isPayoutPublished()) {
try {
if (isSigned) { if (isSigned) {
log.info("{} {} publishing signed payout tx from seller", trade.getClass().getSimpleName(), trade.getId()); log.info("{} {} publishing signed payout tx from seller", trade.getClass().getSimpleName(), trade.getId());
trade.processPayoutTx(message.getSignedPayoutTxHex(), false, true); trade.processPayoutTx(message.getSignedPayoutTxHex(), false, true);
} else { } else {
try {
PaymentSentMessage paymentSentMessage = (trade.isArbitrator() ? trade.getBuyer() : trade.getArbitrator()).getPaymentSentMessage(); PaymentSentMessage paymentSentMessage = (trade.isArbitrator() ? trade.getBuyer() : trade.getArbitrator()).getPaymentSentMessage();
if (paymentSentMessage == null) throw new RuntimeException("Process model does not have payment sent message for " + trade.getClass().getSimpleName() + " " + trade.getId()); if (paymentSentMessage == null) throw new RuntimeException("Process model does not have payment sent message for " + trade.getClass().getSimpleName() + " " + trade.getId());
if (trade.getPayoutTxHex() == null) { // unsigned if (trade.getPayoutTxHex() == null) { // unsigned
@ -175,6 +175,7 @@ public class ProcessPaymentReceivedMessage extends TradeTask {
log.info("{} {} re-verifying and publishing signed payout tx", trade.getClass().getSimpleName(), trade.getId()); log.info("{} {} re-verifying and publishing signed payout tx", trade.getClass().getSimpleName(), trade.getId());
trade.processPayoutTx(trade.getPayoutTxHex(), false, true); trade.processPayoutTx(trade.getPayoutTxHex(), false, true);
} }
}
} catch (Exception e) { } catch (Exception e) {
HavenoUtils.waitFor(trade.getXmrConnectionService().getRefreshPeriodMs()); // wait to see published tx HavenoUtils.waitFor(trade.getXmrConnectionService().getRefreshPeriodMs()); // wait to see published tx
trade.syncAndPollWallet(); trade.syncAndPollWallet();
@ -182,7 +183,6 @@ public class ProcessPaymentReceivedMessage extends TradeTask {
else throw e; else throw e;
} }
} }
}
} else { } else {
log.info("Payout tx already published for {} {}", trade.getClass().getSimpleName(), trade.getId()); log.info("Payout tx already published for {} {}", trade.getClass().getSimpleName(), trade.getId());
if (message.getSignedPayoutTxHex() != null && !trade.isPayoutConfirmed()) trade.processPayoutTx(message.getSignedPayoutTxHex(), false, true); if (message.getSignedPayoutTxHex() != null && !trade.isPayoutConfirmed()) trade.processPayoutTx(message.getSignedPayoutTxHex(), false, true);