diff --git a/core/src/main/java/bisq/core/trade/DumpDelayedPayoutTx.java b/core/src/main/java/bisq/core/trade/DumpDelayedPayoutTx.java
new file mode 100644
index 00000000000..0f5669f751e
--- /dev/null
+++ b/core/src/main/java/bisq/core/trade/DumpDelayedPayoutTx.java
@@ -0,0 +1,63 @@
+/*
+ * This file is part of Bisq.
+ *
+ * Bisq is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * Bisq is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with Bisq. If not, see .
+ */
+
+package bisq.core.trade;
+
+import bisq.common.config.Config;
+import bisq.common.storage.JsonFileManager;
+import bisq.common.util.Utilities;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import java.io.File;
+
+import java.util.stream.Collectors;
+
+public class DumpDelayedPayoutTx {
+ private final boolean dumpDelayedPayoutTxs;
+ private final JsonFileManager jsonFileManager;
+
+ @Inject
+ DumpDelayedPayoutTx(@Named(Config.STORAGE_DIR) File storageDir,
+ @Named(Config.DUMP_DELAYED_PAYOUT_TXS) boolean dumpDelayedPayoutTxs) {
+ this.dumpDelayedPayoutTxs = dumpDelayedPayoutTxs;
+ jsonFileManager = new JsonFileManager(storageDir);
+ }
+
+ static class DelayedPayoutHash {
+ String tradeId;
+ String delayedPayoutTx;
+
+ DelayedPayoutHash(String tradeId, String delayedPayoutTx) {
+ this.tradeId = tradeId;
+ this.delayedPayoutTx = delayedPayoutTx;
+ }
+ }
+
+ public void maybeDumpDelayedPayoutTxs(TradableList tradableList, String fileName) {
+ if (!dumpDelayedPayoutTxs)
+ return;
+
+ var delayedPayoutHashes = tradableList.stream()
+ .map(trade -> new DelayedPayoutHash(trade.getId(),
+ Utilities.bytesAsHexString(trade.getDelayedPayoutTxBytes())))
+ .collect(Collectors.toList());
+ jsonFileManager.writeToDisc(Utilities.objectToJson(delayedPayoutHashes), fileName);
+ }
+
+}
diff --git a/core/src/main/java/bisq/core/trade/TradeManager.java b/core/src/main/java/bisq/core/trade/TradeManager.java
index 2fa1a84c83b..f55b8bd0d0c 100644
--- a/core/src/main/java/bisq/core/trade/TradeManager.java
+++ b/core/src/main/java/bisq/core/trade/TradeManager.java
@@ -57,16 +57,13 @@
import bisq.network.p2p.SendMailboxMessageListener;
import bisq.common.ClockWatcher;
-import bisq.common.config.Config;
import bisq.common.crypto.KeyRing;
import bisq.common.handlers.ErrorMessageHandler;
import bisq.common.handlers.FaultHandler;
import bisq.common.handlers.ResultHandler;
import bisq.common.proto.network.NetworkEnvelope;
import bisq.common.proto.persistable.PersistedDataHost;
-import bisq.common.storage.JsonFileManager;
import bisq.common.storage.Storage;
-import bisq.common.util.Utilities;
import org.bitcoinj.core.AddressFormatException;
import org.bitcoinj.core.Coin;
@@ -75,7 +72,6 @@
import org.bitcoinj.core.TransactionConfidence;
import javax.inject.Inject;
-import javax.inject.Named;
import com.google.common.util.concurrent.FutureCallback;
@@ -90,8 +86,6 @@
import org.spongycastle.crypto.params.KeyParameter;
-import java.io.File;
-
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -147,8 +141,7 @@ public class TradeManager implements PersistedDataHost {
private final LongProperty numPendingTrades = new SimpleLongProperty();
@Getter
private final ObservableList tradesWithoutDepositTx = FXCollections.observableArrayList();
- private final boolean dumpDelayedPayoutTxs;
- private final JsonFileManager jsonFileManager;
+ private final DumpDelayedPayoutTx dumpDelayedPayoutTx;
///////////////////////////////////////////////////////////////////////////////////////////
@@ -176,8 +169,7 @@ public TradeManager(User user,
DaoFacade daoFacade,
ClockWatcher clockWatcher,
Storage> storage,
- @Named(Config.STORAGE_DIR) File storageDir,
- @Named(Config.DUMP_DELAYED_PAYOUT_TXS) boolean dumpDelayedPayoutTxs) {
+ DumpDelayedPayoutTx dumpDelayedPayoutTx) {
this.user = user;
this.keyRing = keyRing;
this.btcWalletService = btcWalletService;
@@ -197,7 +189,7 @@ public TradeManager(User user,
this.refundAgentManager = refundAgentManager;
this.daoFacade = daoFacade;
this.clockWatcher = clockWatcher;
- this.dumpDelayedPayoutTxs = dumpDelayedPayoutTxs;
+ this.dumpDelayedPayoutTx = dumpDelayedPayoutTx;
tradableListStorage = storage;
@@ -233,9 +225,6 @@ public TradeManager(User user,
}
}
});
-
- jsonFileManager = new JsonFileManager(storageDir);
-
}
@Override
@@ -247,7 +236,8 @@ public void readPersisted() {
if (offer != null)
offer.setPriceFeedService(priceFeedService);
});
- maybeDumpDelayedPayoutTxs();
+
+ dumpDelayedPayoutTx.maybeDumpDelayedPayoutTxs(tradableList, "delayed_payout_txs_pending");
}
@@ -793,25 +783,4 @@ else if (now.after(halfTradePeriodDate))
public void persistTrades() {
tradableList.persist();
}
-
- @SuppressWarnings("InnerClassMayBeStatic")
- class DelayedPayoutHash {
- String tradeId;
- String delayedPayoutTx;
- DelayedPayoutHash(String tradeId, String delayedPayoutTx) {
- this.tradeId = tradeId;
- this.delayedPayoutTx = delayedPayoutTx;
- }
- }
-
- private void maybeDumpDelayedPayoutTxs() {
- if (!dumpDelayedPayoutTxs)
- return;
-
- var delayedPayoutHashes = tradableList.stream()
- .map(trade -> new DelayedPayoutHash(trade.getId(),
- Utilities.bytesAsHexString(trade.getDelayedPayoutTxBytes())))
- .collect(Collectors.toList());
- jsonFileManager.writeToDisc(Utilities.objectToJson(delayedPayoutHashes), "delayed_payout_txs");
- }
}
diff --git a/core/src/main/java/bisq/core/trade/failed/FailedTradesManager.java b/core/src/main/java/bisq/core/trade/failed/FailedTradesManager.java
index 28a0572cfb0..7733de0ff31 100644
--- a/core/src/main/java/bisq/core/trade/failed/FailedTradesManager.java
+++ b/core/src/main/java/bisq/core/trade/failed/FailedTradesManager.java
@@ -20,6 +20,7 @@
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.offer.Offer;
import bisq.core.provider.price.PriceFeedService;
+import bisq.core.trade.DumpDelayedPayoutTx;
import bisq.core.trade.TradableList;
import bisq.core.trade.Trade;
@@ -44,17 +45,19 @@ public class FailedTradesManager implements PersistedDataHost {
private final PriceFeedService priceFeedService;
private final BtcWalletService btcWalletService;
private final Storage> tradableListStorage;
+ private final DumpDelayedPayoutTx dumpDelayedPayoutTx;
@Inject
public FailedTradesManager(KeyRing keyRing,
PriceFeedService priceFeedService,
BtcWalletService btcWalletService,
- Storage> storage) {
+ Storage> storage,
+ DumpDelayedPayoutTx dumpDelayedPayoutTx) {
this.keyRing = keyRing;
this.priceFeedService = priceFeedService;
this.btcWalletService = btcWalletService;
tradableListStorage = storage;
-
+ this.dumpDelayedPayoutTx = dumpDelayedPayoutTx;
}
@Override
@@ -67,6 +70,8 @@ public void readPersisted() {
trade.setTransientFields(tradableListStorage, btcWalletService);
});
+
+ dumpDelayedPayoutTx.maybeDumpDelayedPayoutTxs(failedTrades, "delayed_payout_txs_failed");
}
public void add(Trade trade) {