mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-03 04:06:23 -04:00
Use byte array instead of PubKeys, Use uid for mailbox msg, Improve storage data structure, Renamings, Cleanup
This commit is contained in:
parent
bb6334f6a0
commit
77511a43f5
101 changed files with 869 additions and 1074 deletions
|
@ -18,30 +18,48 @@
|
|||
package io.bitsquare.alert;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.p2p.storage.data.StoragePayload;
|
||||
import io.bitsquare.common.crypto.Sig;
|
||||
import io.bitsquare.p2p.storage.payload.StoragePayload;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.KeyFactory;
|
||||
import java.security.PublicKey;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class Alert implements StoragePayload {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(Alert.class);
|
||||
private static final long TTL = TimeUnit.DAYS.toMillis(10);
|
||||
|
||||
public final String message;
|
||||
public final boolean isUpdateInfo;
|
||||
private String signatureAsBase64;
|
||||
private PublicKey storagePublicKey;
|
||||
private transient PublicKey storagePublicKey;
|
||||
private byte[] storagePublicKeyBytes;
|
||||
|
||||
public Alert(String message, boolean isUpdateInfo) {
|
||||
this.message = message;
|
||||
this.isUpdateInfo = isUpdateInfo;
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
try {
|
||||
in.defaultReadObject();
|
||||
storagePublicKey = KeyFactory.getInstance(Sig.KEY_ALGO, "BC").generatePublic(new X509EncodedKeySpec(storagePublicKeyBytes));
|
||||
} catch (Throwable t) {
|
||||
log.error("Exception at readObject: " + t.getMessage());
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSigAndStoragePubKey(String signatureAsBase64, PublicKey storagePublicKey) {
|
||||
this.signatureAsBase64 = signatureAsBase64;
|
||||
this.storagePublicKey = storagePublicKey;
|
||||
this.storagePublicKeyBytes = new X509EncodedKeySpec(this.storagePublicKey.getEncoded()).getEncoded();
|
||||
}
|
||||
|
||||
public String getSignatureAsBase64() {
|
||||
|
|
|
@ -20,7 +20,7 @@ package io.bitsquare.alert;
|
|||
import com.google.inject.Inject;
|
||||
import io.bitsquare.common.crypto.KeyRing;
|
||||
import io.bitsquare.p2p.storage.HashMapChangedListener;
|
||||
import io.bitsquare.p2p.storage.data.ProtectedData;
|
||||
import io.bitsquare.p2p.storage.storageentry.ProtectedStorageEntry;
|
||||
import io.bitsquare.user.User;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.ReadOnlyObjectProperty;
|
||||
|
@ -60,18 +60,18 @@ public class AlertManager {
|
|||
|
||||
alertService.addHashSetChangedListener(new HashMapChangedListener() {
|
||||
@Override
|
||||
public void onAdded(ProtectedData data) {
|
||||
if (data.expirablePayload instanceof Alert) {
|
||||
Alert alert = (Alert) data.expirablePayload;
|
||||
public void onAdded(ProtectedStorageEntry data) {
|
||||
if (data.getStoragePayload() instanceof Alert) {
|
||||
Alert alert = (Alert) data.getStoragePayload();
|
||||
if (verifySignature(alert))
|
||||
alertMessageProperty.set(alert);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoved(ProtectedData data) {
|
||||
if (data.expirablePayload instanceof Alert) {
|
||||
Alert alert = (Alert) data.expirablePayload;
|
||||
public void onRemoved(ProtectedStorageEntry data) {
|
||||
if (data.getStoragePayload() instanceof Alert) {
|
||||
Alert alert = (Alert) data.getStoragePayload();
|
||||
if (verifySignature(alert))
|
||||
alertMessageProperty.set(null);
|
||||
}
|
||||
|
|
|
@ -20,9 +20,10 @@ package io.bitsquare.arbitration;
|
|||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.crypto.PubKeyRing;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.storage.data.StoragePayload;
|
||||
import io.bitsquare.p2p.storage.payload.StoragePayload;
|
||||
|
||||
import java.security.PublicKey;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -38,7 +39,7 @@ public final class Arbitrator implements StoragePayload {
|
|||
private final byte[] btcPubKey;
|
||||
private final PubKeyRing pubKeyRing;
|
||||
private final NodeAddress arbitratorNodeAddress;
|
||||
private final List<String> languageCodes;
|
||||
private final ArrayList<String> languageCodes;
|
||||
private final String btcAddress;
|
||||
private final long registrationDate;
|
||||
private final String registrationSignature;
|
||||
|
@ -48,7 +49,7 @@ public final class Arbitrator implements StoragePayload {
|
|||
byte[] btcPubKey,
|
||||
String btcAddress,
|
||||
PubKeyRing pubKeyRing,
|
||||
List<String> languageCodes,
|
||||
ArrayList<String> languageCodes,
|
||||
Date registrationDate,
|
||||
byte[] registrationPubKey,
|
||||
String registrationSignature) {
|
||||
|
|
|
@ -29,7 +29,7 @@ import io.bitsquare.p2p.BootstrapListener;
|
|||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.P2PService;
|
||||
import io.bitsquare.p2p.storage.HashMapChangedListener;
|
||||
import io.bitsquare.p2p.storage.data.ProtectedData;
|
||||
import io.bitsquare.p2p.storage.storageentry.ProtectedStorageEntry;
|
||||
import io.bitsquare.user.User;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableMap;
|
||||
|
@ -117,12 +117,12 @@ public class ArbitratorManager {
|
|||
|
||||
arbitratorService.addHashSetChangedListener(new HashMapChangedListener() {
|
||||
@Override
|
||||
public void onAdded(ProtectedData data) {
|
||||
public void onAdded(ProtectedStorageEntry data) {
|
||||
applyArbitrators();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoved(ProtectedData data) {
|
||||
public void onRemoved(ProtectedStorageEntry data) {
|
||||
applyArbitrators();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -84,8 +84,8 @@ public class ArbitratorService {
|
|||
|
||||
public Map<NodeAddress, Arbitrator> getArbitrators() {
|
||||
Set<Arbitrator> arbitratorSet = p2PService.getDataMap().values().stream()
|
||||
.filter(data -> data.expirablePayload instanceof Arbitrator)
|
||||
.map(data -> (Arbitrator) data.expirablePayload)
|
||||
.filter(data -> data.getStoragePayload() instanceof Arbitrator)
|
||||
.map(data -> (Arbitrator) data.getStoragePayload())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Map<NodeAddress, Arbitrator> map = new HashMap<>();
|
||||
|
|
|
@ -26,7 +26,6 @@ import io.bitsquare.trade.Contract;
|
|||
import javafx.beans.property.*;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -36,7 +35,6 @@ import java.io.ObjectInputStream;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public final class Dispute implements Payload {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
|
@ -71,11 +69,12 @@ public final class Dispute implements Payload {
|
|||
private final PubKeyRing arbitratorPubKeyRing;
|
||||
private final boolean isSupportTicket;
|
||||
|
||||
private final List<DisputeCommunicationMessage> disputeCommunicationMessages = new ArrayList<>();
|
||||
private final ArrayList<DisputeCommunicationMessage> disputeCommunicationMessages = new ArrayList<>();
|
||||
|
||||
private boolean isClosed;
|
||||
private DisputeResult disputeResult;
|
||||
private Transaction disputePayoutTx;
|
||||
@Nullable
|
||||
private String disputePayoutTxId;
|
||||
|
||||
transient private Storage<DisputeList<Dispute>> storage;
|
||||
transient private ObservableList<DisputeCommunicationMessage> disputeCommunicationMessagesAsObservableList = FXCollections.observableArrayList(disputeCommunicationMessages);
|
||||
|
@ -171,8 +170,8 @@ public final class Dispute implements Payload {
|
|||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
public void setDisputePayoutTx(Transaction disputePayoutTx) {
|
||||
this.disputePayoutTx = disputePayoutTx;
|
||||
public void setDisputePayoutTxId(String disputePayoutTxId) {
|
||||
this.disputePayoutTxId = disputePayoutTxId;
|
||||
}
|
||||
|
||||
|
||||
|
@ -280,8 +279,8 @@ public final class Dispute implements Payload {
|
|||
return new Date(tradeDate);
|
||||
}
|
||||
|
||||
public Transaction getDisputePayoutTx() {
|
||||
return disputePayoutTx;
|
||||
public String getDisputePayoutTxId() {
|
||||
return disputePayoutTxId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -299,6 +298,7 @@ public final class Dispute implements Payload {
|
|||
if (isSupportTicket != dispute.isSupportTicket) return false;
|
||||
if (isClosed != dispute.isClosed) return false;
|
||||
if (tradeId != null ? !tradeId.equals(dispute.tradeId) : dispute.tradeId != null) return false;
|
||||
if (id != null ? !id.equals(dispute.id) : dispute.id != null) return false;
|
||||
if (traderPubKeyRing != null ? !traderPubKeyRing.equals(dispute.traderPubKeyRing) : dispute.traderPubKeyRing != null)
|
||||
return false;
|
||||
if (contract != null ? !contract.equals(dispute.contract) : dispute.contract != null) return false;
|
||||
|
@ -317,13 +317,18 @@ public final class Dispute implements Payload {
|
|||
return false;
|
||||
if (disputeCommunicationMessages != null ? !disputeCommunicationMessages.equals(dispute.disputeCommunicationMessages) : dispute.disputeCommunicationMessages != null)
|
||||
return false;
|
||||
return !(disputeResult != null ? !disputeResult.equals(dispute.disputeResult) : dispute.disputeResult != null);
|
||||
if (disputeResult != null ? !disputeResult.equals(dispute.disputeResult) : dispute.disputeResult != null)
|
||||
return false;
|
||||
if (disputePayoutTxId != null ? !disputePayoutTxId.equals(dispute.disputePayoutTxId) : dispute.disputePayoutTxId != null)
|
||||
return false;
|
||||
return !(storage != null ? !storage.equals(dispute.storage) : dispute.storage != null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = tradeId != null ? tradeId.hashCode() : 0;
|
||||
result = 31 * result + (id != null ? id.hashCode() : 0);
|
||||
result = 31 * result + traderId;
|
||||
result = 31 * result + (disputeOpenerIsBuyer ? 1 : 0);
|
||||
result = 31 * result + (disputeOpenerIsOfferer ? 1 : 0);
|
||||
|
@ -344,27 +349,39 @@ public final class Dispute implements Payload {
|
|||
result = 31 * result + (disputeCommunicationMessages != null ? disputeCommunicationMessages.hashCode() : 0);
|
||||
result = 31 * result + (isClosed ? 1 : 0);
|
||||
result = 31 * result + (disputeResult != null ? disputeResult.hashCode() : 0);
|
||||
result = 31 * result + (disputePayoutTxId != null ? disputePayoutTxId.hashCode() : 0);
|
||||
result = 31 * result + (storage != null ? storage.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Dispute{" +
|
||||
", tradeId='" + tradeId + '\'' +
|
||||
", traderId='" + traderId + '\'' +
|
||||
"tradeId='" + tradeId + '\'' +
|
||||
", id='" + id + '\'' +
|
||||
", traderId=" + traderId +
|
||||
", disputeOpenerIsBuyer=" + disputeOpenerIsBuyer +
|
||||
", disputeOpenerIsOfferer=" + disputeOpenerIsOfferer +
|
||||
", openingDate=" + openingDate +
|
||||
", traderPubKeyRing=" + traderPubKeyRing +
|
||||
", tradeDate=" + tradeDate +
|
||||
", contract=" + contract +
|
||||
", contractHash=" + Arrays.toString(contractHash) +
|
||||
", depositTxSerialized=" + Arrays.toString(depositTxSerialized) +
|
||||
", payoutTxSerialized=" + Arrays.toString(payoutTxSerialized) +
|
||||
", depositTxId='" + depositTxId + '\'' +
|
||||
", payoutTxId='" + payoutTxId + '\'' +
|
||||
", contractAsJson='" + contractAsJson + '\'' +
|
||||
", buyerContractSignature='" + offererContractSignature + '\'' +
|
||||
", sellerContractSignature='" + takerContractSignature + '\'' +
|
||||
", offererContractSignature='" + offererContractSignature + '\'' +
|
||||
", takerContractSignature='" + takerContractSignature + '\'' +
|
||||
", arbitratorPubKeyRing=" + arbitratorPubKeyRing +
|
||||
", disputeDirectMessages=" + disputeCommunicationMessages +
|
||||
", disputeDirectMessagesAsObservableList=" + disputeCommunicationMessagesAsObservableList +
|
||||
", isSupportTicket=" + isSupportTicket +
|
||||
", disputeCommunicationMessages=" + disputeCommunicationMessages +
|
||||
", isClosed=" + isClosed +
|
||||
", disputeResult=" + disputeResult +
|
||||
", disputePayoutTxId='" + disputePayoutTxId + '\'' +
|
||||
", disputeCommunicationMessagesAsObservableList=" + disputeCommunicationMessagesAsObservableList +
|
||||
", isClosedProperty=" + isClosedProperty +
|
||||
", disputeResultProperty=" + disputeResultProperty +
|
||||
'}';
|
||||
}
|
||||
|
|
|
@ -28,11 +28,11 @@ import io.bitsquare.btc.exceptions.TransactionVerificationException;
|
|||
import io.bitsquare.btc.exceptions.WalletException;
|
||||
import io.bitsquare.common.crypto.KeyRing;
|
||||
import io.bitsquare.common.crypto.PubKeyRing;
|
||||
import io.bitsquare.crypto.DecryptedMsgWithPubKey;
|
||||
import io.bitsquare.p2p.BootstrapListener;
|
||||
import io.bitsquare.p2p.Message;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.P2PService;
|
||||
import io.bitsquare.p2p.messaging.DecryptedMsgWithPubKey;
|
||||
import io.bitsquare.p2p.messaging.SendMailboxMessageListener;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.trade.Contract;
|
||||
|
@ -513,7 +513,7 @@ public class DisputeManager {
|
|||
|
||||
// after successful publish we send peer the tx
|
||||
|
||||
dispute.setDisputePayoutTx(transaction);
|
||||
dispute.setDisputePayoutTxId(transaction.getHashAsString());
|
||||
sendPeerPublishedPayoutTxMessage(transaction, dispute, contract);
|
||||
}
|
||||
|
||||
|
@ -551,7 +551,7 @@ public class DisputeManager {
|
|||
// losing trader or in case of 50/50 the seller gets the tx sent from the winner or buyer
|
||||
private void onDisputedPayoutTxMessage(PeerPublishedPayoutTxMessage peerPublishedPayoutTxMessage) {
|
||||
Transaction transaction = tradeWalletService.addTransactionToWallet(peerPublishedPayoutTxMessage.transaction);
|
||||
findOwnDispute(peerPublishedPayoutTxMessage.tradeId).ifPresent(dispute -> dispute.setDisputePayoutTx(transaction));
|
||||
findOwnDispute(peerPublishedPayoutTxMessage.tradeId).ifPresent(dispute -> dispute.setDisputePayoutTxId(transaction.getHashAsString()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -585,11 +585,11 @@ public class DisputeManager {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private Optional<Dispute> findDispute(String tradeId, int traderId) {
|
||||
return disputes.stream().filter(e -> e.getTradeId().equals(tradeId) && e.getTraderId() == traderId).findFirst();
|
||||
return disputes.stream().filter(e -> e.getTradeId().equals(tradeId) && e.getTraderId() == traderId).findAny();
|
||||
}
|
||||
|
||||
public Optional<Dispute> findOwnDispute(String tradeId) {
|
||||
return disputes.stream().filter(e -> e.getTradeId().equals(tradeId)).findFirst();
|
||||
return disputes.stream().filter(e -> e.getTradeId().equals(tradeId)).findAny();
|
||||
}
|
||||
|
||||
public List<Dispute> findDisputesByTradeId(String tradeId) {
|
||||
|
|
|
@ -35,7 +35,7 @@ public final class DisputeResult implements Payload {
|
|||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
private static final Logger log = LoggerFactory.getLogger(DisputeResult.class);
|
||||
|
||||
public enum FeePaymentPolicy {
|
||||
public enum DisputeFeePolicy {
|
||||
LOSER,
|
||||
SPLIT,
|
||||
WAIVE
|
||||
|
@ -49,7 +49,7 @@ public final class DisputeResult implements Payload {
|
|||
|
||||
public final String tradeId;
|
||||
public final int traderId;
|
||||
private FeePaymentPolicy feePaymentPolicy;
|
||||
private DisputeFeePolicy disputeFeePolicy;
|
||||
|
||||
private boolean tamperProofEvidence;
|
||||
private boolean idVerification;
|
||||
|
@ -68,14 +68,14 @@ public final class DisputeResult implements Payload {
|
|||
transient private BooleanProperty tamperProofEvidenceProperty = new SimpleBooleanProperty();
|
||||
transient private BooleanProperty idVerificationProperty = new SimpleBooleanProperty();
|
||||
transient private BooleanProperty screenCastProperty = new SimpleBooleanProperty();
|
||||
transient private ObjectProperty<FeePaymentPolicy> feePaymentPolicyProperty = new SimpleObjectProperty<>();
|
||||
transient private ObjectProperty<DisputeFeePolicy> feePaymentPolicyProperty = new SimpleObjectProperty<>();
|
||||
transient private StringProperty summaryNotesProperty = new SimpleStringProperty();
|
||||
|
||||
public DisputeResult(String tradeId, int traderId) {
|
||||
this.tradeId = tradeId;
|
||||
this.traderId = traderId;
|
||||
|
||||
feePaymentPolicy = FeePaymentPolicy.LOSER;
|
||||
disputeFeePolicy = DisputeFeePolicy.LOSER;
|
||||
init();
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ public final class DisputeResult implements Payload {
|
|||
tamperProofEvidenceProperty = new SimpleBooleanProperty(tamperProofEvidence);
|
||||
idVerificationProperty = new SimpleBooleanProperty(idVerification);
|
||||
screenCastProperty = new SimpleBooleanProperty(screenCast);
|
||||
feePaymentPolicyProperty = new SimpleObjectProperty<>(feePaymentPolicy);
|
||||
feePaymentPolicyProperty = new SimpleObjectProperty<>(disputeFeePolicy);
|
||||
summaryNotesProperty = new SimpleStringProperty(summaryNotes);
|
||||
|
||||
tamperProofEvidenceProperty.addListener((observable, oldValue, newValue) -> {
|
||||
|
@ -105,7 +105,7 @@ public final class DisputeResult implements Payload {
|
|||
screenCast = newValue;
|
||||
});
|
||||
feePaymentPolicyProperty.addListener((observable, oldValue, newValue) -> {
|
||||
feePaymentPolicy = newValue;
|
||||
disputeFeePolicy = newValue;
|
||||
});
|
||||
summaryNotesProperty.addListener((observable, oldValue, newValue) -> {
|
||||
summaryNotes = newValue;
|
||||
|
@ -124,17 +124,17 @@ public final class DisputeResult implements Payload {
|
|||
return screenCastProperty;
|
||||
}
|
||||
|
||||
public void setFeePaymentPolicy(FeePaymentPolicy feePaymentPolicy) {
|
||||
this.feePaymentPolicy = feePaymentPolicy;
|
||||
feePaymentPolicyProperty.set(feePaymentPolicy);
|
||||
public void setDisputeFeePolicy(DisputeFeePolicy disputeFeePolicy) {
|
||||
this.disputeFeePolicy = disputeFeePolicy;
|
||||
feePaymentPolicyProperty.set(disputeFeePolicy);
|
||||
}
|
||||
|
||||
public ReadOnlyObjectProperty<FeePaymentPolicy> feePaymentPolicyProperty() {
|
||||
public ReadOnlyObjectProperty<DisputeFeePolicy> disputeFeePolicyProperty() {
|
||||
return feePaymentPolicyProperty;
|
||||
}
|
||||
|
||||
public FeePaymentPolicy getFeePaymentPolicy() {
|
||||
return feePaymentPolicy;
|
||||
public DisputeFeePolicy getDisputeFeePolicy() {
|
||||
return disputeFeePolicy;
|
||||
}
|
||||
|
||||
|
||||
|
@ -230,7 +230,7 @@ public final class DisputeResult implements Payload {
|
|||
if (arbitratorPayoutAmount != that.arbitratorPayoutAmount) return false;
|
||||
if (closeDate != that.closeDate) return false;
|
||||
if (tradeId != null ? !tradeId.equals(that.tradeId) : that.tradeId != null) return false;
|
||||
if (feePaymentPolicy != that.feePaymentPolicy) return false;
|
||||
if (disputeFeePolicy != that.disputeFeePolicy) return false;
|
||||
if (summaryNotes != null ? !summaryNotes.equals(that.summaryNotes) : that.summaryNotes != null) return false;
|
||||
if (disputeCommunicationMessage != null ? !disputeCommunicationMessage.equals(that.disputeCommunicationMessage) : that.disputeCommunicationMessage != null)
|
||||
return false;
|
||||
|
@ -246,7 +246,7 @@ public final class DisputeResult implements Payload {
|
|||
public int hashCode() {
|
||||
int result = tradeId != null ? tradeId.hashCode() : 0;
|
||||
result = 31 * result + traderId;
|
||||
result = 31 * result + (feePaymentPolicy != null ? feePaymentPolicy.hashCode() : 0);
|
||||
result = 31 * result + (disputeFeePolicy != null ? disputeFeePolicy.hashCode() : 0);
|
||||
result = 31 * result + (tamperProofEvidence ? 1 : 0);
|
||||
result = 31 * result + (idVerification ? 1 : 0);
|
||||
result = 31 * result + (screenCast ? 1 : 0);
|
||||
|
|
|
@ -42,7 +42,7 @@ public final class DisputeCommunicationMessage extends DisputeMessage {
|
|||
private final int traderId;
|
||||
private final boolean senderIsTrader;
|
||||
private final String message;
|
||||
private final List<Attachment> attachments = new ArrayList<>();
|
||||
private final ArrayList<Attachment> attachments = new ArrayList<>();
|
||||
private boolean arrived;
|
||||
private boolean storedInMailbox;
|
||||
private boolean isSystemMessage;
|
||||
|
|
|
@ -20,11 +20,19 @@ package io.bitsquare.arbitration.messages;
|
|||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.p2p.messaging.MailboxMessage;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class DisputeMessage implements MailboxMessage {
|
||||
private final int messageVersion = Version.getP2PMessageVersion();
|
||||
private final String uid = UUID.randomUUID().toString();
|
||||
|
||||
@Override
|
||||
public int getMessageVersion() {
|
||||
return messageVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUID() {
|
||||
return uid;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import io.bitsquare.p2p.NodeAddress;
|
|||
public final class PeerOpenedDisputeMessage extends DisputeMessage {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
|
||||
public final Dispute dispute;
|
||||
private final NodeAddress myNodeAddress;
|
||||
|
||||
|
|
|
@ -17,13 +17,12 @@
|
|||
|
||||
package io.bitsquare.btc;
|
||||
|
||||
import io.bitsquare.common.persistance.Persistable;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.params.MainNetParams;
|
||||
import org.bitcoinj.params.RegTestParams;
|
||||
import org.bitcoinj.params.TestNet3Params;
|
||||
|
||||
public enum BitcoinNetwork implements Persistable {
|
||||
public enum BitcoinNetwork {
|
||||
MAINNET(MainNetParams.get()),
|
||||
TESTNET(TestNet3Params.get()),
|
||||
REGTEST(RegTestParams.get());
|
||||
|
|
|
@ -25,7 +25,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
import io.bitsquare.app.Log;
|
||||
import io.bitsquare.btc.data.InputsAndChangeOutput;
|
||||
import io.bitsquare.btc.data.PreparedDepositTxAndOffererInputs;
|
||||
import io.bitsquare.btc.data.RawInput;
|
||||
import io.bitsquare.btc.data.RawTransactionInput;
|
||||
import io.bitsquare.btc.exceptions.SigningException;
|
||||
import io.bitsquare.btc.exceptions.TransactionVerificationException;
|
||||
import io.bitsquare.btc.exceptions.WalletException;
|
||||
|
@ -233,7 +233,7 @@ public class TradeWalletService {
|
|||
|
||||
printTxWithInputs("dummyTX", dummyTX);
|
||||
|
||||
List<RawInput> rawInputList = dummyTX.getInputs().stream()
|
||||
List<RawTransactionInput> rawTransactionInputList = dummyTX.getInputs().stream()
|
||||
.map(e -> {
|
||||
checkNotNull(e.getConnectedOutput(), "e.getConnectedOutput() must not be null");
|
||||
checkNotNull(e.getConnectedOutput().getParentTransaction(), "e.getConnectedOutput().getParentTransaction() must not be null");
|
||||
|
@ -255,7 +255,7 @@ public class TradeWalletService {
|
|||
changeOutputAddress = addressFromP2PKHScript.toString();
|
||||
}
|
||||
|
||||
return new InputsAndChangeOutput(rawInputList, changeOutputValue, changeOutputAddress);
|
||||
return new InputsAndChangeOutput(new ArrayList<>(rawTransactionInputList), changeOutputValue, changeOutputAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -265,7 +265,7 @@ public class TradeWalletService {
|
|||
* @param contractHash The hash of the contract to be added to the OP_RETURN output.
|
||||
* @param offererInputAmount The input amount of the offerer.
|
||||
* @param msOutputAmount The output amount to our MS output.
|
||||
* @param takerRawInputs Raw data for the connected outputs for all inputs of the taker (normally 1 input)
|
||||
* @param takerRawTransactionInputs Raw data for the connected outputs for all inputs of the taker (normally 1 input)
|
||||
* @param takerChangeOutputValue Optional taker change output value
|
||||
* @param takerChangeAddressString Optional taker change address
|
||||
* @param offererAddressInfo The offerers address entry.
|
||||
|
@ -281,7 +281,7 @@ public class TradeWalletService {
|
|||
byte[] contractHash,
|
||||
Coin offererInputAmount,
|
||||
Coin msOutputAmount,
|
||||
List<RawInput> takerRawInputs,
|
||||
List<RawTransactionInput> takerRawTransactionInputs,
|
||||
long takerChangeOutputValue,
|
||||
@Nullable String takerChangeAddressString,
|
||||
AddressEntry offererAddressInfo,
|
||||
|
@ -293,14 +293,14 @@ public class TradeWalletService {
|
|||
log.trace("offererIsBuyer " + offererIsBuyer);
|
||||
log.trace("offererInputAmount " + offererInputAmount.toFriendlyString());
|
||||
log.trace("msOutputAmount " + msOutputAmount.toFriendlyString());
|
||||
log.trace("takerRawInputs " + takerRawInputs.toString());
|
||||
log.trace("takerRawInputs " + takerRawTransactionInputs.toString());
|
||||
log.trace("takerChangeOutputValue " + takerChangeOutputValue);
|
||||
log.trace("takerChangeAddressString " + takerChangeAddressString);
|
||||
log.trace("buyerPubKey " + ECKey.fromPublicOnly(buyerPubKey).toString());
|
||||
log.trace("sellerPubKey " + ECKey.fromPublicOnly(sellerPubKey).toString());
|
||||
log.trace("arbitratorPubKey " + ECKey.fromPublicOnly(arbitratorPubKey).toString());
|
||||
|
||||
checkArgument(!takerRawInputs.isEmpty());
|
||||
checkArgument(!takerRawTransactionInputs.isEmpty());
|
||||
|
||||
// First we construct a dummy TX to get the inputs and outputs we want to use for the real deposit tx.
|
||||
// Similar to the way we did in the createTakerDepositTxInputs method.
|
||||
|
@ -323,30 +323,30 @@ public class TradeWalletService {
|
|||
// Now we construct the real deposit tx
|
||||
Transaction preparedDepositTx = new Transaction(params);
|
||||
|
||||
List<RawInput> offererRawInputs = new ArrayList<>();
|
||||
ArrayList<RawTransactionInput> offererRawTransactionInputs = new ArrayList<>();
|
||||
if (offererIsBuyer) {
|
||||
// Add buyer inputs
|
||||
for (TransactionInput input : offererInputs) {
|
||||
preparedDepositTx.addInput(input);
|
||||
offererRawInputs.add(getRawInputFromTransactionInput(input));
|
||||
offererRawTransactionInputs.add(getRawInputFromTransactionInput(input));
|
||||
}
|
||||
|
||||
// Add seller inputs
|
||||
// the sellers input is not signed so we attach empty script bytes
|
||||
for (RawInput rawInput : takerRawInputs)
|
||||
preparedDepositTx.addInput(getTransactionInput(preparedDepositTx, new byte[]{}, rawInput));
|
||||
for (RawTransactionInput rawTransactionInput : takerRawTransactionInputs)
|
||||
preparedDepositTx.addInput(getTransactionInput(preparedDepositTx, new byte[]{}, rawTransactionInput));
|
||||
} else {
|
||||
// taker is buyer role
|
||||
|
||||
// Add buyer inputs
|
||||
// the sellers input is not signed so we attach empty script bytes
|
||||
for (RawInput rawInput : takerRawInputs)
|
||||
preparedDepositTx.addInput(getTransactionInput(preparedDepositTx, new byte[]{}, rawInput));
|
||||
for (RawTransactionInput rawTransactionInput : takerRawTransactionInputs)
|
||||
preparedDepositTx.addInput(getTransactionInput(preparedDepositTx, new byte[]{}, rawTransactionInput));
|
||||
|
||||
// Add seller inputs
|
||||
for (TransactionInput input : offererInputs) {
|
||||
preparedDepositTx.addInput(input);
|
||||
offererRawInputs.add(getRawInputFromTransactionInput(input));
|
||||
offererRawTransactionInputs.add(getRawInputFromTransactionInput(input));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -401,7 +401,7 @@ public class TradeWalletService {
|
|||
|
||||
printTxWithInputs("preparedDepositTx", preparedDepositTx);
|
||||
|
||||
return new PreparedDepositTxAndOffererInputs(offererRawInputs, preparedDepositTx.bitcoinSerialize());
|
||||
return new PreparedDepositTxAndOffererInputs(offererRawTransactionInputs, preparedDepositTx.bitcoinSerialize());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -423,8 +423,8 @@ public class TradeWalletService {
|
|||
public void takerSignsAndPublishesDepositTx(boolean takerIsSeller,
|
||||
byte[] contractHash,
|
||||
byte[] offerersDepositTxSerialized,
|
||||
List<RawInput> buyerInputs,
|
||||
List<RawInput> sellerInputs,
|
||||
List<RawTransactionInput> buyerInputs,
|
||||
List<RawTransactionInput> sellerInputs,
|
||||
byte[] buyerPubKey,
|
||||
byte[] sellerPubKey,
|
||||
byte[] arbitratorPubKey,
|
||||
|
@ -460,13 +460,13 @@ public class TradeWalletService {
|
|||
depositTx.addInput(getTransactionInput(depositTx, getScriptProgram(offerersDepositTx, i), buyerInputs.get(i)));
|
||||
|
||||
// Add seller inputs
|
||||
for (RawInput rawInput : sellerInputs)
|
||||
depositTx.addInput(getTransactionInput(depositTx, new byte[]{}, rawInput));
|
||||
for (RawTransactionInput rawTransactionInput : sellerInputs)
|
||||
depositTx.addInput(getTransactionInput(depositTx, new byte[]{}, rawTransactionInput));
|
||||
} else {
|
||||
// taker is buyer
|
||||
// Add buyer inputs and apply signature
|
||||
for (RawInput rawInput : buyerInputs)
|
||||
depositTx.addInput(getTransactionInput(depositTx, new byte[]{}, rawInput));
|
||||
for (RawTransactionInput rawTransactionInput : buyerInputs)
|
||||
depositTx.addInput(getTransactionInput(depositTx, new byte[]{}, rawTransactionInput));
|
||||
|
||||
// Add seller inputs
|
||||
// We grab the signature from the offerersDepositTx and apply it to the new tx input
|
||||
|
@ -898,12 +898,12 @@ public class TradeWalletService {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@NotNull
|
||||
private RawInput getRawInputFromTransactionInput(@NotNull TransactionInput input) {
|
||||
private RawTransactionInput getRawInputFromTransactionInput(@NotNull TransactionInput input) {
|
||||
checkNotNull(input.getConnectedOutput(), "input.getConnectedOutput() must not be null");
|
||||
checkNotNull(input.getConnectedOutput().getParentTransaction(), "input.getConnectedOutput().getParentTransaction() must not be null");
|
||||
checkNotNull(input.getValue(), "input.getValue() must not be null");
|
||||
|
||||
return new RawInput(input.getOutpoint().getIndex(), input.getConnectedOutput().getParentTransaction().bitcoinSerialize(), input.getValue().value);
|
||||
return new RawTransactionInput(input.getOutpoint().getIndex(), input.getConnectedOutput().getParentTransaction().bitcoinSerialize(), input.getValue().value);
|
||||
}
|
||||
|
||||
private byte[] getScriptProgram(Transaction offerersDepositTx, int i) throws TransactionVerificationException {
|
||||
|
@ -915,12 +915,12 @@ public class TradeWalletService {
|
|||
}
|
||||
|
||||
@NotNull
|
||||
private TransactionInput getTransactionInput(Transaction depositTx, byte[] scriptProgram, RawInput rawInput) {
|
||||
private TransactionInput getTransactionInput(Transaction depositTx, byte[] scriptProgram, RawTransactionInput rawTransactionInput) {
|
||||
return new TransactionInput(params,
|
||||
depositTx,
|
||||
scriptProgram,
|
||||
new TransactionOutPoint(params, rawInput.index, new Transaction(params, rawInput.parentTransaction)),
|
||||
Coin.valueOf(rawInput.value));
|
||||
new TransactionOutPoint(params, rawTransactionInput.index, new Transaction(params, rawTransactionInput.parentTransaction)),
|
||||
Coin.valueOf(rawTransactionInput.value));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,22 +18,22 @@
|
|||
package io.bitsquare.btc.data;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public class InputsAndChangeOutput {
|
||||
public final List<RawInput> rawInputs;
|
||||
public final ArrayList<RawTransactionInput> rawTransactionInputs;
|
||||
|
||||
// Is set to 0L in case we don't have an output
|
||||
public final long changeOutputValue;
|
||||
@Nullable
|
||||
public final String changeOutputAddress;
|
||||
|
||||
public InputsAndChangeOutput(List<RawInput> rawInputs, long changeOutputValue, @Nullable String changeOutputAddress) {
|
||||
checkArgument(!rawInputs.isEmpty(), "rawInputs.isEmpty()");
|
||||
public InputsAndChangeOutput(ArrayList<RawTransactionInput> rawTransactionInputs, long changeOutputValue, @Nullable String changeOutputAddress) {
|
||||
checkArgument(!rawTransactionInputs.isEmpty(), "rawInputs.isEmpty()");
|
||||
|
||||
this.rawInputs = rawInputs;
|
||||
this.rawTransactionInputs = rawTransactionInputs;
|
||||
this.changeOutputValue = changeOutputValue;
|
||||
this.changeOutputAddress = changeOutputAddress;
|
||||
}
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
|
||||
package io.bitsquare.btc.data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PreparedDepositTxAndOffererInputs {
|
||||
public final List<RawInput> rawOffererInputs;
|
||||
public final ArrayList<RawTransactionInput> rawOffererInputs;
|
||||
public final byte[] depositTransaction;
|
||||
|
||||
public PreparedDepositTxAndOffererInputs(List<RawInput> rawOffererInputs, byte[] depositTransaction) {
|
||||
public PreparedDepositTxAndOffererInputs(ArrayList<RawTransactionInput> rawOffererInputs, byte[] depositTransaction) {
|
||||
this.rawOffererInputs = rawOffererInputs;
|
||||
this.depositTransaction = depositTransaction;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import io.bitsquare.common.wire.Payload;
|
|||
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class RawInput implements Payload {
|
||||
public final class RawTransactionInput implements Payload {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
|
||||
|
@ -30,7 +30,7 @@ public final class RawInput implements Payload {
|
|||
public final byte[] parentTransaction;
|
||||
public final long value;
|
||||
|
||||
public RawInput(long index, byte[] parentTransaction, long value) {
|
||||
public RawTransactionInput(long index, byte[] parentTransaction, long value) {
|
||||
this.index = index;
|
||||
this.parentTransaction = parentTransaction;
|
||||
this.value = value;
|
||||
|
@ -39,13 +39,13 @@ public final class RawInput implements Payload {
|
|||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof RawInput)) return false;
|
||||
if (!(o instanceof RawTransactionInput)) return false;
|
||||
|
||||
RawInput rawInput = (RawInput) o;
|
||||
RawTransactionInput rawTransactionInput = (RawTransactionInput) o;
|
||||
|
||||
if (index != rawInput.index) return false;
|
||||
if (value != rawInput.value) return false;
|
||||
return Arrays.equals(parentTransaction, rawInput.parentTransaction);
|
||||
if (index != rawTransactionInput.index) return false;
|
||||
if (value != rawTransactionInput.value) return false;
|
||||
return Arrays.equals(parentTransaction, rawTransactionInput.parentTransaction);
|
||||
|
||||
}
|
||||
|
|
@ -29,9 +29,9 @@ import io.bitsquare.btc.TradeWalletService;
|
|||
import io.bitsquare.btc.WalletService;
|
||||
import io.bitsquare.common.crypto.KeyRing;
|
||||
import io.bitsquare.common.taskrunner.Model;
|
||||
import io.bitsquare.crypto.DecryptedMsgWithPubKey;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.P2PService;
|
||||
import io.bitsquare.p2p.messaging.DecryptedMsgWithPubKey;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.trade.offer.Offer;
|
||||
import io.bitsquare.trade.offer.OpenOfferManager;
|
||||
|
@ -82,6 +82,7 @@ public abstract class Trade implements Tradable, Model {
|
|||
FIAT_PAYMENT_RECEIPT_MSG_SENT(Phase.FIAT_RECEIVED),
|
||||
FIAT_PAYMENT_RECEIPT_MSG_RECEIVED(Phase.FIAT_RECEIVED),
|
||||
|
||||
PAYOUT_TX_COMMITTED(Phase.PAYOUT_PAID),
|
||||
PAYOUT_TX_SENT(Phase.PAYOUT_PAID),
|
||||
PAYOUT_TX_RECEIVED_AND_COMMITTED(Phase.PAYOUT_PAID),
|
||||
PAYOUT_BROAD_CASTED(Phase.PAYOUT_PAID),
|
||||
|
|
|
@ -26,13 +26,13 @@ import io.bitsquare.btc.WalletService;
|
|||
import io.bitsquare.common.crypto.KeyRing;
|
||||
import io.bitsquare.common.handlers.FaultHandler;
|
||||
import io.bitsquare.common.handlers.ResultHandler;
|
||||
import io.bitsquare.crypto.DecryptedMsgWithPubKey;
|
||||
import io.bitsquare.p2p.BootstrapListener;
|
||||
import io.bitsquare.p2p.Message;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.P2PService;
|
||||
import io.bitsquare.p2p.messaging.DecryptedDirectMessageListener;
|
||||
import io.bitsquare.p2p.messaging.DecryptedMailboxListener;
|
||||
import io.bitsquare.p2p.messaging.DecryptedMsgWithPubKey;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.trade.closed.ClosedTradableManager;
|
||||
import io.bitsquare.trade.failed.FailedTradesManager;
|
||||
|
|
|
@ -25,8 +25,8 @@ import io.bitsquare.common.handlers.ResultHandler;
|
|||
import io.bitsquare.common.util.JsonExclude;
|
||||
import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.storage.data.RequiresOwnerIsOnlinePayload;
|
||||
import io.bitsquare.p2p.storage.data.StoragePayload;
|
||||
import io.bitsquare.p2p.storage.payload.RequiresOwnerIsOnlinePayload;
|
||||
import io.bitsquare.p2p.storage.payload.StoragePayload;
|
||||
import io.bitsquare.payment.PaymentMethod;
|
||||
import io.bitsquare.trade.protocol.availability.OfferAvailabilityModel;
|
||||
import io.bitsquare.trade.protocol.availability.OfferAvailabilityProtocol;
|
||||
|
@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory;
|
|||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.security.PublicKey;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -48,20 +49,25 @@ import static com.google.common.base.Preconditions.checkArgument;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Static
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@JsonExclude
|
||||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
@JsonExclude
|
||||
private static final Logger log = LoggerFactory.getLogger(Offer.class);
|
||||
|
||||
// public static final long TTL = TimeUnit.SECONDS.toMillis(60);
|
||||
public static final long TTL = TimeUnit.SECONDS.toMillis(10); //TODO
|
||||
|
||||
public static final long TTL = TimeUnit.SECONDS.toMillis(60);
|
||||
public final static String TAC_OFFERER = "When placing that offer I accept that anyone who fulfills my conditions can " +
|
||||
"take that offer.";
|
||||
public static final String TAC_TAKER = "With taking the offer I commit to the trade conditions as defined.";
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Enums
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public enum Direction {BUY, SELL}
|
||||
|
||||
public enum State {
|
||||
|
@ -74,6 +80,10 @@ public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload
|
|||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Instance fields
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private final String id;
|
||||
private final Direction direction;
|
||||
private final String currencyCode;
|
||||
|
@ -91,8 +101,8 @@ public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload
|
|||
private final String offererPaymentAccountId;
|
||||
|
||||
@Nullable
|
||||
private final List<String> acceptedCountryCodes;
|
||||
private final List<NodeAddress> arbitratorNodeAddresses;
|
||||
private final ArrayList<String> acceptedCountryCodes;
|
||||
private final ArrayList<NodeAddress> arbitratorNodeAddresses;
|
||||
|
||||
// Mutable property. Has to be set before offer is save in P2P network as it changes the objects hash!
|
||||
private String offerFeePaymentTxID;
|
||||
|
@ -104,6 +114,7 @@ public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload
|
|||
@JsonExclude
|
||||
transient private ObjectProperty<State> stateProperty = new SimpleObjectProperty<>(state);
|
||||
@JsonExclude
|
||||
@Nullable
|
||||
transient private OfferAvailabilityProtocol availabilityProtocol;
|
||||
@JsonExclude
|
||||
transient private StringProperty errorMessageProperty = new SimpleStringProperty();
|
||||
|
@ -124,8 +135,8 @@ public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload
|
|||
String currencyCode,
|
||||
@Nullable Country paymentMethodCountry,
|
||||
String offererPaymentAccountId,
|
||||
List<NodeAddress> arbitratorNodeAddresses,
|
||||
@Nullable List<String> acceptedCountryCodes) {
|
||||
ArrayList<NodeAddress> arbitratorNodeAddresses,
|
||||
@Nullable ArrayList<String> acceptedCountryCodes) {
|
||||
this.id = id;
|
||||
this.offererNodeAddress = offererNodeAddress;
|
||||
this.pubKeyRing = pubKeyRing;
|
||||
|
|
|
@ -21,7 +21,7 @@ import io.bitsquare.common.handlers.ErrorMessageHandler;
|
|||
import io.bitsquare.common.handlers.ResultHandler;
|
||||
import io.bitsquare.p2p.P2PService;
|
||||
import io.bitsquare.p2p.storage.HashMapChangedListener;
|
||||
import io.bitsquare.p2p.storage.data.ProtectedData;
|
||||
import io.bitsquare.p2p.storage.storageentry.ProtectedStorageEntry;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -58,18 +58,18 @@ public class OfferBookService {
|
|||
|
||||
p2PService.addHashSetChangedListener(new HashMapChangedListener() {
|
||||
@Override
|
||||
public void onAdded(ProtectedData data) {
|
||||
public void onAdded(ProtectedStorageEntry data) {
|
||||
offerBookChangedListeners.stream().forEach(listener -> {
|
||||
if (data.expirablePayload instanceof Offer)
|
||||
listener.onAdded((Offer) data.expirablePayload);
|
||||
if (data.getStoragePayload() instanceof Offer)
|
||||
listener.onAdded((Offer) data.getStoragePayload());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoved(ProtectedData data) {
|
||||
public void onRemoved(ProtectedStorageEntry data) {
|
||||
offerBookChangedListeners.stream().forEach(listener -> {
|
||||
if (data.expirablePayload instanceof Offer)
|
||||
listener.onRemoved((Offer) data.expirablePayload);
|
||||
if (data.getStoragePayload() instanceof Offer)
|
||||
listener.onRemoved((Offer) data.getStoragePayload());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -126,8 +126,8 @@ public class OfferBookService {
|
|||
|
||||
public List<Offer> getOffers() {
|
||||
return p2PService.getDataMap().values().stream()
|
||||
.filter(data -> data.expirablePayload instanceof Offer)
|
||||
.map(data -> (Offer) data.expirablePayload)
|
||||
.filter(data -> data.getStoragePayload() instanceof Offer)
|
||||
.map(data -> (Offer) data.getStoragePayload())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
|
|
@ -26,12 +26,12 @@ import io.bitsquare.common.UserThread;
|
|||
import io.bitsquare.common.crypto.KeyRing;
|
||||
import io.bitsquare.common.handlers.ErrorMessageHandler;
|
||||
import io.bitsquare.common.handlers.ResultHandler;
|
||||
import io.bitsquare.crypto.DecryptedMsgWithPubKey;
|
||||
import io.bitsquare.p2p.BootstrapListener;
|
||||
import io.bitsquare.p2p.Message;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.P2PService;
|
||||
import io.bitsquare.p2p.messaging.DecryptedDirectMessageListener;
|
||||
import io.bitsquare.p2p.messaging.DecryptedMsgWithPubKey;
|
||||
import io.bitsquare.p2p.messaging.SendDirectMessageListener;
|
||||
import io.bitsquare.p2p.peers.PeerManager;
|
||||
import io.bitsquare.storage.Storage;
|
||||
|
|
|
@ -22,7 +22,7 @@ import io.bitsquare.arbitration.ArbitratorManager;
|
|||
import io.bitsquare.btc.AddressEntry;
|
||||
import io.bitsquare.btc.TradeWalletService;
|
||||
import io.bitsquare.btc.WalletService;
|
||||
import io.bitsquare.btc.data.RawInput;
|
||||
import io.bitsquare.btc.data.RawTransactionInput;
|
||||
import io.bitsquare.common.crypto.KeyRing;
|
||||
import io.bitsquare.common.crypto.PubKeyRing;
|
||||
import io.bitsquare.common.taskrunner.Model;
|
||||
|
@ -44,6 +44,7 @@ import javax.annotation.Nullable;
|
|||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ProcessModel implements Model, Serializable {
|
||||
|
@ -74,7 +75,7 @@ public class ProcessModel implements Model, Serializable {
|
|||
// After successful verified we copy that over to the trade.tradingPeerAddress
|
||||
private NodeAddress tempTradingPeerNodeAddress;
|
||||
private byte[] preparedDepositTx;
|
||||
private List<RawInput> rawInputs;
|
||||
private ArrayList<RawTransactionInput> rawTransactionInputs;
|
||||
private long changeOutputValue;
|
||||
@Nullable
|
||||
private String changeOutputAddress;
|
||||
|
@ -243,12 +244,12 @@ public class ProcessModel implements Model, Serializable {
|
|||
return preparedDepositTx;
|
||||
}
|
||||
|
||||
public void setRawInputs(List<RawInput> rawInputs) {
|
||||
this.rawInputs = rawInputs;
|
||||
public void setRawTransactionInputs(ArrayList<RawTransactionInput> rawTransactionInputs) {
|
||||
this.rawTransactionInputs = rawTransactionInputs;
|
||||
}
|
||||
|
||||
public List<RawInput> getRawInputs() {
|
||||
return rawInputs;
|
||||
public ArrayList<RawTransactionInput> getRawTransactionInputs() {
|
||||
return rawTransactionInputs;
|
||||
}
|
||||
|
||||
public void setChangeOutputValue(long changeOutputValue) {
|
||||
|
|
|
@ -20,10 +20,10 @@ package io.bitsquare.trade.protocol.trade;
|
|||
import io.bitsquare.common.Timer;
|
||||
import io.bitsquare.common.UserThread;
|
||||
import io.bitsquare.common.crypto.PubKeyRing;
|
||||
import io.bitsquare.crypto.DecryptedMsgWithPubKey;
|
||||
import io.bitsquare.p2p.Message;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.messaging.DecryptedDirectMessageListener;
|
||||
import io.bitsquare.p2p.messaging.DecryptedMsgWithPubKey;
|
||||
import io.bitsquare.trade.OffererTrade;
|
||||
import io.bitsquare.trade.TakerTrade;
|
||||
import io.bitsquare.trade.Trade;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bitsquare.trade.protocol.trade;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.btc.data.RawInput;
|
||||
import io.bitsquare.btc.data.RawTransactionInput;
|
||||
import io.bitsquare.common.crypto.PubKeyRing;
|
||||
import io.bitsquare.common.persistance.Persistable;
|
||||
import io.bitsquare.payment.PaymentAccountContractData;
|
||||
|
@ -47,7 +47,7 @@ public final class TradingPeer implements Persistable {
|
|||
private byte[] signature;
|
||||
private PubKeyRing pubKeyRing;
|
||||
private byte[] tradeWalletPubKey;
|
||||
private List<RawInput> rawInputs;
|
||||
private List<RawTransactionInput> rawTransactionInputs;
|
||||
private long changeOutputValue;
|
||||
@Nullable
|
||||
private String changeOutputAddress;
|
||||
|
@ -138,12 +138,12 @@ public final class TradingPeer implements Persistable {
|
|||
this.pubKeyRing = pubKeyRing;
|
||||
}
|
||||
|
||||
public void setRawInputs(List<RawInput> rawInputs) {
|
||||
this.rawInputs = rawInputs;
|
||||
public void setRawTransactionInputs(List<RawTransactionInput> rawTransactionInputs) {
|
||||
this.rawTransactionInputs = rawTransactionInputs;
|
||||
}
|
||||
|
||||
public List<RawInput> getRawInputs() {
|
||||
return rawInputs;
|
||||
public List<RawTransactionInput> getRawTransactionInputs() {
|
||||
return rawTransactionInputs;
|
||||
}
|
||||
|
||||
public void setChangeOutputValue(long changeOutputValue) {
|
||||
|
|
|
@ -23,6 +23,7 @@ import io.bitsquare.p2p.messaging.MailboxMessage;
|
|||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
@Immutable
|
||||
public final class DepositTxPublishedMessage extends TradeMessage implements MailboxMessage {
|
||||
|
@ -31,6 +32,7 @@ public final class DepositTxPublishedMessage extends TradeMessage implements Mai
|
|||
|
||||
public final byte[] depositTx;
|
||||
private final NodeAddress senderNodeAddress;
|
||||
private final String uid = UUID.randomUUID().toString();
|
||||
|
||||
public DepositTxPublishedMessage(String tradeId, byte[] depositTx, NodeAddress senderNodeAddress) {
|
||||
super(tradeId);
|
||||
|
@ -43,6 +45,11 @@ public final class DepositTxPublishedMessage extends TradeMessage implements Mai
|
|||
return senderNodeAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUID() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -52,7 +59,9 @@ public final class DepositTxPublishedMessage extends TradeMessage implements Mai
|
|||
DepositTxPublishedMessage that = (DepositTxPublishedMessage) o;
|
||||
|
||||
if (!Arrays.equals(depositTx, that.depositTx)) return false;
|
||||
return !(senderNodeAddress != null ? !senderNodeAddress.equals(that.senderNodeAddress) : that.senderNodeAddress != null);
|
||||
if (senderNodeAddress != null ? !senderNodeAddress.equals(that.senderNodeAddress) : that.senderNodeAddress != null)
|
||||
return false;
|
||||
return !(uid != null ? !uid.equals(that.uid) : that.uid != null);
|
||||
|
||||
}
|
||||
|
||||
|
@ -61,6 +70,7 @@ public final class DepositTxPublishedMessage extends TradeMessage implements Mai
|
|||
int result = super.hashCode();
|
||||
result = 31 * result + (depositTx != null ? Arrays.hashCode(depositTx) : 0);
|
||||
result = 31 * result + (senderNodeAddress != null ? senderNodeAddress.hashCode() : 0);
|
||||
result = 31 * result + (uid != null ? uid.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import io.bitsquare.p2p.NodeAddress;
|
|||
import io.bitsquare.p2p.messaging.MailboxMessage;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import java.util.UUID;
|
||||
|
||||
@Immutable
|
||||
public final class FiatTransferStartedMessage extends TradeMessage implements MailboxMessage {
|
||||
|
@ -30,6 +31,7 @@ public final class FiatTransferStartedMessage extends TradeMessage implements Ma
|
|||
|
||||
public final String buyerPayoutAddress;
|
||||
private final NodeAddress senderNodeAddress;
|
||||
private final String uid = UUID.randomUUID().toString();
|
||||
|
||||
public FiatTransferStartedMessage(String tradeId, String buyerPayoutAddress, NodeAddress senderNodeAddress) {
|
||||
super(tradeId);
|
||||
|
@ -42,6 +44,11 @@ public final class FiatTransferStartedMessage extends TradeMessage implements Ma
|
|||
return senderNodeAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUID() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -52,7 +59,9 @@ public final class FiatTransferStartedMessage extends TradeMessage implements Ma
|
|||
|
||||
if (buyerPayoutAddress != null ? !buyerPayoutAddress.equals(that.buyerPayoutAddress) : that.buyerPayoutAddress != null)
|
||||
return false;
|
||||
return !(senderNodeAddress != null ? !senderNodeAddress.equals(that.senderNodeAddress) : that.senderNodeAddress != null);
|
||||
if (senderNodeAddress != null ? !senderNodeAddress.equals(that.senderNodeAddress) : that.senderNodeAddress != null)
|
||||
return false;
|
||||
return !(uid != null ? !uid.equals(that.uid) : that.uid != null);
|
||||
|
||||
}
|
||||
|
||||
|
@ -61,6 +70,7 @@ public final class FiatTransferStartedMessage extends TradeMessage implements Ma
|
|||
int result = super.hashCode();
|
||||
result = 31 * result + (buyerPayoutAddress != null ? buyerPayoutAddress.hashCode() : 0);
|
||||
result = 31 * result + (senderNodeAddress != null ? senderNodeAddress.hashCode() : 0);
|
||||
result = 31 * result + (uid != null ? uid.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import io.bitsquare.p2p.messaging.MailboxMessage;
|
|||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
@Immutable
|
||||
public final class FinalizePayoutTxRequest extends TradeMessage implements MailboxMessage {
|
||||
|
@ -33,6 +34,7 @@ public final class FinalizePayoutTxRequest extends TradeMessage implements Mailb
|
|||
public final String sellerPayoutAddress;
|
||||
public final long lockTimeAsBlockHeight;
|
||||
private final NodeAddress senderNodeAddress;
|
||||
private final String uid = UUID.randomUUID().toString();
|
||||
|
||||
public FinalizePayoutTxRequest(String tradeId,
|
||||
byte[] sellerSignature,
|
||||
|
@ -51,6 +53,11 @@ public final class FinalizePayoutTxRequest extends TradeMessage implements Mailb
|
|||
return senderNodeAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUID() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -63,7 +70,9 @@ public final class FinalizePayoutTxRequest extends TradeMessage implements Mailb
|
|||
if (!Arrays.equals(sellerSignature, that.sellerSignature)) return false;
|
||||
if (sellerPayoutAddress != null ? !sellerPayoutAddress.equals(that.sellerPayoutAddress) : that.sellerPayoutAddress != null)
|
||||
return false;
|
||||
return !(senderNodeAddress != null ? !senderNodeAddress.equals(that.senderNodeAddress) : that.senderNodeAddress != null);
|
||||
if (senderNodeAddress != null ? !senderNodeAddress.equals(that.senderNodeAddress) : that.senderNodeAddress != null)
|
||||
return false;
|
||||
return !(uid != null ? !uid.equals(that.uid) : that.uid != null);
|
||||
|
||||
}
|
||||
|
||||
|
@ -74,6 +83,7 @@ public final class FinalizePayoutTxRequest extends TradeMessage implements Mailb
|
|||
result = 31 * result + (sellerPayoutAddress != null ? sellerPayoutAddress.hashCode() : 0);
|
||||
result = 31 * result + (int) (lockTimeAsBlockHeight ^ (lockTimeAsBlockHeight >>> 32));
|
||||
result = 31 * result + (senderNodeAddress != null ? senderNodeAddress.hashCode() : 0);
|
||||
result = 31 * result + (uid != null ? uid.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,15 +18,16 @@
|
|||
package io.bitsquare.trade.protocol.trade.messages;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.btc.data.RawInput;
|
||||
import io.bitsquare.btc.data.RawTransactionInput;
|
||||
import io.bitsquare.common.crypto.PubKeyRing;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.messaging.MailboxMessage;
|
||||
import io.bitsquare.payment.PaymentAccountContractData;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Immutable
|
||||
public final class PayDepositRequest extends TradeMessage implements MailboxMessage {
|
||||
|
@ -35,7 +36,7 @@ public final class PayDepositRequest extends TradeMessage implements MailboxMess
|
|||
|
||||
public final long tradeAmount;
|
||||
public final byte[] takerTradeWalletPubKey;
|
||||
public final List<RawInput> rawInputs;
|
||||
public final ArrayList<RawTransactionInput> rawTransactionInputs;
|
||||
public final long changeOutputValue;
|
||||
public final String changeOutputAddress;
|
||||
public final String takerPayoutAddressString;
|
||||
|
@ -43,14 +44,15 @@ public final class PayDepositRequest extends TradeMessage implements MailboxMess
|
|||
public final PaymentAccountContractData takerPaymentAccountContractData;
|
||||
public final String takerAccountId;
|
||||
public final String takeOfferFeeTxId;
|
||||
public final List<NodeAddress> acceptedArbitratorNodeAddresses;
|
||||
public final ArrayList<NodeAddress> acceptedArbitratorNodeAddresses;
|
||||
public final NodeAddress arbitratorNodeAddress;
|
||||
private final NodeAddress senderNodeAddress;
|
||||
private final String uid = UUID.randomUUID().toString();
|
||||
|
||||
public PayDepositRequest(NodeAddress senderNodeAddress,
|
||||
String tradeId,
|
||||
long tradeAmount,
|
||||
List<RawInput> rawInputs,
|
||||
ArrayList<RawTransactionInput> rawTransactionInputs,
|
||||
long changeOutputValue,
|
||||
String changeOutputAddress,
|
||||
byte[] takerTradeWalletPubKey,
|
||||
|
@ -59,12 +61,12 @@ public final class PayDepositRequest extends TradeMessage implements MailboxMess
|
|||
PaymentAccountContractData takerPaymentAccountContractData,
|
||||
String takerAccountId,
|
||||
String takeOfferFeeTxId,
|
||||
List<NodeAddress> acceptedArbitratorNodeAddresses,
|
||||
ArrayList<NodeAddress> acceptedArbitratorNodeAddresses,
|
||||
NodeAddress arbitratorNodeAddress) {
|
||||
super(tradeId);
|
||||
this.senderNodeAddress = senderNodeAddress;
|
||||
this.tradeAmount = tradeAmount;
|
||||
this.rawInputs = rawInputs;
|
||||
this.rawTransactionInputs = rawTransactionInputs;
|
||||
this.changeOutputValue = changeOutputValue;
|
||||
this.changeOutputAddress = changeOutputAddress;
|
||||
this.takerPayoutAddressString = takerPayoutAddressString;
|
||||
|
@ -82,6 +84,11 @@ public final class PayDepositRequest extends TradeMessage implements MailboxMess
|
|||
return senderNodeAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUID() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -93,7 +100,8 @@ public final class PayDepositRequest extends TradeMessage implements MailboxMess
|
|||
if (tradeAmount != that.tradeAmount) return false;
|
||||
if (changeOutputValue != that.changeOutputValue) return false;
|
||||
if (!Arrays.equals(takerTradeWalletPubKey, that.takerTradeWalletPubKey)) return false;
|
||||
if (rawInputs != null ? !rawInputs.equals(that.rawInputs) : that.rawInputs != null) return false;
|
||||
if (rawTransactionInputs != null ? !rawTransactionInputs.equals(that.rawTransactionInputs) : that.rawTransactionInputs != null)
|
||||
return false;
|
||||
if (changeOutputAddress != null ? !changeOutputAddress.equals(that.changeOutputAddress) : that.changeOutputAddress != null)
|
||||
return false;
|
||||
if (takerPayoutAddressString != null ? !takerPayoutAddressString.equals(that.takerPayoutAddressString) : that.takerPayoutAddressString != null)
|
||||
|
@ -110,7 +118,9 @@ public final class PayDepositRequest extends TradeMessage implements MailboxMess
|
|||
return false;
|
||||
if (arbitratorNodeAddress != null ? !arbitratorNodeAddress.equals(that.arbitratorNodeAddress) : that.arbitratorNodeAddress != null)
|
||||
return false;
|
||||
return !(senderNodeAddress != null ? !senderNodeAddress.equals(that.senderNodeAddress) : that.senderNodeAddress != null);
|
||||
if (senderNodeAddress != null ? !senderNodeAddress.equals(that.senderNodeAddress) : that.senderNodeAddress != null)
|
||||
return false;
|
||||
return !(uid != null ? !uid.equals(that.uid) : that.uid != null);
|
||||
|
||||
}
|
||||
|
||||
|
@ -119,7 +129,7 @@ public final class PayDepositRequest extends TradeMessage implements MailboxMess
|
|||
int result = super.hashCode();
|
||||
result = 31 * result + (int) (tradeAmount ^ (tradeAmount >>> 32));
|
||||
result = 31 * result + (takerTradeWalletPubKey != null ? Arrays.hashCode(takerTradeWalletPubKey) : 0);
|
||||
result = 31 * result + (rawInputs != null ? rawInputs.hashCode() : 0);
|
||||
result = 31 * result + (rawTransactionInputs != null ? rawTransactionInputs.hashCode() : 0);
|
||||
result = 31 * result + (int) (changeOutputValue ^ (changeOutputValue >>> 32));
|
||||
result = 31 * result + (changeOutputAddress != null ? changeOutputAddress.hashCode() : 0);
|
||||
result = 31 * result + (takerPayoutAddressString != null ? takerPayoutAddressString.hashCode() : 0);
|
||||
|
@ -130,6 +140,7 @@ public final class PayDepositRequest extends TradeMessage implements MailboxMess
|
|||
result = 31 * result + (acceptedArbitratorNodeAddresses != null ? acceptedArbitratorNodeAddresses.hashCode() : 0);
|
||||
result = 31 * result + (arbitratorNodeAddress != null ? arbitratorNodeAddress.hashCode() : 0);
|
||||
result = 31 * result + (senderNodeAddress != null ? senderNodeAddress.hashCode() : 0);
|
||||
result = 31 * result + (uid != null ? uid.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import io.bitsquare.p2p.messaging.MailboxMessage;
|
|||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
@Immutable
|
||||
public final class PayoutTxFinalizedMessage extends TradeMessage implements MailboxMessage {
|
||||
|
@ -31,6 +32,7 @@ public final class PayoutTxFinalizedMessage extends TradeMessage implements Mail
|
|||
|
||||
public final byte[] payoutTx;
|
||||
private final NodeAddress senderNodeAddress;
|
||||
private final String uid = UUID.randomUUID().toString();
|
||||
|
||||
public PayoutTxFinalizedMessage(String tradeId, byte[] payoutTx, NodeAddress senderNodeAddress) {
|
||||
super(tradeId);
|
||||
|
@ -43,6 +45,11 @@ public final class PayoutTxFinalizedMessage extends TradeMessage implements Mail
|
|||
return senderNodeAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUID() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -52,7 +59,9 @@ public final class PayoutTxFinalizedMessage extends TradeMessage implements Mail
|
|||
PayoutTxFinalizedMessage that = (PayoutTxFinalizedMessage) o;
|
||||
|
||||
if (!Arrays.equals(payoutTx, that.payoutTx)) return false;
|
||||
return !(senderNodeAddress != null ? !senderNodeAddress.equals(that.senderNodeAddress) : that.senderNodeAddress != null);
|
||||
if (senderNodeAddress != null ? !senderNodeAddress.equals(that.senderNodeAddress) : that.senderNodeAddress != null)
|
||||
return false;
|
||||
return !(uid != null ? !uid.equals(that.uid) : that.uid != null);
|
||||
|
||||
}
|
||||
|
||||
|
@ -61,6 +70,7 @@ public final class PayoutTxFinalizedMessage extends TradeMessage implements Mail
|
|||
int result = super.hashCode();
|
||||
result = 31 * result + (payoutTx != null ? Arrays.hashCode(payoutTx) : 0);
|
||||
result = 31 * result + (senderNodeAddress != null ? senderNodeAddress.hashCode() : 0);
|
||||
result = 31 * result + (uid != null ? uid.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bitsquare.trade.protocol.trade.messages;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.btc.data.RawInput;
|
||||
import io.bitsquare.btc.data.RawTransactionInput;
|
||||
import io.bitsquare.common.util.Utilities;
|
||||
import io.bitsquare.payment.PaymentAccountContractData;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -26,7 +26,6 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Immutable
|
||||
|
||||
|
@ -43,7 +42,7 @@ public final class PublishDepositTxRequest extends TradeMessage {
|
|||
public final String offererContractSignature;
|
||||
public final String offererPayoutAddressString;
|
||||
public final byte[] preparedDepositTx;
|
||||
public final List<RawInput> offererInputs;
|
||||
public final ArrayList<RawTransactionInput> offererInputs;
|
||||
public final int openDisputeTimeAsBlockHeight;
|
||||
public final int checkPaymentTimeAsBlockHeight;
|
||||
public final byte[] offererTradeWalletPubKey;
|
||||
|
@ -56,7 +55,7 @@ public final class PublishDepositTxRequest extends TradeMessage {
|
|||
String offererContractSignature,
|
||||
String offererPayoutAddressString,
|
||||
byte[] preparedDepositTx,
|
||||
List<RawInput> offererInputs,
|
||||
ArrayList<RawTransactionInput> offererInputs,
|
||||
int openDisputeTimeAsBlockHeight,
|
||||
int checkPaymentTimeAsBlockHeight) {
|
||||
super(tradeId);
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bitsquare.trade.protocol.trade.tasks;
|
|||
|
||||
import io.bitsquare.common.taskrunner.Task;
|
||||
import io.bitsquare.common.taskrunner.TaskRunner;
|
||||
import io.bitsquare.p2p.messaging.DecryptedMsgWithPubKey;
|
||||
import io.bitsquare.crypto.DecryptedMsgWithPubKey;
|
||||
import io.bitsquare.p2p.messaging.MailboxMessage;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.protocol.trade.ProcessModel;
|
||||
|
|
|
@ -56,7 +56,7 @@ public class CreateAndSignDepositTxAsBuyer extends TradeTask {
|
|||
contractHash,
|
||||
buyerInputAmount,
|
||||
msOutputAmount,
|
||||
processModel.tradingPeer.getRawInputs(),
|
||||
processModel.tradingPeer.getRawTransactionInputs(),
|
||||
processModel.tradingPeer.getChangeOutputValue(),
|
||||
processModel.tradingPeer.getChangeOutputAddress(),
|
||||
processModel.getAddressEntry(),
|
||||
|
@ -65,7 +65,7 @@ public class CreateAndSignDepositTxAsBuyer extends TradeTask {
|
|||
processModel.getArbitratorPubKey(trade.getArbitratorNodeAddress()));
|
||||
|
||||
processModel.setPreparedDepositTx(result.depositTransaction);
|
||||
processModel.setRawInputs(result.rawOffererInputs);
|
||||
processModel.setRawTransactionInputs(result.rawOffererInputs);
|
||||
|
||||
complete();
|
||||
} catch (Throwable t) {
|
||||
|
|
|
@ -39,7 +39,7 @@ public class CreateDepositTxInputsAsBuyer extends TradeTask {
|
|||
runInterceptHook();
|
||||
Coin takerInputAmount = FeePolicy.getSecurityDeposit().add(FeePolicy.getFixedTxFeeForTrades());
|
||||
InputsAndChangeOutput result = processModel.getTradeWalletService().takerCreatesDepositsTxInputs(takerInputAmount, processModel.getAddressEntry());
|
||||
processModel.setRawInputs(result.rawInputs);
|
||||
processModel.setRawTransactionInputs(result.rawTransactionInputs);
|
||||
processModel.setChangeOutputValue(result.changeOutputValue);
|
||||
processModel.setChangeOutputAddress(result.changeOutputAddress);
|
||||
|
||||
|
|
|
@ -49,24 +49,25 @@ public class SendPayoutTxFinalizedMessage extends TradeTask {
|
|||
@Override
|
||||
public void onArrived() {
|
||||
log.trace("Message arrived at peer.");
|
||||
trade.setState(Trade.State.PAYOUT_TX_SENT);
|
||||
complete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStoredInMailbox() {
|
||||
log.trace("Message stored in mailbox.");
|
||||
trade.setState(Trade.State.PAYOUT_TX_SENT);
|
||||
complete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFault(String errorMessage) {
|
||||
appendToErrorMessage("PayoutTxFinalizedMessage sending failed");
|
||||
failed();
|
||||
appendToErrorMessage("PayoutTxFinalizedMessage sending failed. errorMessage=" + errorMessage);
|
||||
failed(errorMessage);
|
||||
}
|
||||
}
|
||||
);
|
||||
// state must not be set in onArrived or onStoredInMailbox handlers as we would get that
|
||||
// called delayed and would overwrite the broad cast state set by the next task
|
||||
trade.setState(Trade.State.PAYOUT_TX_SENT);
|
||||
} else {
|
||||
log.error("trade.getPayoutTx() = " + trade.getPayoutTx());
|
||||
failed("PayoutTx is null");
|
||||
|
|
|
@ -57,7 +57,7 @@ public class SignAndFinalizePayoutTx extends TradeTask {
|
|||
);
|
||||
|
||||
trade.setPayoutTx(transaction);
|
||||
trade.setState(Trade.State.PAYOUT_TX_RECEIVED_AND_COMMITTED);
|
||||
trade.setState(Trade.State.PAYOUT_TX_COMMITTED);
|
||||
|
||||
complete();
|
||||
} catch (Throwable t) {
|
||||
|
|
|
@ -51,8 +51,8 @@ public class SignAndPublishDepositTxAsBuyer extends TradeTask {
|
|||
false,
|
||||
contractHash,
|
||||
processModel.getPreparedDepositTx(),
|
||||
processModel.getRawInputs(),
|
||||
processModel.tradingPeer.getRawInputs(),
|
||||
processModel.getRawTransactionInputs(),
|
||||
processModel.tradingPeer.getRawTransactionInputs(),
|
||||
processModel.getTradeWalletPubKey(),
|
||||
processModel.tradingPeer.getTradeWalletPubKey(),
|
||||
processModel.getArbitratorPubKey(trade.getArbitratorNodeAddress()),
|
||||
|
|
|
@ -35,7 +35,7 @@ public class LoadTakeOfferFeeTx extends TradeTask {
|
|||
try {
|
||||
runInterceptHook();
|
||||
|
||||
// TODO impl. not completed
|
||||
// TODO impl. missing
|
||||
//processModel.getWalletService().findTxInBlockChain(processModel.getTakeOfferFeeTxId());
|
||||
|
||||
complete();
|
||||
|
|
|
@ -50,8 +50,8 @@ public class ProcessPayDepositRequest extends TradeTask {
|
|||
checkTradeId(processModel.getId(), payDepositRequest);
|
||||
checkNotNull(payDepositRequest);
|
||||
|
||||
processModel.tradingPeer.setRawInputs(checkNotNull(payDepositRequest.rawInputs));
|
||||
checkArgument(payDepositRequest.rawInputs.size() > 0);
|
||||
processModel.tradingPeer.setRawTransactionInputs(checkNotNull(payDepositRequest.rawTransactionInputs));
|
||||
checkArgument(payDepositRequest.rawTransactionInputs.size() > 0);
|
||||
|
||||
processModel.tradingPeer.setChangeOutputValue(payDepositRequest.changeOutputValue);
|
||||
if (payDepositRequest.changeOutputAddress != null)
|
||||
|
|
|
@ -45,7 +45,7 @@ public class SendPublishDepositTxRequest extends TradeTask {
|
|||
trade.getOffererContractSignature(),
|
||||
processModel.getAddressEntry().getAddressString(),
|
||||
processModel.getPreparedDepositTx(),
|
||||
processModel.getRawInputs(),
|
||||
processModel.getRawTransactionInputs(),
|
||||
trade.getOpenDisputeTimeAsBlockHeight(),
|
||||
trade.getCheckPaymentTimeAsBlockHeight()
|
||||
);
|
||||
|
|
|
@ -34,7 +34,7 @@ public class VerifyTakerAccount extends TradeTask {
|
|||
protected void run() {
|
||||
try {
|
||||
runInterceptHook();
|
||||
//TODO mocked yet
|
||||
//TODO impl. missing
|
||||
/* if (processModel.getBlockChainService().isAccountBlackListed(processModel.tradingPeer.getAccountId(),
|
||||
processModel.tradingPeer.getPaymentAccountContractData())) {
|
||||
log.error("Taker is blacklisted");
|
||||
|
|
|
@ -56,7 +56,7 @@ public class CreateAndSignDepositTxAsSeller extends TradeTask {
|
|||
contractHash,
|
||||
sellerInputAmount,
|
||||
msOutputAmount,
|
||||
processModel.tradingPeer.getRawInputs(),
|
||||
processModel.tradingPeer.getRawTransactionInputs(),
|
||||
processModel.tradingPeer.getChangeOutputValue(),
|
||||
processModel.tradingPeer.getChangeOutputAddress(),
|
||||
processModel.getAddressEntry(),
|
||||
|
@ -65,7 +65,7 @@ public class CreateAndSignDepositTxAsSeller extends TradeTask {
|
|||
processModel.getArbitratorPubKey(trade.getArbitratorNodeAddress()));
|
||||
|
||||
processModel.setPreparedDepositTx(result.depositTransaction);
|
||||
processModel.setRawInputs(result.rawOffererInputs);
|
||||
processModel.setRawTransactionInputs(result.rawOffererInputs);
|
||||
|
||||
complete();
|
||||
} catch (Throwable t) {
|
||||
|
|
|
@ -42,7 +42,7 @@ public class CreateDepositTxInputsAsSeller extends TradeTask {
|
|||
|
||||
InputsAndChangeOutput result = processModel.getTradeWalletService().takerCreatesDepositsTxInputs(takerInputAmount, processModel
|
||||
.getAddressEntry());
|
||||
processModel.setRawInputs(result.rawInputs);
|
||||
processModel.setRawTransactionInputs(result.rawTransactionInputs);
|
||||
processModel.setChangeOutputValue(result.changeOutputValue);
|
||||
processModel.setChangeOutputAddress(result.changeOutputAddress);
|
||||
|
||||
|
|
|
@ -66,8 +66,8 @@ public class SendFinalizePayoutTxRequest extends TradeTask {
|
|||
|
||||
@Override
|
||||
public void onFault(String errorMessage) {
|
||||
appendToErrorMessage("FinalizePayoutTxRequest sending failed");
|
||||
failed();
|
||||
appendToErrorMessage("FinalizePayoutTxRequest sending failed. errorMessage=" + errorMessage);
|
||||
failed(errorMessage);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -49,8 +49,8 @@ public class SignAndPublishDepositTxAsSeller extends TradeTask {
|
|||
true,
|
||||
contractHash,
|
||||
processModel.getPreparedDepositTx(),
|
||||
processModel.tradingPeer.getRawInputs(),
|
||||
processModel.getRawInputs(),
|
||||
processModel.tradingPeer.getRawTransactionInputs(),
|
||||
processModel.getRawTransactionInputs(),
|
||||
processModel.tradingPeer.getTradeWalletPubKey(),
|
||||
processModel.getTradeWalletPubKey(),
|
||||
processModel.getArbitratorPubKey(trade.getArbitratorNodeAddress()),
|
||||
|
|
|
@ -35,7 +35,7 @@ public class LoadCreateOfferFeeTx extends TradeTask {
|
|||
try {
|
||||
runInterceptHook();
|
||||
|
||||
// TODO impl. not completed
|
||||
// TODO impl. missing
|
||||
///processModel.getWalletService().findTxInBlockChain(trade.getOffer().getOfferFeePaymentTxID());
|
||||
|
||||
complete();
|
||||
|
|
|
@ -63,7 +63,7 @@ public class ProcessPublishDepositTxRequest extends TradeTask {
|
|||
processModel.tradingPeer.setContractAsJson(nonEmptyStringOf(publishDepositTxRequest.offererContractAsJson));
|
||||
processModel.tradingPeer.setContractSignature(nonEmptyStringOf(publishDepositTxRequest.offererContractSignature));
|
||||
processModel.tradingPeer.setPayoutAddressString(nonEmptyStringOf(publishDepositTxRequest.offererPayoutAddressString));
|
||||
processModel.tradingPeer.setRawInputs(checkNotNull(publishDepositTxRequest.offererInputs));
|
||||
processModel.tradingPeer.setRawTransactionInputs(checkNotNull(publishDepositTxRequest.offererInputs));
|
||||
processModel.setPreparedDepositTx(checkNotNull(publishDepositTxRequest.preparedDepositTx));
|
||||
checkArgument(publishDepositTxRequest.offererInputs.size() > 0);
|
||||
if (publishDepositTxRequest.openDisputeTimeAsBlockHeight != 0) {
|
||||
|
|
|
@ -25,6 +25,8 @@ import io.bitsquare.trade.protocol.trade.tasks.TradeTask;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class SendPayDepositRequest extends TradeTask {
|
||||
|
@ -47,7 +49,7 @@ public class SendPayDepositRequest extends TradeTask {
|
|||
processModel.getMyAddress(),
|
||||
processModel.getId(),
|
||||
trade.getTradeAmount().value,
|
||||
processModel.getRawInputs(),
|
||||
processModel.getRawTransactionInputs(),
|
||||
processModel.getChangeOutputValue(),
|
||||
processModel.getChangeOutputAddress(),
|
||||
processModel.getTradeWalletPubKey(),
|
||||
|
@ -56,7 +58,7 @@ public class SendPayDepositRequest extends TradeTask {
|
|||
processModel.getPaymentAccountContractData(trade),
|
||||
processModel.getAccountId(),
|
||||
trade.getTakeOfferFeeTxId(),
|
||||
processModel.getUser().getAcceptedArbitratorAddresses(),
|
||||
new ArrayList<>(processModel.getUser().getAcceptedArbitratorAddresses()),
|
||||
trade.getArbitratorNodeAddress()
|
||||
);
|
||||
|
||||
|
|
|
@ -201,14 +201,6 @@ public final class User implements Persistable {
|
|||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// TODO just a first attempt, refine when working on the embedded data for the reg. tx
|
||||
public String getStringifiedBankAccounts() {
|
||||
return paymentAccounts.stream()
|
||||
.map(PaymentAccount::getId)
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
|
||||
public PaymentAccount getPaymentAccount(String paymentAccountId) {
|
||||
Optional<PaymentAccount> optional = paymentAccounts.stream().filter(e -> e.getId().equals(paymentAccountId)).findAny();
|
||||
if (optional.isPresent())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue