mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-13 17:05:40 -04:00
Removing star and unused imports with checkstyle
This commit is contained in:
parent
ce05710537
commit
3b8f19c4ce
1206 changed files with 5197 additions and 6620 deletions
|
@ -6,17 +6,17 @@ import haveno.core.proto.CoreProtoResolver;
|
|||
import haveno.core.trade.protocol.ProcessModel;
|
||||
import haveno.core.xmr.wallet.XmrWalletService;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.UUID;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Trade in the context of an arbitrator.
|
||||
*/
|
||||
@Slf4j
|
||||
public class ArbitratorTrade extends Trade {
|
||||
|
||||
|
||||
public ArbitratorTrade(Offer offer,
|
||||
BigInteger tradeAmount,
|
||||
BigInteger takerFee,
|
||||
|
|
|
@ -23,11 +23,11 @@ import haveno.core.proto.CoreProtoResolver;
|
|||
import haveno.core.trade.protocol.ProcessModel;
|
||||
import haveno.core.xmr.wallet.XmrWalletService;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.UUID;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public final class BuyerAsMakerTrade extends BuyerTrade implements MakerTrade {
|
||||
|
||||
|
|
|
@ -23,12 +23,11 @@ import haveno.core.proto.CoreProtoResolver;
|
|||
import haveno.core.trade.protocol.ProcessModel;
|
||||
import haveno.core.xmr.wallet.XmrWalletService;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import java.math.BigInteger;
|
||||
import java.util.UUID;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
public final class BuyerAsTakerTrade extends BuyerTrade implements TakerTrade {
|
||||
|
|
|
@ -24,11 +24,10 @@ import haveno.network.p2p.NodeAddress;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
@Slf4j
|
||||
public abstract class BuyerTrade extends Trade {
|
||||
BuyerTrade(Offer offer,
|
||||
|
|
|
@ -27,12 +27,11 @@ import haveno.network.p2p.DecryptedMessageWithPubKey;
|
|||
import haveno.network.p2p.P2PService;
|
||||
import haveno.network.p2p.mailbox.MailboxMessage;
|
||||
import haveno.network.p2p.mailbox.MailboxMessageService;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
|
||||
//TODO with the redesign of mailbox messages that is not required anymore. We leave it for now as we want to minimize
|
||||
// changes for the 1.5.0 release but we should clean up afterwards...
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ package haveno.core.trade;
|
|||
|
||||
import haveno.common.crypto.PubKeyRing;
|
||||
import haveno.common.proto.network.NetworkEnvelope;
|
||||
import haveno.core.trade.Trade;
|
||||
import haveno.core.trade.messages.TradeMessage;
|
||||
import haveno.network.p2p.AckMessage;
|
||||
import haveno.network.p2p.AckMessageSourceType;
|
||||
|
@ -28,12 +27,11 @@ import haveno.network.p2p.DecryptedMessageWithPubKey;
|
|||
import haveno.network.p2p.P2PService;
|
||||
import haveno.network.p2p.mailbox.MailboxMessage;
|
||||
import haveno.network.p2p.mailbox.MailboxMessageService;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
|
||||
//TODO with the redesign of mailbox messages that is not required anymore. We leave it for now as we want to minimize
|
||||
// changes for the 1.5.0 release but we should clean up afterwards...
|
||||
|
||||
|
|
|
@ -17,13 +17,28 @@
|
|||
|
||||
package haveno.core.trade;
|
||||
|
||||
import haveno.core.locale.CurrencyUtil;
|
||||
import haveno.core.locale.Res;
|
||||
import haveno.core.monetary.Altcoin;
|
||||
import haveno.core.monetary.Volume;
|
||||
import haveno.core.offer.OpenOffer;
|
||||
import haveno.core.util.FormattingUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bitcoinj.core.Monetary;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.math.BigInteger;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static haveno.core.trade.ClosedTradableUtil.*;
|
||||
import static haveno.core.trade.ClosedTradableUtil.castToTrade;
|
||||
import static haveno.core.trade.ClosedTradableUtil.getTotalTxFee;
|
||||
import static haveno.core.trade.ClosedTradableUtil.getTotalVolumeByCurrency;
|
||||
import static haveno.core.trade.ClosedTradableUtil.isHavenoV1Trade;
|
||||
import static haveno.core.trade.ClosedTradableUtil.isOpenOffer;
|
||||
import static haveno.core.trade.Trade.DisputeState.DISPUTE_CLOSED;
|
||||
import static haveno.core.trade.Trade.DisputeState.MEDIATION_CLOSED;
|
||||
import static haveno.core.trade.Trade.DisputeState.REFUND_REQUEST_CLOSED;
|
||||
|
@ -32,21 +47,6 @@ import static haveno.core.util.FormattingUtils.formatToPercentWithSymbol;
|
|||
import static haveno.core.util.VolumeUtil.formatVolume;
|
||||
import static haveno.core.util.VolumeUtil.formatVolumeWithCode;
|
||||
|
||||
import haveno.core.locale.CurrencyUtil;
|
||||
import haveno.core.locale.Res;
|
||||
import haveno.core.monetary.Altcoin;
|
||||
import haveno.core.monetary.Volume;
|
||||
import haveno.core.offer.OpenOffer;
|
||||
import haveno.core.util.FormattingUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Singleton
|
||||
public class ClosedTradableFormatter {
|
||||
|
|
|
@ -17,14 +17,7 @@
|
|||
|
||||
package haveno.core.trade;
|
||||
|
||||
import static haveno.core.offer.OpenOffer.State.CANCELED;
|
||||
import static haveno.core.trade.ClosedTradableUtil.castToTradeModel;
|
||||
import static haveno.core.trade.ClosedTradableUtil.isOpenOffer;
|
||||
import static haveno.core.util.AveragePriceUtil.getAveragePriceTuple;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.inject.Inject;
|
||||
import haveno.common.crypto.KeyRing;
|
||||
import haveno.common.persistence.PersistenceManager;
|
||||
|
@ -38,13 +31,13 @@ import haveno.core.provider.price.PriceFeedService;
|
|||
import haveno.core.trade.statistics.TradeStatisticsManager;
|
||||
import haveno.core.user.Preferences;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import javafx.collections.ObservableList;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.time.Instant;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
@ -53,7 +46,10 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import static haveno.core.offer.OpenOffer.State.CANCELED;
|
||||
import static haveno.core.trade.ClosedTradableUtil.castToTradeModel;
|
||||
import static haveno.core.trade.ClosedTradableUtil.isOpenOffer;
|
||||
import static haveno.core.util.AveragePriceUtil.getAveragePriceTuple;
|
||||
|
||||
/**
|
||||
* Manages closed trades or offers.
|
||||
|
|
|
@ -31,17 +31,15 @@ import haveno.core.proto.CoreProtoResolver;
|
|||
import haveno.core.util.JsonUtil;
|
||||
import haveno.core.util.VolumeUtil;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import lombok.Value;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
@Slf4j
|
||||
@Value
|
||||
public final class Contract implements NetworkPayload {
|
||||
|
@ -195,7 +193,7 @@ public final class Contract implements NetworkPayload {
|
|||
public byte[] getSellerPaymentAccountPayloadHash() {
|
||||
return isBuyerMakerAndSellerTaker ? takerPaymentAccountPayloadHash : makerPaymentAccountPayloadHash;
|
||||
}
|
||||
|
||||
|
||||
public String getPaymentMethodId() {
|
||||
return makerPaymentMethodId;
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
package haveno.core.trade;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.base.Charsets;
|
||||
import haveno.common.config.Config;
|
||||
|
@ -36,14 +34,16 @@ import haveno.core.trade.messages.PaymentReceivedMessage;
|
|||
import haveno.core.trade.messages.PaymentSentMessage;
|
||||
import haveno.core.util.JsonUtil;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
||||
import java.net.URI;
|
||||
import java.security.PrivateKey;
|
||||
import javax.annotation.Nullable;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import java.net.URI;
|
||||
import java.security.PrivateKey;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
@ -53,10 +53,6 @@ import java.util.concurrent.Executors;
|
|||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Collection of utilities.
|
||||
*/
|
||||
|
@ -72,7 +68,7 @@ public class HavenoUtils {
|
|||
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
|
||||
private static final int POOL_SIZE = 10;
|
||||
private static final ExecutorService POOL = Executors.newFixedThreadPool(POOL_SIZE);
|
||||
|
||||
|
||||
public static ArbitrationManager arbitrationManager; // TODO: better way to share reference?
|
||||
|
||||
|
||||
|
|
|
@ -23,12 +23,11 @@ import haveno.core.proto.CoreProtoResolver;
|
|||
import haveno.core.trade.protocol.ProcessModel;
|
||||
import haveno.core.xmr.wallet.XmrWalletService;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import java.math.BigInteger;
|
||||
import java.util.UUID;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
public final class SellerAsMakerTrade extends SellerTrade implements MakerTrade {
|
||||
|
|
|
@ -23,12 +23,11 @@ import haveno.core.proto.CoreProtoResolver;
|
|||
import haveno.core.trade.protocol.ProcessModel;
|
||||
import haveno.core.xmr.wallet.XmrWalletService;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import java.math.BigInteger;
|
||||
import java.util.UUID;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
public final class SellerAsTakerTrade extends SellerTrade implements TakerTrade {
|
||||
|
|
|
@ -24,11 +24,10 @@ import haveno.network.p2p.NodeAddress;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
@Slf4j
|
||||
public abstract class SellerTrade extends Trade {
|
||||
SellerTrade(Offer offer,
|
||||
|
|
|
@ -24,12 +24,12 @@ import haveno.common.proto.persistable.PersistableListAsObservable;
|
|||
import haveno.core.offer.OpenOffer;
|
||||
import haveno.core.proto.CoreProtoResolver;
|
||||
import haveno.core.xmr.wallet.XmrWalletService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public final class TradableList<T extends Tradable> extends PersistableListAsObservable<T> {
|
||||
|
||||
|
|
|
@ -53,10 +53,6 @@ import haveno.core.xmr.wallet.XmrWalletService;
|
|||
import haveno.network.p2p.AckMessage;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import haveno.network.p2p.P2PService;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.fxmisc.easybind.EasyBind;
|
||||
import org.fxmisc.easybind.Subscription;
|
||||
|
||||
import javafx.beans.property.IntegerProperty;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.ReadOnlyObjectProperty;
|
||||
|
@ -65,34 +61,11 @@ import javafx.beans.property.SimpleIntegerProperty;
|
|||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.time.Clock;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.crypto.SecretKey;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
|
||||
|
||||
import monero.common.MoneroError;
|
||||
import monero.common.MoneroRpcConnection;
|
||||
import monero.common.TaskLooper;
|
||||
|
@ -107,6 +80,25 @@ import monero.wallet.model.MoneroTxQuery;
|
|||
import monero.wallet.model.MoneroTxSet;
|
||||
import monero.wallet.model.MoneroTxWallet;
|
||||
import monero.wallet.model.MoneroWalletListener;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.fxmisc.easybind.EasyBind;
|
||||
import org.fxmisc.easybind.Subscription;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.crypto.SecretKey;
|
||||
import java.math.BigInteger;
|
||||
import java.time.Clock;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Holds all data which are relevant to the trade, but not those which are only needed in the trade process as shared data between tasks. Those data are
|
||||
|
@ -389,7 +381,7 @@ public abstract class Trade implements Tradable, Model {
|
|||
public static final long DEFER_PUBLISH_MS = 25000; // 25 seconds
|
||||
private static final long IDLE_SYNC_PERIOD_MS = 3600000; // 1 hour
|
||||
private static final long MAX_REPROCESS_DELAY_SECONDS = 7200; // max delay to reprocess messages (once per 2 hours)
|
||||
|
||||
|
||||
// Mutable
|
||||
@Getter
|
||||
transient private boolean isInitialized;
|
||||
|
@ -555,18 +547,18 @@ public abstract class Trade implements Tradable, Model {
|
|||
public void addListener(TradeListener listener) {
|
||||
tradeListeners.add(listener);
|
||||
}
|
||||
|
||||
|
||||
public void removeListener(TradeListener listener) {
|
||||
if (!tradeListeners.remove(listener)) throw new RuntimeException("TradeMessageListener is not registered");
|
||||
}
|
||||
|
||||
|
||||
// notified from TradeProtocol of verified trade messages
|
||||
public void onVerifiedTradeMessage(TradeMessage message, NodeAddress sender) {
|
||||
for (TradeListener listener : new ArrayList<TradeListener>(tradeListeners)) { // copy array to allow listener invocation to unregister listener without concurrent modification exception
|
||||
listener.onVerifiedTradeMessage(message, sender);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// notified from TradeProtocol of ack messages
|
||||
public void onAckMessage(AckMessage ackMessage, NodeAddress sender) {
|
||||
for (TradeListener listener : new ArrayList<TradeListener>(tradeListeners)) { // copy array to allow listener invocation to unregister listener without concurrent modification exception
|
||||
|
@ -818,7 +810,7 @@ public abstract class Trade implements Tradable, Model {
|
|||
if (wallet != null) closeWallet();
|
||||
log.info("Deleting wallet for {} {}", getClass().getSimpleName(), getId());
|
||||
xmrWalletService.deleteWallet(getWalletName());
|
||||
|
||||
|
||||
// delete trade wallet backups unless deposits requested and payouts not unlocked
|
||||
if (isDepositRequested() && !isPayoutUnlocked()) {
|
||||
log.warn("Refusing to delete backup wallet for " + getClass().getSimpleName() + " " + getId() + " in the small chance it becomes funded");
|
||||
|
@ -1598,7 +1590,7 @@ public abstract class Trade implements Tradable, Model {
|
|||
|
||||
/**
|
||||
* Get the duration to delay reprocessing a message based on its reprocess count.
|
||||
*
|
||||
*
|
||||
* @return the duration to delay in seconds
|
||||
*/
|
||||
public long getReprocessDelayInSeconds(int reprocessCount) {
|
||||
|
@ -1639,7 +1631,7 @@ public abstract class Trade implements Tradable, Model {
|
|||
if (connection != null && !Boolean.FALSE.equals(connection.isConnected())) {
|
||||
HavenoUtils.submitTask(() -> {
|
||||
updateSyncing();
|
||||
|
||||
|
||||
// reprocess pending payout messages
|
||||
this.getProtocol().maybeReprocessPaymentReceivedMessage(false);
|
||||
HavenoUtils.arbitrationManager.maybeReprocessDisputeClosedMessage(this, false);
|
||||
|
@ -1813,7 +1805,7 @@ public abstract class Trade implements Tradable, Model {
|
|||
// skip if not idling and not waiting for payout to unlock
|
||||
if (!isIdling() || !isPayoutPublished() || isPayoutUnlocked()) {
|
||||
processing = false;
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -17,6 +17,11 @@
|
|||
|
||||
package haveno.core.trade;
|
||||
|
||||
import haveno.core.offer.Offer;
|
||||
import haveno.core.support.dispute.Dispute;
|
||||
import haveno.core.xmr.wallet.BtcWalletService;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bitcoinj.core.Address;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
|
@ -24,24 +29,16 @@ import org.bitcoinj.core.TransactionInput;
|
|||
import org.bitcoinj.core.TransactionOutPoint;
|
||||
import org.bitcoinj.core.TransactionOutput;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import haveno.core.offer.Offer;
|
||||
import haveno.core.support.dispute.Dispute;
|
||||
import haveno.core.xmr.wallet.BtcWalletService;
|
||||
|
||||
@Slf4j
|
||||
public class TradeDataValidation {
|
||||
|
||||
|
||||
public static void validateDelayedPayoutTx(Trade trade,
|
||||
Transaction delayedPayoutTx,
|
||||
BtcWalletService btcWalletService)
|
||||
|
@ -201,7 +198,7 @@ public class TradeDataValidation {
|
|||
this.dispute = dispute;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class InvalidPaymentAccountPayloadException extends ValidationException {
|
||||
InvalidPaymentAccountPayloadException(@Nullable Dispute dispute, String msg) {
|
||||
super(dispute, msg);
|
||||
|
|
|
@ -73,21 +73,24 @@ import haveno.network.p2p.DecryptedMessageWithPubKey;
|
|||
import haveno.network.p2p.NodeAddress;
|
||||
import haveno.network.p2p.P2PService;
|
||||
import haveno.network.p2p.network.TorNetworkNode;
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.LongProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.SimpleLongProperty;
|
||||
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import monero.daemon.model.MoneroTx;
|
||||
import monero.wallet.model.MoneroOutputQuery;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bouncycastle.crypto.params.KeyParameter;
|
||||
import org.fxmisc.easybind.EasyBind;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
@ -102,20 +105,9 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import monero.daemon.model.MoneroTx;
|
||||
import monero.wallet.model.MoneroOutputQuery;
|
||||
|
||||
|
||||
public class TradeManager implements PersistedDataHost, DecryptedDirectMessageListener {
|
||||
private static final Logger log = LoggerFactory.getLogger(TradeManager.class);
|
||||
|
@ -1158,11 +1150,11 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
|||
log.warn("Scheduling to delete trade if unfunded for {} {}", trade.getClass().getSimpleName(), trade.getId());
|
||||
UserThread.runAfter(() -> {
|
||||
if (isShutDown) return;
|
||||
|
||||
|
||||
// get trade's deposit txs from daemon
|
||||
MoneroTx makerDepositTx = xmrWalletService.getDaemon().getTx(trade.getMaker().getDepositTxHash());
|
||||
MoneroTx takerDepositTx = xmrWalletService.getDaemon().getTx(trade.getTaker().getDepositTxHash());
|
||||
|
||||
|
||||
// delete multisig trade wallet if neither deposit tx published
|
||||
if (makerDepositTx == null && takerDepositTx == null) {
|
||||
log.warn("Deleting {} {} after protocol timeout", trade.getClass().getSimpleName(), trade.getId());
|
||||
|
|
|
@ -19,19 +19,16 @@ package haveno.core.trade;
|
|||
|
||||
import haveno.common.crypto.KeyRing;
|
||||
import haveno.common.util.Tuple2;
|
||||
import haveno.common.util.Utilities;
|
||||
import haveno.core.locale.Res;
|
||||
import haveno.core.offer.Offer;
|
||||
import haveno.core.xmr.wallet.BtcWalletService;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static haveno.core.locale.CurrencyUtil.getCurrencyPair;
|
||||
|
|
|
@ -30,16 +30,14 @@ import haveno.core.trade.TradeUtil;
|
|||
import haveno.core.xmr.model.XmrAddressEntry;
|
||||
import haveno.core.xmr.wallet.XmrWalletService;
|
||||
import javafx.collections.ObservableList;
|
||||
import lombok.Setter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import lombok.Setter;
|
||||
|
||||
public class FailedTradesManager implements PersistedDataHost {
|
||||
private static final Logger log = LoggerFactory.getLogger(FailedTradesManager.class);
|
||||
private final TradableList<Trade> failedTrades = new TradableList<>();
|
||||
|
|
|
@ -22,11 +22,12 @@ import haveno.common.proto.ProtoUtil;
|
|||
import haveno.common.util.Utilities;
|
||||
import haveno.core.proto.CoreProtoResolver;
|
||||
import haveno.network.p2p.DirectMessage;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Optional;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Value
|
||||
public final class DepositRequest extends TradeMessage implements DirectMessage {
|
||||
|
|
|
@ -17,15 +17,14 @@
|
|||
|
||||
package haveno.core.trade.messages;
|
||||
|
||||
import haveno.common.crypto.PubKeyRing;
|
||||
import haveno.common.proto.ProtoUtil;
|
||||
import haveno.core.proto.CoreProtoResolver;
|
||||
import haveno.network.p2p.DirectMessage;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import java.util.Optional;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Value
|
||||
public final class DepositResponse extends TradeMessage implements DirectMessage {
|
||||
|
|
|
@ -24,11 +24,12 @@ import haveno.common.proto.ProtoUtil;
|
|||
import haveno.common.util.Utilities;
|
||||
import haveno.core.proto.CoreProtoResolver;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Optional;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Value
|
||||
public final class DepositsConfirmedMessage extends TradeMailboxMessage {
|
||||
|
|
|
@ -17,17 +17,14 @@
|
|||
|
||||
package haveno.core.trade.messages;
|
||||
|
||||
import haveno.common.crypto.PubKeyRing;
|
||||
import haveno.common.proto.ProtoUtil;
|
||||
import haveno.core.proto.CoreProtoResolver;
|
||||
import haveno.network.p2p.DirectMessage;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import java.util.Optional;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Optional;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Value
|
||||
|
|
|
@ -24,12 +24,11 @@ import haveno.common.util.Utilities;
|
|||
import haveno.core.proto.CoreProtoResolver;
|
||||
import haveno.network.p2p.DirectMessage;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import java.util.Optional;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Optional;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Value
|
||||
|
|
|
@ -17,21 +17,19 @@
|
|||
|
||||
package haveno.core.trade.messages;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import haveno.common.app.Version;
|
||||
import haveno.common.proto.ProtoUtil;
|
||||
import haveno.core.account.sign.SignedWitness;
|
||||
import haveno.core.account.witness.AccountAgeWitness;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Optional;
|
||||
|
||||
@Slf4j
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
|
|
@ -22,13 +22,12 @@ import haveno.common.app.Version;
|
|||
import haveno.common.proto.ProtoUtil;
|
||||
import haveno.core.account.witness.AccountAgeWitness;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import java.util.Optional;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Optional;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Getter
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
|
||||
package haveno.core.trade.messages;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import haveno.common.proto.ProtoUtil;
|
||||
import haveno.common.util.Utilities;
|
||||
|
@ -29,6 +25,9 @@ import haveno.network.p2p.DirectMessage;
|
|||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Optional;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Value
|
||||
public final class SignContractRequest extends TradeMessage implements DirectMessage {
|
||||
|
|
|
@ -22,11 +22,12 @@ import haveno.common.proto.ProtoUtil;
|
|||
import haveno.common.util.Utilities;
|
||||
import haveno.core.proto.CoreProtoResolver;
|
||||
import haveno.network.p2p.DirectMessage;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Optional;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Value
|
||||
public final class SignContractResponse extends TradeMessage implements DirectMessage {
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
package haveno.core.trade.messages;
|
||||
|
||||
import haveno.network.p2p.mailbox.MailboxMessage;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString
|
||||
public abstract class TradeMailboxMessage extends TradeMessage implements MailboxMessage {
|
||||
|
|
|
@ -19,7 +19,6 @@ package haveno.core.trade.protocol;
|
|||
|
||||
|
||||
import haveno.common.handlers.ErrorMessageHandler;
|
||||
import haveno.core.offer.Offer;
|
||||
import haveno.core.trade.BuyerAsTakerTrade;
|
||||
import haveno.core.trade.Trade;
|
||||
import haveno.core.trade.handlers.TradeResultHandler;
|
||||
|
@ -30,7 +29,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
|
||||
@Slf4j
|
||||
public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol {
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -21,16 +21,14 @@ import haveno.common.taskrunner.Task;
|
|||
import haveno.core.trade.Trade;
|
||||
import haveno.core.trade.messages.TradeMessage;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static haveno.core.util.Validator.isTradeIdValid;
|
||||
|
@ -99,7 +97,7 @@ public class FluentProtocol {
|
|||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
if (setup.getTimeoutSec() > 0) {
|
||||
tradeProtocol.startTimeout(setup.getTimeoutSec());
|
||||
}
|
||||
|
|
|
@ -50,22 +50,17 @@ import haveno.core.xmr.wallet.XmrWalletService;
|
|||
import haveno.network.p2p.AckMessage;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import haveno.network.p2p.P2PService;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import java.util.Optional;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import monero.wallet.model.MoneroTxWallet;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
|
||||
import monero.wallet.model.MoneroTxWallet;
|
||||
import java.util.Optional;
|
||||
|
||||
// Fields marked as transient are only used during protocol execution which are based on directMessages so we do not
|
||||
// persist them.
|
||||
|
@ -114,7 +109,7 @@ public class ProcessModel implements Model, PersistablePayload {
|
|||
private boolean useSavingsWallet;
|
||||
@Setter
|
||||
private long fundsNeededForTrade;
|
||||
|
||||
|
||||
// that is used to store temp. the peers address when we get an incoming message before the message is verified.
|
||||
// After successful verified we copy that over to the trade.tradePeerAddress
|
||||
@Nullable
|
||||
|
@ -307,7 +302,7 @@ public class ProcessModel implements Model, PersistablePayload {
|
|||
tradeManager.requestPersistence();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void setDepositTxSentAckMessage(AckMessage ackMessage) {
|
||||
MessageState messageState = ackMessage.isSuccess() ?
|
||||
MessageState.ACKNOWLEDGED :
|
||||
|
@ -330,7 +325,7 @@ public class ProcessModel implements Model, PersistablePayload {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Delegates
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public XmrWalletService getXmrWalletService() {
|
||||
return provider.getXmrWalletService();
|
||||
}
|
||||
|
|
|
@ -31,10 +31,10 @@ import haveno.core.xmr.wallet.BtcWalletService;
|
|||
import haveno.core.xmr.wallet.TradeWalletService;
|
||||
import haveno.core.xmr.wallet.XmrWalletService;
|
||||
import haveno.network.p2p.P2PService;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@Getter
|
||||
public class ProcessModelServiceProvider {
|
||||
private final OpenOfferManager openOfferManager;
|
||||
|
|
|
@ -26,17 +26,16 @@ import haveno.core.account.witness.AccountAgeWitness;
|
|||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.proto.CoreProtoResolver;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import monero.daemon.model.MoneroTx;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
// Fields marked as transient are only used during protocol execution which are based on directMessages so we do not
|
||||
// persist them.
|
||||
|
@ -120,7 +119,7 @@ public final class TradePeer implements PersistablePayload {
|
|||
private long securityDeposit;
|
||||
@Nullable
|
||||
private String updatedMultisigHex;
|
||||
|
||||
|
||||
public TradePeer() {
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,10 @@ import haveno.network.p2p.SendMailboxMessageListener;
|
|||
import haveno.network.p2p.mailbox.MailboxMessage;
|
||||
import haveno.network.p2p.mailbox.MailboxMessageService;
|
||||
import haveno.network.p2p.messaging.DecryptedMailboxListener;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.fxmisc.easybind.EasyBind;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -73,10 +77,6 @@ import java.util.List;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.fxmisc.easybind.EasyBind;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Slf4j
|
||||
public abstract class TradeProtocol implements DecryptedDirectMessageListener, DecryptedMailboxListener {
|
||||
|
||||
|
@ -363,7 +363,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
|||
public void handleSignContractResponse(SignContractResponse message, NodeAddress sender) {
|
||||
System.out.println(getClass().getSimpleName() + ".handleSignContractResponse() " + trade.getId());
|
||||
synchronized (trade) {
|
||||
|
||||
|
||||
// check trade
|
||||
if (trade.hasFailed()) {
|
||||
log.warn("{} {} ignoring {} from {} because trade failed with previous error: {}", trade.getClass().getSimpleName(), trade.getId(), message.getClass().getSimpleName(), sender, trade.getErrorMessage());
|
||||
|
@ -511,7 +511,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
|||
protected void handle(PaymentReceivedMessage message, NodeAddress peer) {
|
||||
handle(message, peer, true);
|
||||
}
|
||||
|
||||
|
||||
private void handle(PaymentReceivedMessage message, NodeAddress peer, boolean reprocessOnError) {
|
||||
System.out.println(getClass().getSimpleName() + ".handle(PaymentReceivedMessage)");
|
||||
if (!(trade instanceof BuyerTrade || trade instanceof ArbitratorTrade)) {
|
||||
|
@ -590,7 +590,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
|||
protected FluentProtocol.Condition anyPhase(Trade.Phase... expectedPhases) {
|
||||
return new FluentProtocol.Condition(trade).anyPhase(expectedPhases);
|
||||
}
|
||||
|
||||
|
||||
protected FluentProtocol.Condition state(Trade.State expectedState) {
|
||||
return new FluentProtocol.Condition(trade).state(expectedState);
|
||||
}
|
||||
|
@ -757,7 +757,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
|||
|
||||
// valid if maker pub key
|
||||
if (message.getSignaturePubKey().equals(trade.getMaker().getPubKeyRing().getSignaturePubKey())) return true;
|
||||
|
||||
|
||||
// valid if taker pub key
|
||||
if (message.getSignaturePubKey().equals(trade.getTaker().getPubKeyRing().getSignaturePubKey())) return true;
|
||||
} else {
|
||||
|
@ -771,7 +771,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
|||
// valid if peer's pub key ring
|
||||
if (message.getSignaturePubKey().equals(trade.getTradePeer().getPubKeyRing().getSignaturePubKey())) return true;
|
||||
}
|
||||
|
||||
|
||||
// invalid
|
||||
log.error("SignaturePubKey in message does not match the SignaturePubKey we have set for our arbitrator or trading peer.");
|
||||
return false;
|
||||
|
|
|
@ -21,7 +21,6 @@ package haveno.core.trade.protocol.tasks;
|
|||
import common.utils.JsonUtils;
|
||||
import haveno.common.app.Version;
|
||||
import haveno.common.crypto.PubKeyRing;
|
||||
import haveno.common.crypto.Sig;
|
||||
import haveno.common.taskrunner.TaskRunner;
|
||||
import haveno.core.offer.Offer;
|
||||
import haveno.core.trade.HavenoUtils;
|
||||
|
@ -31,15 +30,15 @@ import haveno.core.trade.messages.DepositResponse;
|
|||
import haveno.core.trade.protocol.TradePeer;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import haveno.network.p2p.SendDirectMessageListener;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import monero.daemon.MoneroDaemon;
|
||||
import monero.daemon.model.MoneroSubmitTxResult;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import monero.daemon.MoneroDaemon;
|
||||
import monero.daemon.model.MoneroSubmitTxResult;
|
||||
|
||||
@Slf4j
|
||||
public class ArbitratorProcessDepositRequest extends TradeTask {
|
||||
|
||||
|
@ -55,7 +54,7 @@ public class ArbitratorProcessDepositRequest extends TradeTask {
|
|||
MoneroDaemon daemon = trade.getXmrWalletService().getDaemon();
|
||||
try {
|
||||
runInterceptHook();
|
||||
|
||||
|
||||
// get contract and signature
|
||||
String contractAsJson = trade.getContractAsJson();
|
||||
DepositRequest request = (DepositRequest) processModel.getTradeMessage(); // TODO (woodser): verify response
|
||||
|
@ -65,7 +64,7 @@ public class ArbitratorProcessDepositRequest extends TradeTask {
|
|||
TradePeer trader = trade.getTradePeer(processModel.getTempTradePeerNodeAddress());
|
||||
if (trader == null) throw new RuntimeException(request.getClass().getSimpleName() + " is not from maker, taker, or arbitrator");
|
||||
PubKeyRing peerPubKeyRing = trader.getPubKeyRing();
|
||||
|
||||
|
||||
// verify signature
|
||||
if (!HavenoUtils.isSignatureValid(peerPubKeyRing, contractAsJson, signature)) {
|
||||
throw new RuntimeException("Peer's contract signature is invalid");
|
||||
|
@ -115,12 +114,12 @@ public class ArbitratorProcessDepositRequest extends TradeTask {
|
|||
if (!takerResult.isGood()) throw new RuntimeException("Error submitting taker deposit tx: " + JsonUtils.serialize(takerResult));
|
||||
daemon.relayTxsByHash(Arrays.asList(processModel.getMaker().getDepositTxHash(), processModel.getTaker().getDepositTxHash()));
|
||||
depositTxsRelayed = true;
|
||||
|
||||
|
||||
// update trade state
|
||||
log.info("Arbitrator submitted deposit txs for trade " + trade.getId());
|
||||
trade.setState(Trade.State.ARBITRATOR_PUBLISHED_DEPOSIT_TXS);
|
||||
processModel.getTradeManager().requestPersistence();
|
||||
|
||||
|
||||
// create deposit response
|
||||
DepositResponse response = new DepositResponse(
|
||||
trade.getOffer().getId(),
|
||||
|
@ -128,7 +127,7 @@ public class ArbitratorProcessDepositRequest extends TradeTask {
|
|||
Version.getP2PMessageVersion(),
|
||||
new Date().getTime(),
|
||||
null);
|
||||
|
||||
|
||||
// send deposit response to maker and taker
|
||||
sendDepositResponse(trade.getMaker().getNodeAddress(), trade.getMaker().getPubKeyRing(), response);
|
||||
sendDepositResponse(trade.getTaker().getNodeAddress(), trade.getTaker().getPubKeyRing(), response);
|
||||
|
@ -145,7 +144,7 @@ public class ArbitratorProcessDepositRequest extends TradeTask {
|
|||
if (!depositTxsRelayed) {
|
||||
try {
|
||||
daemon.flushTxPool(processModel.getMaker().getDepositTxHash(), processModel.getTaker().getDepositTxHash());
|
||||
} catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -156,7 +155,7 @@ public class ArbitratorProcessDepositRequest extends TradeTask {
|
|||
Version.getP2PMessageVersion(),
|
||||
new Date().getTime(),
|
||||
t.getMessage());
|
||||
|
||||
|
||||
// send deposit response to maker and taker
|
||||
sendDepositResponse(trade.getMaker().getNodeAddress(), trade.getMaker().getPubKeyRing(), response);
|
||||
sendDepositResponse(trade.getTaker().getNodeAddress(), trade.getTaker().getPubKeyRing(), response);
|
||||
|
|
|
@ -24,14 +24,14 @@ import haveno.core.offer.OfferDirection;
|
|||
import haveno.core.trade.Trade;
|
||||
import haveno.core.trade.messages.InitTradeRequest;
|
||||
import haveno.core.trade.protocol.TradePeer;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import monero.daemon.model.MoneroTx;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* Arbitrator verifies reserve tx from maker or taker.
|
||||
*
|
||||
*
|
||||
* The maker reserve tx is only verified here if this arbitrator is not
|
||||
* the original offer signer and thus does not have the original reserve tx.
|
||||
*/
|
||||
|
@ -50,9 +50,9 @@ public class ArbitratorProcessReserveTx extends TradeTask {
|
|||
InitTradeRequest request = (InitTradeRequest) processModel.getTradeMessage();
|
||||
boolean isFromTaker = request.getSenderNodeAddress().equals(trade.getTaker().getNodeAddress());
|
||||
boolean isFromBuyer = isFromTaker ? offer.getDirection() == OfferDirection.SELL : offer.getDirection() == OfferDirection.BUY;
|
||||
|
||||
|
||||
// TODO (woodser): if signer online, should never be called by maker
|
||||
|
||||
|
||||
// process reserve tx with expected values
|
||||
BigInteger tradeFee = isFromTaker ? trade.getTakerFee() : trade.getMakerFee();
|
||||
BigInteger sendAmount = isFromBuyer ? BigInteger.valueOf(0) : offer.getAmount();
|
||||
|
@ -72,14 +72,14 @@ public class ArbitratorProcessReserveTx extends TradeTask {
|
|||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error processing reserve tx from " + (isFromTaker ? "taker " : "maker ") + request.getSenderNodeAddress() + ", offerId=" + offer.getId() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
// save reserve tx to model
|
||||
TradePeer trader = isFromTaker ? processModel.getTaker() : processModel.getMaker();
|
||||
trader.setReserveTxHash(request.getReserveTxHash());
|
||||
trader.setReserveTxHex(request.getReserveTxHex());
|
||||
trader.setReserveTxKey(request.getReserveTxKey());
|
||||
trader.setSecurityDeposit(txResult.second);
|
||||
|
||||
|
||||
// persist trade
|
||||
processModel.getTradeManager().requestPersistence();
|
||||
complete();
|
||||
|
|
|
@ -24,20 +24,21 @@ import haveno.core.trade.Trade;
|
|||
import haveno.core.trade.messages.InitMultisigRequest;
|
||||
import haveno.core.trade.messages.InitTradeRequest;
|
||||
import haveno.network.p2p.SendDirectMessageListener;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import monero.wallet.MoneroWallet;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Arbitrator sends InitTradeRequest to maker after receiving InitTradeRequest
|
||||
* from taker and verifying taker reserve tx.
|
||||
*
|
||||
*
|
||||
* Arbitrator sends InitMultisigRequests after the maker acks.
|
||||
*/
|
||||
@Slf4j
|
||||
public class ArbitratorSendInitTradeOrMultisigRequests extends TradeTask {
|
||||
|
||||
|
||||
@SuppressWarnings({"unused"})
|
||||
public ArbitratorSendInitTradeOrMultisigRequests(TaskRunner taskHandler, Trade trade) {
|
||||
super(taskHandler, trade);
|
||||
|
@ -109,7 +110,7 @@ public class ArbitratorSendInitTradeOrMultisigRequests extends TradeTask {
|
|||
failed(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void sendInitMultisigRequests() {
|
||||
|
||||
// ensure arbitrator has maker's reserve tx
|
||||
|
|
|
@ -20,22 +20,18 @@ package haveno.core.trade.protocol.tasks;
|
|||
import com.google.common.base.Preconditions;
|
||||
import haveno.common.taskrunner.TaskRunner;
|
||||
import haveno.core.trade.Trade;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
|
||||
|
||||
import monero.wallet.MoneroWallet;
|
||||
import monero.wallet.model.MoneroAccount;
|
||||
import monero.wallet.model.MoneroSubaddress;
|
||||
import monero.wallet.model.MoneroTxWallet;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Slf4j
|
||||
public class BuyerPreparePaymentSentMessage extends TradeTask {
|
||||
|
||||
|
@ -78,7 +74,7 @@ public class BuyerPreparePaymentSentMessage extends TradeTask {
|
|||
failed(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO (woodser): move these to gen utils
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,10 +24,10 @@ import haveno.core.trade.Trade;
|
|||
import haveno.core.trade.messages.InitTradeRequest;
|
||||
import haveno.core.xmr.model.XmrAddressEntry;
|
||||
import haveno.network.p2p.SendDirectMessageListener;
|
||||
import java.util.UUID;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static haveno.core.util.Validator.checkTradeId;
|
||||
|
||||
|
|
|
@ -17,11 +17,6 @@
|
|||
|
||||
package haveno.core.trade.protocol.tasks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import haveno.common.app.Version;
|
||||
import haveno.common.taskrunner.TaskRunner;
|
||||
import haveno.core.trade.ArbitratorTrade;
|
||||
|
@ -36,10 +31,15 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import monero.daemon.model.MoneroOutput;
|
||||
import monero.wallet.model.MoneroTxWallet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
// TODO (woodser): separate classes for deposit tx creation and contract request, or combine into ProcessInitMultisigRequest
|
||||
@Slf4j
|
||||
public class MaybeSendSignContractRequest extends TradeTask {
|
||||
|
||||
|
||||
private boolean ack1 = false; // TODO (woodser) these represent onArrived(), not the ack
|
||||
private boolean ack2 = false;
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class MaybeSendSignContractRequest extends TradeTask {
|
|||
protected void run() {
|
||||
try {
|
||||
runInterceptHook();
|
||||
|
||||
|
||||
// skip if arbitrator
|
||||
if (trade instanceof ArbitratorTrade) {
|
||||
complete();
|
||||
|
@ -64,7 +64,7 @@ public class MaybeSendSignContractRequest extends TradeTask {
|
|||
complete();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// skip if deposit tx already created
|
||||
if (processModel.getDepositTxXmr() != null) {
|
||||
complete();
|
||||
|
@ -119,7 +119,7 @@ public class MaybeSendSignContractRequest extends TradeTask {
|
|||
failed();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// send request to arbitrator
|
||||
processModel.getP2PService().sendEncryptedDirectMessage(trade.getArbitrator().getNodeAddress(), trade.getArbitrator().getPubKeyRing(), request, new SendDirectMessageListener() {
|
||||
@Override
|
||||
|
@ -139,7 +139,7 @@ public class MaybeSendSignContractRequest extends TradeTask {
|
|||
failed(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void completeAux() {
|
||||
trade.setState(State.CONTRACT_SIGNATURE_REQUESTED);
|
||||
processModel.getTradeManager().requestPersistence();
|
||||
|
|
|
@ -29,18 +29,17 @@ import haveno.core.trade.protocol.TradePeer;
|
|||
import haveno.core.xmr.wallet.XmrWalletService;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import haveno.network.p2p.SendDirectMessageListener;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import monero.wallet.MoneroWallet;
|
||||
import monero.wallet.model.MoneroMultisigInitResult;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static haveno.core.util.Validator.checkTradeId;
|
||||
|
||||
import monero.wallet.MoneroWallet;
|
||||
import monero.wallet.model.MoneroMultisigInitResult;
|
||||
|
||||
@Slf4j
|
||||
public class ProcessInitMultisigRequest extends TradeTask {
|
||||
|
||||
|
|
|
@ -29,13 +29,13 @@ import haveno.core.trade.messages.InitTradeRequest;
|
|||
import haveno.core.trade.protocol.TradePeer;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static haveno.core.util.Validator.checkTradeId;
|
||||
import static haveno.core.util.Validator.nonEmptyStringOf;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Slf4j
|
||||
public class ProcessInitTradeRequest extends TradeTask {
|
||||
@SuppressWarnings({"unused"})
|
||||
|
@ -58,7 +58,7 @@ public class ProcessInitTradeRequest extends TradeTask {
|
|||
if (trade instanceof ArbitratorTrade) {
|
||||
trade.getMaker().setPubKeyRing((trade.getOffer().getPubKeyRing()));
|
||||
trade.getArbitrator().setPubKeyRing(processModel.getPubKeyRing()); // TODO (woodser): why duplicating field in process model
|
||||
|
||||
|
||||
// handle request from taker
|
||||
if (request.getSenderNodeAddress().equals(request.getTakerNodeAddress())) {
|
||||
multisigParticipant = processModel.getTaker();
|
||||
|
@ -78,7 +78,7 @@ public class ProcessInitTradeRequest extends TradeTask {
|
|||
failed(e2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// handle request from maker
|
||||
else if (request.getSenderNodeAddress().equals(request.getMakerNodeAddress())) {
|
||||
multisigParticipant = processModel.getMaker();
|
||||
|
@ -91,7 +91,7 @@ public class ProcessInitTradeRequest extends TradeTask {
|
|||
throw new RuntimeException("Sender is not trade's maker or taker");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// handle request as maker
|
||||
else if (trade instanceof MakerTrade) {
|
||||
multisigParticipant = processModel.getTaker();
|
||||
|
@ -109,7 +109,7 @@ public class ProcessInitTradeRequest extends TradeTask {
|
|||
failed(e2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// handle invalid trade type
|
||||
else {
|
||||
throw new RuntimeException("Invalid trade type to process init trade request: " + trade.getClass().getName());
|
||||
|
|
|
@ -28,12 +28,11 @@ import haveno.core.trade.Trade;
|
|||
import haveno.core.trade.messages.PaymentReceivedMessage;
|
||||
import haveno.core.util.Validator;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@Slf4j
|
||||
public class ProcessPaymentReceivedMessage extends TradeTask {
|
||||
public ProcessPaymentReceivedMessage(TaskRunner<Trade> taskHandler, Trade trade) {
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
package haveno.core.trade.protocol.tasks;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import haveno.common.taskrunner.TaskRunner;
|
||||
import haveno.core.trade.HavenoUtils;
|
||||
import haveno.core.trade.Trade;
|
||||
|
@ -26,6 +24,8 @@ import haveno.core.trade.messages.PaymentSentMessage;
|
|||
import haveno.core.util.Validator;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Slf4j
|
||||
public class ProcessPaymentSentMessage extends TradeTask {
|
||||
public ProcessPaymentSentMessage(TaskRunner<Trade> taskHandler, Trade trade) {
|
||||
|
|
|
@ -18,12 +18,6 @@
|
|||
package haveno.core.trade.protocol.tasks;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
import javax.crypto.SecretKey;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import haveno.common.app.Version;
|
||||
import haveno.common.crypto.Encryption;
|
||||
|
@ -44,9 +38,15 @@ import haveno.network.p2p.NodeAddress;
|
|||
import haveno.network.p2p.SendDirectMessageListener;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Slf4j
|
||||
public class ProcessSignContractRequest extends TradeTask {
|
||||
|
||||
|
||||
private boolean ack1 = false;
|
||||
private boolean ack2 = false;
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class ProcessSignContractRequest extends TradeTask {
|
|||
trader.setAccountId(request.getAccountId());
|
||||
trader.setPaymentAccountPayloadHash(request.getPaymentAccountPayloadHash());
|
||||
trader.setPayoutAddressString(request.getPayoutAddress());
|
||||
|
||||
|
||||
// maker sends witness signature of deposit tx hash
|
||||
if (trader == trade.getMaker()) {
|
||||
trader.setAccountAgeWitnessNonce(request.getDepositTxHash().getBytes(Charsets.UTF_8));
|
||||
|
|
|
@ -27,13 +27,14 @@ import haveno.core.trade.messages.DepositRequest;
|
|||
import haveno.core.trade.messages.SignContractResponse;
|
||||
import haveno.core.trade.protocol.TradePeer;
|
||||
import haveno.network.p2p.SendDirectMessageListener;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class ProcessSignContractResponse extends TradeTask {
|
||||
|
||||
|
||||
@SuppressWarnings({"unused"})
|
||||
public ProcessSignContractResponse(TaskRunner taskHandler, Trade trade) {
|
||||
super(taskHandler, trade);
|
||||
|
|
|
@ -27,13 +27,13 @@ import haveno.core.trade.protocol.TradePeer;
|
|||
import haveno.core.util.Validator;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Slf4j
|
||||
public class ResendDisputeClosedMessageWithPayout extends TradeTask {
|
||||
|
||||
|
||||
@SuppressWarnings({"unused"})
|
||||
public ResendDisputeClosedMessageWithPayout(TaskRunner taskHandler, Trade trade) {
|
||||
super(taskHandler, trade);
|
||||
|
@ -50,7 +50,7 @@ public class ResendDisputeClosedMessageWithPayout extends TradeTask {
|
|||
Validator.checkTradeId(processModel.getOfferId(), request);
|
||||
TradePeer sender = trade.getTradePeer(request.getPubKeyRing());
|
||||
if (sender == null) throw new RuntimeException("Pub key ring is not from arbitrator, buyer, or seller");
|
||||
|
||||
|
||||
// arbitrator resends DisputeClosedMessage with payout tx when updated multisig info received
|
||||
boolean ticketClosed = false;
|
||||
if (!trade.isPayoutPublished() && trade.isArbitrator()) {
|
||||
|
|
|
@ -17,12 +17,9 @@
|
|||
|
||||
package haveno.core.trade.protocol.tasks;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import haveno.common.crypto.PubKeyRing;
|
||||
import haveno.common.crypto.Sig;
|
||||
import haveno.common.taskrunner.TaskRunner;
|
||||
import haveno.core.account.sign.SignedWitness;
|
||||
import haveno.core.account.witness.AccountAgeWitnessService;
|
||||
|
@ -32,6 +29,10 @@ import haveno.core.trade.messages.PaymentReceivedMessage;
|
|||
import haveno.core.trade.messages.TradeMailboxMessage;
|
||||
import haveno.core.util.JsonUtil;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Slf4j
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
@ -90,7 +91,7 @@ public abstract class SellerSendPaymentReceivedMessage extends SendMailboxMessag
|
|||
// sign message
|
||||
try {
|
||||
String messageAsJson = JsonUtil.objectToJson(message);
|
||||
byte[] sig = HavenoUtils.sign(processModel.getP2PService().getKeyRing(), messageAsJson);
|
||||
byte[] sig = Sig.sign(processModel.getP2PService().getKeyRing().getSignatureKeyPair().getPrivate(), messageAsJson.getBytes(Charsets.UTF_8));
|
||||
message.setSellerSignature(sig);
|
||||
processModel.setPaymentReceivedMessage(message);
|
||||
trade.requestPersistence();
|
||||
|
|
|
@ -21,13 +21,13 @@ import haveno.common.taskrunner.TaskRunner;
|
|||
import haveno.core.offer.OfferDirection;
|
||||
import haveno.core.trade.Trade;
|
||||
import haveno.core.xmr.model.XmrAddressEntry;
|
||||
import monero.daemon.model.MoneroOutput;
|
||||
import monero.wallet.model.MoneroTxWallet;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import monero.daemon.model.MoneroOutput;
|
||||
import monero.wallet.model.MoneroTxWallet;
|
||||
|
||||
public class TakerReserveTradeFunds extends TradeTask {
|
||||
|
||||
public TakerReserveTradeFunds(TaskRunner taskHandler, Trade trade) {
|
||||
|
|
|
@ -27,9 +27,10 @@ import haveno.core.trade.Trade;
|
|||
import haveno.core.trade.messages.InitTradeRequest;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import haveno.network.p2p.SendDirectMessageListener;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class TakerSendInitTradeRequestToArbitrator extends TradeTask {
|
||||
|
@ -81,7 +82,7 @@ public class TakerSendInitTradeRequestToArbitrator extends TradeTask {
|
|||
}
|
||||
|
||||
private void sendInitTradeRequest(NodeAddress arbitratorNodeAddress, SendDirectMessageListener listener) {
|
||||
|
||||
|
||||
// get registered arbitrator
|
||||
Arbitrator arbitrator = processModel.getUser().getAcceptedArbitratorByAddress(arbitratorNodeAddress);
|
||||
if (arbitrator == null) throw new RuntimeException("Node address " + arbitratorNodeAddress + " is not a registered arbitrator");
|
||||
|
|
|
@ -26,11 +26,10 @@ import haveno.core.payment.payload.PaymentAccountPayload;
|
|||
import haveno.core.trade.ArbitratorTrade;
|
||||
import haveno.core.trade.Trade;
|
||||
import haveno.core.trade.protocol.TradePeer;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Slf4j
|
||||
|
|
|
@ -27,10 +27,10 @@ import haveno.core.trade.protocol.tasks.TradeTask;
|
|||
import haveno.network.p2p.NodeAddress;
|
||||
import haveno.network.p2p.P2PService;
|
||||
import haveno.network.p2p.SendMailboxMessageListener;
|
||||
import java.util.UUID;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Slf4j
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
|
||||
package haveno.core.trade.statistics;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import haveno.core.user.Preferences;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
public class ReferralIdService {
|
||||
private final Preferences preferences;
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package haveno.core.trade.statistics;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.protobuf.ByteString;
|
||||
import haveno.common.app.Capabilities;
|
||||
import haveno.common.app.Capability;
|
||||
|
@ -40,27 +42,21 @@ import haveno.network.p2p.storage.payload.CapabilityRequiringPayload;
|
|||
import haveno.network.p2p.storage.payload.DateSortedTruncatablePayload;
|
||||
import haveno.network.p2p.storage.payload.PersistableNetworkPayload;
|
||||
import haveno.network.p2p.storage.payload.ProcessOncePersistableNetworkPayload;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.utils.ExchangeRate;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
|
@ -81,16 +77,16 @@ public final class TradeStatistics3 implements ProcessOncePersistableNetworkPayl
|
|||
if (referralId != null) {
|
||||
extraDataMap.put(OfferPayload.REFERRAL_ID, referralId);
|
||||
}
|
||||
|
||||
|
||||
NodeAddress arbitratorNodeAddress = checkNotNull(trade.getArbitrator().getNodeAddress());
|
||||
|
||||
|
||||
// The first 4 chars are sufficient to identify an arbitrator.
|
||||
// For testing with regtest/localhost we use the full address as its localhost and would result in
|
||||
// same values for multiple arbitrators.
|
||||
String truncatedArbitratorNodeAddress = isTorNetworkNode ?
|
||||
arbitratorNodeAddress.getFullAddress().substring(0, 4) :
|
||||
arbitratorNodeAddress.getFullAddress();
|
||||
|
||||
|
||||
Offer offer = checkNotNull(trade.getOffer());
|
||||
return new TradeStatistics3(offer.getCurrencyCode(),
|
||||
trade.getPrice().getValue(),
|
||||
|
|
|
@ -21,14 +21,13 @@ import haveno.common.config.Config;
|
|||
import haveno.common.persistence.PersistenceManager;
|
||||
import haveno.network.p2p.storage.payload.PersistableNetworkPayload;
|
||||
import haveno.network.p2p.storage.persistence.HistoricalDataStoreService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Singleton
|
||||
@Slf4j
|
||||
public class TradeStatistics3StorageService extends HistoricalDataStoreService<TradeStatistics3Store> {
|
||||
|
|
|
@ -20,11 +20,11 @@ package haveno.core.trade.statistics;
|
|||
import com.google.protobuf.Message;
|
||||
import haveno.network.p2p.storage.P2PDataStorage;
|
||||
import haveno.network.p2p.storage.persistence.PersistableNetworkPayloadStore;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* We store only the payload in the PB file to save disc space. The hash of the payload can be created anyway and
|
||||
* is only used as key in the map. So we have a hybrid data structure which is represented as list in the protobuffer
|
||||
|
|
|
@ -26,9 +26,8 @@ import lombok.EqualsAndHashCode;
|
|||
import lombok.ToString;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import java.math.BigInteger;
|
||||
|
||||
@Immutable
|
||||
@EqualsAndHashCode
|
||||
|
|
|
@ -30,26 +30,21 @@ import haveno.core.util.JsonUtil;
|
|||
import haveno.network.p2p.P2PService;
|
||||
import haveno.network.p2p.storage.P2PDataStorage;
|
||||
import haveno.network.p2p.storage.persistence.AppendOnlyDataStoreService;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableSet;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
import java.io.File;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Singleton
|
||||
@Slf4j
|
||||
public class TradeStatisticsManager {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package haveno.core.trade.txproof;
|
||||
|
||||
import haveno.common.handlers.FaultHandler;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface AssetTxProofRequest<R extends AssetTxProofRequest.Result> {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package haveno.core.trade.txproof;
|
||||
|
||||
import haveno.common.handlers.FaultHandler;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface AssetTxProofRequestsPerTrade {
|
||||
|
|
|
@ -25,11 +25,11 @@ import haveno.core.payment.payload.PaymentAccountPayload;
|
|||
import haveno.core.trade.Trade;
|
||||
import haveno.core.trade.txproof.AssetTxProofModel;
|
||||
import haveno.core.user.AutoConfirmSettings;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.Value;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
|
|
|
@ -25,10 +25,10 @@ import com.google.gson.JsonParseException;
|
|||
import haveno.asset.CryptoNoteUtils;
|
||||
import haveno.common.app.DevEnv;
|
||||
import haveno.core.trade.txproof.AssetTxProofParser;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
public class XmrTxProofParser implements AssetTxProofParser<XmrTxProofRequest.Result, XmrTxProofModel> {
|
||||
public static final long MAX_DATE_TOLERANCE = TimeUnit.HOURS.toSeconds(2);
|
||||
|
|
|
@ -17,6 +17,11 @@
|
|||
|
||||
package haveno.core.trade.txproof.xmr;
|
||||
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonParser;
|
||||
import haveno.common.UserThread;
|
||||
|
@ -27,22 +32,14 @@ import haveno.core.trade.txproof.AssetTxProofHttpClient;
|
|||
import haveno.core.trade.txproof.AssetTxProofParser;
|
||||
import haveno.core.trade.txproof.AssetTxProofRequest;
|
||||
import haveno.network.Socks5ProxyProvider;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Requests for the XMR tx proof for a particular trade from a particular service.
|
||||
|
|
|
@ -30,9 +30,10 @@ import haveno.core.trade.txproof.AssetTxProofResult;
|
|||
import haveno.core.user.AutoConfirmSettings;
|
||||
import haveno.network.Socks5ProxyProvider;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.HashSet;
|
||||
|
@ -40,9 +41,6 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Handles the XMR tx proof requests for multiple services per trade.
|
||||
*/
|
||||
|
|
|
@ -36,26 +36,22 @@ import haveno.core.user.Preferences;
|
|||
import haveno.network.Socks5ProxyProvider;
|
||||
import haveno.network.p2p.BootstrapListener;
|
||||
import haveno.network.p2p.P2PService;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.fxmisc.easybind.EasyBind;
|
||||
import org.fxmisc.easybind.monadic.MonadicBinding;
|
||||
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.fxmisc.easybind.EasyBind;
|
||||
import org.fxmisc.easybind.monadic.MonadicBinding;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue