Skip to content

Commit 0554a0d

Browse files
committed
prepare payment received message skips payout tx if published
1 parent 82f805a commit 0554a0d

File tree

1 file changed

+38
-33
lines changed

1 file changed

+38
-33
lines changed

core/src/main/java/haveno/core/trade/protocol/tasks/SellerPreparePaymentReceivedMessage.java

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -40,48 +40,53 @@ protected void run() {
4040
// check connection
4141
trade.verifyDaemonConnection();
4242

43-
// handle first time preparation
44-
if (trade.getArbitrator().getPaymentReceivedMessage() == null) {
43+
// process payout tx if unpublished
44+
if (!trade.isPayoutPublished()) {
4545

46-
// synchronize on lock for wallet operations
47-
synchronized (trade.getWalletLock()) {
48-
synchronized (HavenoUtils.getWalletFunctionLock()) {
46+
// handle first time preparation
47+
if (trade.getArbitrator().getPaymentReceivedMessage() == null) {
4948

50-
// import multisig hex unless already signed
51-
if (trade.getPayoutTxHex() == null) {
52-
trade.importMultisigHex();
53-
}
49+
// synchronize on lock for wallet operations
50+
synchronized (trade.getWalletLock()) {
51+
synchronized (HavenoUtils.getWalletFunctionLock()) {
52+
53+
// import multisig hex unless already signed
54+
if (trade.getPayoutTxHex() == null) {
55+
trade.importMultisigHex();
56+
}
5457

55-
// verify, sign, and publish payout tx if given
56-
if (trade.getBuyer().getPaymentSentMessage().getPayoutTxHex() != null && !trade.getProcessModel().isPaymentSentPayoutTxStale()) {
57-
try {
58-
if (trade.getPayoutTxHex() == null) {
59-
log.info("Seller verifying, signing, and publishing payout tx for trade {}", trade.getId());
60-
trade.processPayoutTx(trade.getBuyer().getPaymentSentMessage().getPayoutTxHex(), true, true);
61-
} else {
62-
log.warn("Seller publishing previously signed payout tx for trade {}", trade.getId());
63-
trade.processPayoutTx(trade.getPayoutTxHex(), false, true);
58+
// verify, sign, and publish payout tx if given
59+
if (trade.getBuyer().getPaymentSentMessage().getPayoutTxHex() != null && !trade.getProcessModel().isPaymentSentPayoutTxStale()) {
60+
try {
61+
if (trade.getPayoutTxHex() == null) {
62+
log.info("Seller verifying, signing, and publishing payout tx for trade {}", trade.getId());
63+
if (true) throw new IllegalArgumentException("Actually lets create the transaction anew");
64+
trade.processPayoutTx(trade.getBuyer().getPaymentSentMessage().getPayoutTxHex(), true, true);
65+
} else {
66+
log.warn("Seller publishing previously signed payout tx for trade {}", trade.getId());
67+
trade.processPayoutTx(trade.getPayoutTxHex(), false, true);
68+
}
69+
} catch (IllegalArgumentException | IllegalStateException e) {
70+
log.warn("Illegal state or argument verifying, signing, and publishing payout tx for {} {}. Creating new unsigned payout tx. error={}. ", trade.getClass().getSimpleName(), trade.getId(), e.getMessage(), e);
71+
createUnsignedPayoutTx();
72+
} catch (Exception e) {
73+
log.warn("Error verifying, signing, and publishing payout tx for trade {}: {}", trade.getId(), e.getMessage(), e);
74+
throw e;
6475
}
65-
} catch (IllegalArgumentException | IllegalStateException e) {
66-
log.warn("Illegal state or argument verifying, signing, and publishing payout tx for {} {}. Creating new unsigned payout tx. error={}. ", trade.getClass().getSimpleName(), trade.getId(), e.getMessage(), e);
76+
}
77+
78+
// otherwise create unsigned payout tx
79+
else if (trade.getSelf().getUnsignedPayoutTxHex() == null) {
6780
createUnsignedPayoutTx();
68-
} catch (Exception e) {
69-
log.warn("Error verifying, signing, and publishing payout tx for trade {}: {}", trade.getId(), e.getMessage(), e);
70-
throw e;
7181
}
7282
}
73-
74-
// otherwise create unsigned payout tx
75-
else if (trade.getSelf().getUnsignedPayoutTxHex() == null) {
76-
createUnsignedPayoutTx();
77-
}
7883
}
79-
}
80-
} else if (trade.getArbitrator().getPaymentReceivedMessage().getSignedPayoutTxHex() != null && !trade.isPayoutPublished()) {
84+
} else if (trade.getArbitrator().getPaymentReceivedMessage().getSignedPayoutTxHex() != null) {
8185

82-
// republish payout tx from previous message
83-
log.info("Seller re-verifying and publishing signed payout tx for trade {}", trade.getId());
84-
trade.processPayoutTx(trade.getArbitrator().getPaymentReceivedMessage().getSignedPayoutTxHex(), false, true);
86+
// republish payout tx from previous message
87+
log.info("Seller re-verifying and publishing signed payout tx for trade {}", trade.getId());
88+
trade.processPayoutTx(trade.getArbitrator().getPaymentReceivedMessage().getSignedPayoutTxHex(), false, true);
89+
}
8590
}
8691

8792
// close open disputes

0 commit comments

Comments
 (0)