mirror of
https://github.com/boldsuck/haveno.git
synced 2025-01-18 14:04:31 +00:00
defer payout publish if published, skip warning log if published
This commit is contained in:
parent
dd5b7996b3
commit
7a392f3c1e
3 changed files with 19 additions and 14 deletions
|
@ -1085,11 +1085,12 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
||||||
} catch (IllegalArgumentException | IllegalStateException e) {
|
} catch (IllegalArgumentException | IllegalStateException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Failed to import multisig hex, tradeId={}, attempt={}/{}, error={}", getShortId(), i + 1, TradeProtocol.MAX_ATTEMPTS, e.getMessage());
|
|
||||||
handleWalletError(e, sourceConnection);
|
handleWalletError(e, sourceConnection);
|
||||||
|
doPollWallet();
|
||||||
|
if (isPayoutPublished()) break;
|
||||||
|
log.warn("Failed to import multisig hex, tradeId={}, attempt={}/{}, error={}", getShortId(), i + 1, TradeProtocol.MAX_ATTEMPTS, e.getMessage());
|
||||||
if (i == TradeProtocol.MAX_ATTEMPTS - 1) throw e;
|
if (i == TradeProtocol.MAX_ATTEMPTS - 1) throw e;
|
||||||
HavenoUtils.waitFor(TradeProtocol.REPROCESS_DELAY_MS); // wait before retrying
|
HavenoUtils.waitFor(TradeProtocol.REPROCESS_DELAY_MS); // wait before retrying
|
||||||
doPollWallet();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1205,8 +1206,10 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
||||||
} catch (IllegalArgumentException | IllegalStateException e) {
|
} catch (IllegalArgumentException | IllegalStateException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Failed to create payout tx, tradeId={}, attempt={}/{}, error={}", getShortId(), i + 1, TradeProtocol.MAX_ATTEMPTS, e.getMessage());
|
|
||||||
handleWalletError(e, sourceConnection);
|
handleWalletError(e, sourceConnection);
|
||||||
|
doPollWallet();
|
||||||
|
if (isPayoutPublished()) break;
|
||||||
|
log.warn("Failed to create payout tx, tradeId={}, attempt={}/{}, error={}", getShortId(), i + 1, TradeProtocol.MAX_ATTEMPTS, e.getMessage());
|
||||||
if (i == TradeProtocol.MAX_ATTEMPTS - 1) throw e;
|
if (i == TradeProtocol.MAX_ATTEMPTS - 1) throw e;
|
||||||
HavenoUtils.waitFor(TradeProtocol.REPROCESS_DELAY_MS); // wait before retrying
|
HavenoUtils.waitFor(TradeProtocol.REPROCESS_DELAY_MS); // wait before retrying
|
||||||
}
|
}
|
||||||
|
@ -1265,11 +1268,12 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (e.getMessage().contains("not possible")) throw new IllegalArgumentException("Loser payout is too small to cover the mining fee");
|
if (e.getMessage().contains("not possible")) throw new IllegalArgumentException("Loser payout is too small to cover the mining fee");
|
||||||
log.warn("Failed to create dispute payout tx, tradeId={}, attempt={}/{}, error={}", getShortId(), i + 1, TradeProtocol.MAX_ATTEMPTS, e.getMessage());
|
|
||||||
handleWalletError(e, sourceConnection);
|
handleWalletError(e, sourceConnection);
|
||||||
|
doPollWallet();
|
||||||
|
if (isPayoutPublished()) break;
|
||||||
|
log.warn("Failed to create dispute payout tx, tradeId={}, attempt={}/{}, error={}", getShortId(), i + 1, TradeProtocol.MAX_ATTEMPTS, e.getMessage());
|
||||||
if (i == TradeProtocol.MAX_ATTEMPTS - 1) throw e;
|
if (i == TradeProtocol.MAX_ATTEMPTS - 1) throw e;
|
||||||
HavenoUtils.waitFor(TradeProtocol.REPROCESS_DELAY_MS); // wait before retrying
|
HavenoUtils.waitFor(TradeProtocol.REPROCESS_DELAY_MS); // wait before retrying
|
||||||
doPollWallet();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new RuntimeException("Failed to create payout tx for " + getClass().getSimpleName() + " " + getId());
|
throw new RuntimeException("Failed to create payout tx for " + getClass().getSimpleName() + " " + getId());
|
||||||
|
@ -1295,11 +1299,12 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
||||||
} catch (IllegalArgumentException | IllegalStateException e) {
|
} catch (IllegalArgumentException | IllegalStateException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Failed to process payout tx, tradeId={}, attempt={}/{}, error={}", getShortId(), i + 1, TradeProtocol.MAX_ATTEMPTS, e.getMessage(), e);
|
|
||||||
handleWalletError(e, sourceConnection);
|
handleWalletError(e, sourceConnection);
|
||||||
|
doPollWallet();
|
||||||
|
if (isPayoutPublished()) break;
|
||||||
|
log.warn("Failed to process payout tx, tradeId={}, attempt={}/{}, error={}", getShortId(), i + 1, TradeProtocol.MAX_ATTEMPTS, e.getMessage(), e);
|
||||||
if (i == TradeProtocol.MAX_ATTEMPTS - 1) throw e;
|
if (i == TradeProtocol.MAX_ATTEMPTS - 1) throw e;
|
||||||
HavenoUtils.waitFor(TradeProtocol.REPROCESS_DELAY_MS); // wait before retrying
|
HavenoUtils.waitFor(TradeProtocol.REPROCESS_DELAY_MS); // wait before retrying
|
||||||
doPollWallet();
|
|
||||||
} finally {
|
} finally {
|
||||||
requestSaveWallet();
|
requestSaveWallet();
|
||||||
requestPersistence();
|
requestPersistence();
|
||||||
|
|
|
@ -143,12 +143,10 @@ public class ProcessPaymentReceivedMessage extends TradeTask {
|
||||||
// handle if payout tx not published
|
// handle if payout tx not published
|
||||||
if (!trade.isPayoutPublished()) {
|
if (!trade.isPayoutPublished()) {
|
||||||
|
|
||||||
// wait to sign and publish payout tx if defer flag set (seller recently saw payout tx arrive at buyer)
|
// wait to publish payout tx if defer flag set from seller (payout is expected)
|
||||||
boolean isSigned = message.getSignedPayoutTxHex() != null;
|
if (message.isDeferPublishPayout()) {
|
||||||
boolean deferSignAndPublish = trade instanceof ArbitratorTrade && !isSigned && message.isDeferPublishPayout();
|
log.info("Deferring publishing payout tx for {} {}", trade.getClass().getSimpleName(), trade.getId());
|
||||||
if (deferSignAndPublish) {
|
if (trade instanceof ArbitratorTrade) trade.pollWalletNormallyForMs(60000); // stop idling arbitrator
|
||||||
log.info("Deferring signing and publishing payout tx for {} {}", trade.getClass().getSimpleName(), trade.getId());
|
|
||||||
trade.pollWalletNormallyForMs(60000);
|
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
if (trade.isPayoutPublished()) break;
|
if (trade.isPayoutPublished()) break;
|
||||||
HavenoUtils.waitFor(Trade.DEFER_PUBLISH_MS / 5);
|
HavenoUtils.waitFor(Trade.DEFER_PUBLISH_MS / 5);
|
||||||
|
@ -159,6 +157,7 @@ public class ProcessPaymentReceivedMessage extends TradeTask {
|
||||||
// verify and publish payout tx
|
// verify and publish payout tx
|
||||||
if (!trade.isPayoutPublished()) {
|
if (!trade.isPayoutPublished()) {
|
||||||
try {
|
try {
|
||||||
|
boolean isSigned = message.getSignedPayoutTxHex() != null;
|
||||||
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);
|
||||||
|
|
|
@ -103,6 +103,7 @@ public abstract class SellerSendPaymentReceivedMessage extends SendMailboxMessag
|
||||||
// messages where only the one which gets processed by the peer would be removed we use the same uid. All
|
// messages where only the one which gets processed by the peer would be removed we use the same uid. All
|
||||||
// other data stays the same when we re-send the message at any time later.
|
// other data stays the same when we re-send the message at any time later.
|
||||||
String deterministicId = HavenoUtils.getDeterministicId(trade, PaymentReceivedMessage.class, getReceiverNodeAddress());
|
String deterministicId = HavenoUtils.getDeterministicId(trade, PaymentReceivedMessage.class, getReceiverNodeAddress());
|
||||||
|
boolean deferPublishPayout = trade.isPayoutPublished() || trade.getState().ordinal() >= Trade.State.SELLER_SAW_ARRIVED_PAYMENT_RECEIVED_MSG.ordinal(); // informs receiver to expect payout so delay processing
|
||||||
PaymentReceivedMessage message = new PaymentReceivedMessage(
|
PaymentReceivedMessage message = new PaymentReceivedMessage(
|
||||||
tradeId,
|
tradeId,
|
||||||
processModel.getMyNodeAddress(),
|
processModel.getMyNodeAddress(),
|
||||||
|
@ -110,7 +111,7 @@ public abstract class SellerSendPaymentReceivedMessage extends SendMailboxMessag
|
||||||
trade.getPayoutTxHex() == null ? trade.getSelf().getUnsignedPayoutTxHex() : null, // unsigned // TODO: phase in after next update to clear old style trades
|
trade.getPayoutTxHex() == null ? trade.getSelf().getUnsignedPayoutTxHex() : null, // unsigned // TODO: phase in after next update to clear old style trades
|
||||||
trade.getPayoutTxHex() == null ? null : trade.getPayoutTxHex(), // signed
|
trade.getPayoutTxHex() == null ? null : trade.getPayoutTxHex(), // signed
|
||||||
trade.getSelf().getUpdatedMultisigHex(),
|
trade.getSelf().getUpdatedMultisigHex(),
|
||||||
trade.getState().ordinal() >= Trade.State.SELLER_SAW_ARRIVED_PAYMENT_RECEIVED_MSG.ordinal(), // informs to expect payout
|
deferPublishPayout,
|
||||||
trade.getTradePeer().getAccountAgeWitness(),
|
trade.getTradePeer().getAccountAgeWitness(),
|
||||||
signedWitness,
|
signedWitness,
|
||||||
getReceiver() == trade.getArbitrator() ? trade.getBuyer().getPaymentSentMessage() : null // buyer already has payment sent message
|
getReceiver() == trade.getArbitrator() ? trade.getBuyer().getPaymentSentMessage() : null // buyer already has payment sent message
|
||||||
|
|
Loading…
Reference in a new issue