Skip to content

Commit

Permalink
improve error handling on payment received message
Browse files Browse the repository at this point in the history
  • Loading branch information
woodser committed Oct 13, 2024
1 parent 5352225 commit 997c1fc
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ private void processPayoutTx(PaymentReceivedMessage message) {

// verify and publish payout tx
if (!trade.isPayoutPublished()) {
if (isSigned) {
log.info("{} {} publishing signed payout tx from seller", trade.getClass().getSimpleName(), trade.getId());
trade.processPayoutTx(message.getSignedPayoutTxHex(), false, true);
} else {
try {
try {
if (isSigned) {
log.info("{} {} publishing signed payout tx from seller", trade.getClass().getSimpleName(), trade.getId());
trade.processPayoutTx(message.getSignedPayoutTxHex(), false, true);
} else {
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 (trade.getPayoutTxHex() == null) { // unsigned
Expand All @@ -175,12 +175,12 @@ private void processPayoutTx(PaymentReceivedMessage message) {
log.info("{} {} re-verifying and publishing signed payout tx", trade.getClass().getSimpleName(), trade.getId());
trade.processPayoutTx(trade.getPayoutTxHex(), false, true);
}
} catch (Exception e) {
HavenoUtils.waitFor(trade.getXmrConnectionService().getRefreshPeriodMs()); // wait to see published tx
trade.syncAndPollWallet();
if (trade.isPayoutPublished()) log.info("Payout tx already published for {} {}", trade.getClass().getName(), trade.getId());
else throw e;
}
} catch (Exception e) {
HavenoUtils.waitFor(trade.getXmrConnectionService().getRefreshPeriodMs()); // wait to see published tx
trade.syncAndPollWallet();
if (trade.isPayoutPublished()) log.info("Payout tx already published for {} {}", trade.getClass().getName(), trade.getId());
else throw e;
}
}
} else {
Expand Down

0 comments on commit 997c1fc

Please sign in to comment.