mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 07:07:43 +01:00
Refactor base interfaces for protobuffer. Rename User to UserPayload and UserModel to User.
This commit is contained in:
parent
752e02dd89
commit
1cf910e8cb
178 changed files with 1307 additions and 1278 deletions
7
common/src/main/java/io/bisq/common/Envelope.java
Normal file
7
common/src/main/java/io/bisq/common/Envelope.java
Normal file
|
@ -0,0 +1,7 @@
|
|||
package io.bisq.common;
|
||||
|
||||
/**
|
||||
* Interface for the outside envelope object sent over the network or persisted to disc.
|
||||
*/
|
||||
public interface Envelope extends Proto {
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package io.bisq.common;
|
||||
|
||||
/**
|
||||
* Marker interface for data which is sent over the wire
|
||||
* Interface for objects used inside an Envelope or other Payloads.
|
||||
*/
|
||||
public interface Payload extends Marshaller {
|
||||
}
|
||||
public interface Payload extends Proto {
|
||||
}
|
|
@ -21,6 +21,9 @@ import com.google.protobuf.Message;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
public interface Marshaller extends Serializable {
|
||||
/**
|
||||
* Base interface for Envelope and Payload.
|
||||
*/
|
||||
interface Proto extends Serializable {
|
||||
Message toProtoMessage();
|
||||
}
|
|
@ -18,7 +18,7 @@
|
|||
package io.bisq.common.crypto;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bisq.common.Payload;
|
||||
import io.bisq.common.network.NetworkPayload;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -42,7 +42,7 @@ import java.security.spec.X509EncodedKeySpec;
|
|||
*/
|
||||
@Slf4j
|
||||
@EqualsAndHashCode
|
||||
public final class PubKeyRing implements Payload {
|
||||
public final class PubKeyRing implements NetworkPayload {
|
||||
private final byte[] signaturePubKeyBytes;
|
||||
private final byte[] encryptionPubKeyBytes;
|
||||
private String pgpPubKeyAsPem;
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
package io.bisq.common.crypto;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bisq.common.Payload;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.NetworkPayload;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -33,7 +33,7 @@ import java.security.spec.InvalidKeySpecException;
|
|||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class SealedAndSigned implements Payload {
|
||||
public final class SealedAndSigned implements NetworkPayload {
|
||||
// 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(SealedAndSigned.class);
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bisq.common.locale;
|
|||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
@ -29,7 +29,7 @@ import javax.annotation.concurrent.Immutable;
|
|||
@Immutable
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public final class Country implements Persistable {
|
||||
public final class Country implements PersistablePayload {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bisq.common.locale;
|
|||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
@ -29,7 +29,7 @@ import javax.annotation.concurrent.Immutable;
|
|||
@Immutable
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public final class Region implements Persistable {
|
||||
public final class Region implements PersistablePayload {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bisq.common.locale;
|
||||
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
|
@ -32,7 +32,7 @@ import javax.annotation.Nullable;
|
|||
@ToString
|
||||
@Getter
|
||||
@Slf4j
|
||||
public abstract class TradeCurrency implements Persistable, Comparable<TradeCurrency> {
|
||||
public abstract class TradeCurrency implements PersistablePayload, Comparable<TradeCurrency> {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
package io.bisq.common.network;
|
||||
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.Marshaller;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
|
||||
public interface Msg extends Marshaller {
|
||||
static PB.Msg.Builder getMsgBuilder() {
|
||||
return PB.Msg.newBuilder().setMsgVersion(Version.getP2PMessageVersion());
|
||||
}
|
||||
|
||||
default Message toProtoMessage() {
|
||||
return toProtoMsg();
|
||||
}
|
||||
|
||||
int getMsgVersion();
|
||||
|
||||
PB.Msg toProtoMsg();
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package io.bisq.common.network;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.Envelope;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
|
||||
/**
|
||||
* Interface for the outside envelope object sent over the network.
|
||||
*/
|
||||
public interface NetworkEnvelope extends Envelope {
|
||||
static PB.WireEnvelope.Builder getMsgBuilder() {
|
||||
return PB.WireEnvelope.newBuilder().setMsgVersion(Version.getP2PMessageVersion());
|
||||
}
|
||||
|
||||
default Message toProtoMessage() {
|
||||
return toProtoMsg();
|
||||
}
|
||||
|
||||
int getMsgVersion();
|
||||
|
||||
PB.WireEnvelope toProtoMsg();
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package io.bisq.common.network;
|
||||
|
||||
import io.bisq.common.Payload;
|
||||
|
||||
/**
|
||||
* Interface for objects used inside WireEnvelope or other WirePayloads.
|
||||
*/
|
||||
public interface NetworkPayload extends Payload {
|
||||
}
|
|
@ -15,26 +15,25 @@
|
|||
* along with bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bisq.common.proto;
|
||||
package io.bisq.common.persistable;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.Marshaller;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ProtoHelper {
|
||||
public class PersistableCollectionUtil {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Convenience
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public static Iterable collectionToProto(Collection<? extends Marshaller> collection) {
|
||||
return collection.stream().map(Marshaller::toProtoMessage).collect(Collectors.toList());
|
||||
public static Iterable collectionToProto(Collection<? extends PersistablePayload> collection) {
|
||||
return collection.stream().map(e -> e.toProtoMessage()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static <T> Iterable<T> collectionToProto(Collection<? extends Marshaller> collection, Function<? super Message, T> extra) {
|
||||
public static <T> Iterable<T> collectionToProto(Collection<? extends PersistablePayload> collection, Function<? super Message, T> extra) {
|
||||
return collection.stream().map(o -> {
|
||||
return extra.apply(o.toProtoMessage());
|
||||
}).collect(Collectors.toList());
|
|
@ -0,0 +1,9 @@
|
|||
package io.bisq.common.persistable;
|
||||
|
||||
import io.bisq.common.Envelope;
|
||||
|
||||
/**
|
||||
* Interface for the outside envelope object persisted to disc.
|
||||
*/
|
||||
public interface PersistableEnvelope extends Envelope {
|
||||
}
|
|
@ -15,7 +15,7 @@
|
|||
* along with bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bisq.common.persistence;
|
||||
package io.bisq.common.persistable;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import lombok.Getter;
|
||||
|
@ -27,18 +27,18 @@ import java.util.HashMap;
|
|||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class HashMapPersistable<K, V> implements Persistable {
|
||||
public class PersistableHashMap<K extends PersistablePayload, V extends PersistablePayload> implements PersistableEnvelope {
|
||||
@Delegate
|
||||
@Getter
|
||||
private HashMap<K, V> hashMap = new HashMap<>();
|
||||
@Setter
|
||||
private Function<HashMap<K, V>, Message> toProto;
|
||||
|
||||
public HashMapPersistable(HashMap<K, V> hashMap) {
|
||||
public PersistableHashMap(HashMap<K, V> hashMap) {
|
||||
this.hashMap = hashMap;
|
||||
}
|
||||
|
||||
public HashMapPersistable(HashMap<K, V> hashMap, Function<HashMap<K, V>, Message> toProto) {
|
||||
public PersistableHashMap(HashMap<K, V> hashMap, Function<HashMap<K, V>, Message> toProto) {
|
||||
this(hashMap);
|
||||
setToProto(toProto);
|
||||
}
|
|
@ -15,7 +15,7 @@
|
|||
* along with bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bisq.common.persistence;
|
||||
package io.bisq.common.persistable;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import lombok.Getter;
|
||||
|
@ -28,28 +28,28 @@ import java.util.Objects;
|
|||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ListPersistable<T extends Persistable> implements Persistable {
|
||||
public class PersistableList<T extends PersistablePayload> implements PersistableEnvelope {
|
||||
@Getter
|
||||
@Setter
|
||||
private List<T> list;
|
||||
@Setter
|
||||
private Function<List<T>, Message> toProto;
|
||||
|
||||
public ListPersistable(List<T> list) {
|
||||
public PersistableList(List<T> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public ListPersistable(List<T> list, Function<List<T>, Message> toProto) {
|
||||
public PersistableList(List<T> list, Function<List<T>, Message> toProto) {
|
||||
this(list);
|
||||
this.toProto = toProto;
|
||||
}
|
||||
|
||||
/** convenience ctor */
|
||||
public ListPersistable(HashSet<T> set) {
|
||||
public PersistableList(HashSet<T> set) {
|
||||
this(set.stream().collect(Collectors.toList()));
|
||||
}
|
||||
/** convenience ctor */
|
||||
public ListPersistable(HashSet<T> set, Function<List<T>, Message> toProto) {
|
||||
public PersistableList(HashSet<T> set, Function<List<T>, Message> toProto) {
|
||||
this(set);
|
||||
this.toProto = toProto;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* This file is part of bisq.
|
||||
*
|
||||
* bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bisq.common.persistable;
|
||||
|
||||
import io.bisq.common.Payload;
|
||||
|
||||
/**
|
||||
* Interface for objects used inside Envelope or other Payloads.
|
||||
*/
|
||||
public interface PersistablePayload extends Payload {
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package io.bisq.common.persistence;
|
||||
|
||||
import io.bisq.common.Marshaller;
|
||||
|
||||
/**
|
||||
* Marker interface for data which is used for local data persistence
|
||||
*/
|
||||
public interface Persistable extends Marshaller {
|
||||
}
|
|
@ -17,11 +17,11 @@
|
|||
|
||||
package io.bisq.common.proto;
|
||||
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface NetworkProtoResolver {
|
||||
Optional<Msg> fromProto(PB.Msg msg);
|
||||
Optional<NetworkEnvelope> fromProto(PB.WireEnvelope msg);
|
||||
}
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
|
||||
package io.bisq.common.proto;
|
||||
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistableEnvelope;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface PersistenceProtoResolver {
|
||||
Optional<Persistable> fromProto(PB.Persistable persistable);
|
||||
Optional<PersistableEnvelope> fromProto(PB.DiscEnvelope persistable);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package io.bisq.common.storage;
|
|||
import com.google.common.util.concurrent.CycleDetectingLockFactory;
|
||||
import io.bisq.common.UserThread;
|
||||
import io.bisq.common.io.LookAheadObjectInputStream;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistableEnvelope;
|
||||
import io.bisq.common.proto.PersistenceProtoResolver;
|
||||
import io.bisq.common.util.Utilities;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
|
@ -37,7 +37,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
@Slf4j
|
||||
public class FileManager<T extends Persistable> {
|
||||
public class FileManager<T extends PersistableEnvelope> {
|
||||
private final File dir;
|
||||
private final File storageFile;
|
||||
private final ScheduledThreadPoolExecutor executor;
|
||||
|
@ -108,16 +108,16 @@ public class FileManager<T extends Persistable> {
|
|||
|
||||
public synchronized T read(File file) throws IOException, ClassNotFoundException {
|
||||
log.debug("read" + file);
|
||||
Optional<Persistable> persistable = Optional.empty();
|
||||
Optional<PersistableEnvelope> persistable = Optional.empty();
|
||||
|
||||
try (final FileInputStream fileInputStream = new FileInputStream(file)) {
|
||||
persistable = persistenceProtoResolver.fromProto(PB.Persistable.parseDelimitedFrom(fileInputStream));
|
||||
persistable = persistenceProtoResolver.fromProto(PB.DiscEnvelope.parseDelimitedFrom(fileInputStream));
|
||||
} catch (Throwable t) {
|
||||
log.error("Exception at proto read: " + t.getMessage() + " " + file.getName());
|
||||
}
|
||||
|
||||
if (persistable.isPresent()) {
|
||||
log.info("Reading Persistable: {}", persistable.get().getClass());
|
||||
log.info("Reading DiscEnvelope: {}", persistable.get().getClass());
|
||||
//noinspection unchecked
|
||||
return (T) persistable.get();
|
||||
}
|
||||
|
@ -197,9 +197,9 @@ public class FileManager<T extends Persistable> {
|
|||
|
||||
// is it a protobuffer thing?
|
||||
|
||||
PB.Persistable protoPersistable = null;
|
||||
PB.DiscEnvelope protoPersistable = null;
|
||||
try {
|
||||
protoPersistable = (PB.Persistable) persistable.toProtoMessage();
|
||||
protoPersistable = (PB.DiscEnvelope) persistable.toProtoMessage();
|
||||
} catch (Throwable e) {
|
||||
log.debug("Not protobufferable: {}, {}, {}", persistable.getClass().getSimpleName(), storageFile, e.getStackTrace());
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package io.bisq.common.storage;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistableEnvelope;
|
||||
|
||||
/**
|
||||
* Used to wrap a plaintext string to distinguish at file storage and safe it as plain text instead of a serialized java object.
|
||||
*/
|
||||
// We would not need Persistable but as it is used in Storage and Storage expects a Persistable as type we keep it...
|
||||
// TODO use same like in the BSQChainState JSON persistence....
|
||||
public class PlainTextWrapper implements Persistable {
|
||||
public class PlainTextWrapper implements PersistableEnvelope {
|
||||
// That object is not saved to disc it is only of type Serializable to support the persistent framework.
|
||||
// SerialVersionUID has no relevance here.
|
||||
private static final long serialVersionUID = 0;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bisq.common.storage;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistableEnvelope;
|
||||
import io.bisq.common.proto.PersistenceProtoResolver;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -47,7 +47,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
* <p>
|
||||
* The write operation used a background thread and supports a delayed write to avoid too many repeated write operations.
|
||||
*/
|
||||
public class Storage<T extends Persistable> {
|
||||
public class Storage<T extends PersistableEnvelope> {
|
||||
private static final Logger log = LoggerFactory.getLogger(Storage.class);
|
||||
public static final String STORAGE_DIR = "storageDir";
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ option java_outer_classname = "PB";
|
|||
// P2P network messages
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
message Msg {
|
||||
message WireEnvelope {
|
||||
int32 msg_version = 1;
|
||||
oneof message {
|
||||
PreliminaryGetDataRequest preliminary_get_data_request = 2;
|
||||
|
@ -59,7 +59,7 @@ message Msg {
|
|||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Implementations of Msg
|
||||
// Implementations of WireEnvelope
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// get data
|
||||
|
@ -790,23 +790,25 @@ message PrivateNotificationPayload {
|
|||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Persistable
|
||||
// DiscEnvelope
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
message Persistable {
|
||||
message DiscEnvelope {
|
||||
// TODO used and set??
|
||||
int64 local_db_version = 1;
|
||||
oneof message {
|
||||
AddressEntryList address_entry_list = 2;
|
||||
ViewPathAsString view_path_as_string = 3;
|
||||
PeersList peers_list = 4;
|
||||
Preferences preferences = 5;
|
||||
User user = 6;
|
||||
UserPayload user_payload = 6;
|
||||
CompensationRequestPayload compensation_request_payload = 7;
|
||||
SequenceNumberMap sequence_number_map = 8;
|
||||
PersistedEntryMap persisted_entry_map = 9;
|
||||
TradeStatisticsList trade_statistics_list = 10;
|
||||
VoteItemsList vote_items_list = 11;
|
||||
TradableList tradable_list = 12;
|
||||
BsqChainState bsq_chain_state = 13;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -854,10 +856,10 @@ message Preferences {
|
|||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// User
|
||||
// UserPayload
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
message User {
|
||||
message UserPayload {
|
||||
string account_id = 1;
|
||||
repeated PaymentAccount payment_accounts = 2;
|
||||
PaymentAccount current_payment_account = 3;
|
||||
|
@ -1086,6 +1088,10 @@ message TradeStatisticsList {
|
|||
// DAO
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
message BsqChainState {
|
||||
// TODO not impl yet
|
||||
}
|
||||
|
||||
message VoteItem {
|
||||
enum VotingType {
|
||||
UNKNOWN_FAILURE = 0;
|
||||
|
|
|
@ -22,7 +22,7 @@ import com.google.inject.name.Named;
|
|||
import io.bisq.common.app.DevEnv;
|
||||
import io.bisq.common.crypto.KeyRing;
|
||||
import io.bisq.core.app.AppOptionKeys;
|
||||
import io.bisq.core.user.UserModel;
|
||||
import io.bisq.core.user.User;
|
||||
import io.bisq.network.p2p.P2PService;
|
||||
import io.bisq.network.p2p.storage.HashMapChangedListener;
|
||||
import io.bisq.network.p2p.storage.payload.ProtectedStorageEntry;
|
||||
|
@ -45,7 +45,7 @@ public class AlertManager {
|
|||
|
||||
private final P2PService p2PService;
|
||||
private final KeyRing keyRing;
|
||||
private final UserModel userModel;
|
||||
private final User user;
|
||||
private final ObjectProperty<Alert> alertMessageProperty = new SimpleObjectProperty<>();
|
||||
|
||||
// Pub key for developer global alert message
|
||||
|
@ -60,10 +60,10 @@ public class AlertManager {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public AlertManager(P2PService p2PService, KeyRing keyRing, UserModel userModel, @Named(AppOptionKeys.IGNORE_DEV_MSG_KEY) boolean ignoreDevMsg) {
|
||||
public AlertManager(P2PService p2PService, KeyRing keyRing, User user, @Named(AppOptionKeys.IGNORE_DEV_MSG_KEY) boolean ignoreDevMsg) {
|
||||
this.p2PService = p2PService;
|
||||
this.keyRing = keyRing;
|
||||
this.userModel = userModel;
|
||||
this.user = user;
|
||||
|
||||
if (!ignoreDevMsg) {
|
||||
p2PService.addHashSetChangedListener(new HashMapChangedListener() {
|
||||
|
@ -100,13 +100,13 @@ public class AlertManager {
|
|||
|
||||
public boolean addAlertMessageIfKeyIsValid(Alert alert, String privKeyString) {
|
||||
// if there is a previous message we remove that first
|
||||
if (userModel.getDevelopersAlert() != null)
|
||||
if (user.getDevelopersAlert() != null)
|
||||
removeAlertMessageIfKeyIsValid(privKeyString);
|
||||
|
||||
boolean isKeyValid = isKeyValid(privKeyString);
|
||||
if (isKeyValid) {
|
||||
signAndAddSignatureToAlertMessage(alert);
|
||||
userModel.setDevelopersAlert(alert);
|
||||
user.setDevelopersAlert(alert);
|
||||
boolean result = p2PService.addData(alert, true);
|
||||
if (result) {
|
||||
log.trace("Add alertMessage to network was successful. AlertMessage = " + alert);
|
||||
|
@ -117,12 +117,12 @@ public class AlertManager {
|
|||
}
|
||||
|
||||
public boolean removeAlertMessageIfKeyIsValid(String privKeyString) {
|
||||
Alert alert = userModel.getDevelopersAlert();
|
||||
Alert alert = user.getDevelopersAlert();
|
||||
if (isKeyValid(privKeyString) && alert != null) {
|
||||
if (p2PService.removeData(alert, true))
|
||||
log.trace("Remove alertMessage from network was successful. AlertMessage = " + alert);
|
||||
|
||||
userModel.setDevelopersAlert(null);
|
||||
user.setDevelopersAlert(null);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -22,7 +22,7 @@ import com.google.inject.name.Named;
|
|||
import io.bisq.common.app.DevEnv;
|
||||
import io.bisq.common.crypto.KeyRing;
|
||||
import io.bisq.common.crypto.PubKeyRing;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.core.app.AppOptionKeys;
|
||||
import io.bisq.network.p2p.DecryptedMsgWithPubKey;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
|
@ -75,9 +75,9 @@ public class PrivateNotificationManager {
|
|||
|
||||
private void handleMessage(DecryptedMsgWithPubKey decryptedMsgWithPubKey, NodeAddress senderNodeAddress) {
|
||||
this.decryptedMsgWithPubKey = decryptedMsgWithPubKey;
|
||||
Msg msg = decryptedMsgWithPubKey.msg;
|
||||
if (msg instanceof PrivateNotificationMsg) {
|
||||
PrivateNotificationMsg privateNotificationMessage = (PrivateNotificationMsg) msg;
|
||||
NetworkEnvelope wireEnvelope = decryptedMsgWithPubKey.wireEnvelope;
|
||||
if (wireEnvelope instanceof PrivateNotificationMsg) {
|
||||
PrivateNotificationMsg privateNotificationMessage = (PrivateNotificationMsg) wireEnvelope;
|
||||
log.trace("Received privateNotificationMessage: " + privateNotificationMessage);
|
||||
if (privateNotificationMessage.getSenderNodeAddress().equals(senderNodeAddress)) {
|
||||
final PrivateNotificationPayload privateNotification = privateNotificationMessage.privateNotificationPayload;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package io.bisq.core.alert;
|
||||
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.MailboxMsg;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
|
@ -45,8 +45,8 @@ public class PrivateNotificationMsg implements MailboxMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Msg toProtoMsg() {
|
||||
PB.Msg.Builder msgBuilder = Msg.getMsgBuilder();
|
||||
public PB.WireEnvelope toProtoMsg() {
|
||||
PB.WireEnvelope.Builder msgBuilder = NetworkEnvelope.getMsgBuilder();
|
||||
return msgBuilder.setPrivateNotificationMessage(msgBuilder.getPrivateNotificationMessageBuilder()
|
||||
.setMessageVersion(messageVersion)
|
||||
.setUid(uid)
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
package io.bisq.core.alert;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bisq.common.Payload;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.crypto.Sig;
|
||||
import io.bisq.common.network.NetworkPayload;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -36,7 +36,7 @@ import java.security.spec.X509EncodedKeySpec;
|
|||
|
||||
@EqualsAndHashCode
|
||||
@Slf4j
|
||||
public final class PrivateNotificationPayload implements Payload {
|
||||
public final class PrivateNotificationPayload implements NetworkPayload {
|
||||
// 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;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import io.bisq.common.crypto.KeyRing;
|
|||
import io.bisq.common.handlers.ErrorMessageHandler;
|
||||
import io.bisq.common.handlers.ResultHandler;
|
||||
import io.bisq.core.user.Preferences;
|
||||
import io.bisq.core.user.UserModel;
|
||||
import io.bisq.core.user.User;
|
||||
import io.bisq.network.p2p.BootstrapListener;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
import io.bisq.network.p2p.P2PService;
|
||||
|
@ -88,7 +88,7 @@ public class ArbitratorManager {
|
|||
|
||||
private final KeyRing keyRing;
|
||||
private final ArbitratorService arbitratorService;
|
||||
private final UserModel userModel;
|
||||
private final User user;
|
||||
private final Preferences preferences;
|
||||
private final ObservableMap<NodeAddress, Arbitrator> arbitratorsObservableMap = FXCollections.observableHashMap();
|
||||
private final List<Arbitrator> persistedAcceptedArbitrators;
|
||||
|
@ -100,17 +100,17 @@ public class ArbitratorManager {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public ArbitratorManager(KeyRing keyRing, ArbitratorService arbitratorService, UserModel userModel, Preferences preferences) {
|
||||
public ArbitratorManager(KeyRing keyRing, ArbitratorService arbitratorService, User user, Preferences preferences) {
|
||||
this.keyRing = keyRing;
|
||||
this.arbitratorService = arbitratorService;
|
||||
this.userModel = userModel;
|
||||
this.user = user;
|
||||
this.preferences = preferences;
|
||||
|
||||
persistedAcceptedArbitrators = new ArrayList<>(userModel.getAcceptedArbitrators());
|
||||
userModel.clearAcceptedArbitrators();
|
||||
persistedAcceptedArbitrators = new ArrayList<>(user.getAcceptedArbitrators());
|
||||
user.clearAcceptedArbitrators();
|
||||
|
||||
// TODO we mirror arbitrator data for mediator as long we have not impl. it in the UI
|
||||
userModel.clearAcceptedMediators();
|
||||
user.clearAcceptedMediators();
|
||||
|
||||
arbitratorService.addHashSetChangedListener(new HashMapChangedListener() {
|
||||
@Override
|
||||
|
@ -138,7 +138,7 @@ public class ArbitratorManager {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void onAllServicesInitialized() {
|
||||
if (userModel.getRegisteredArbitrator() != null) {
|
||||
if (user.getRegisteredArbitrator() != null) {
|
||||
P2PService p2PService = arbitratorService.getP2PService();
|
||||
if (p2PService.isBootstrapped())
|
||||
isBootstrapped();
|
||||
|
@ -174,17 +174,17 @@ public class ArbitratorManager {
|
|||
arbitratorsObservableMap.values().stream()
|
||||
.filter(arbitrator -> persistedAcceptedArbitrators.contains(arbitrator))
|
||||
.forEach(a -> {
|
||||
userModel.addAcceptedArbitrator(a);
|
||||
userModel.addAcceptedMediator(getMediator(a)
|
||||
user.addAcceptedArbitrator(a);
|
||||
user.addAcceptedMediator(getMediator(a)
|
||||
);
|
||||
});
|
||||
|
||||
if (preferences.isAutoSelectArbitrators()) {
|
||||
arbitratorsObservableMap.values().stream()
|
||||
.filter(userModel::hasMatchingLanguage)
|
||||
.filter(user::hasMatchingLanguage)
|
||||
.forEach(a -> {
|
||||
userModel.addAcceptedArbitrator(a);
|
||||
userModel.addAcceptedMediator(getMediator(a)
|
||||
user.addAcceptedArbitrator(a);
|
||||
user.addAcceptedMediator(getMediator(a)
|
||||
);
|
||||
});
|
||||
} else {
|
||||
|
@ -192,12 +192,12 @@ public class ArbitratorManager {
|
|||
// we use a delay as we might get our matching arbitrator a bit delayed (first we get one we did not selected
|
||||
// then we get our selected one - we don't want to activate the first in that case)
|
||||
UserThread.runAfter(() -> {
|
||||
if (userModel.getAcceptedArbitrators().isEmpty()) {
|
||||
if (user.getAcceptedArbitrators().isEmpty()) {
|
||||
arbitratorsObservableMap.values().stream()
|
||||
.filter(userModel::hasMatchingLanguage)
|
||||
.filter(user::hasMatchingLanguage)
|
||||
.forEach(a -> {
|
||||
userModel.addAcceptedArbitrator(a);
|
||||
userModel.addAcceptedMediator(getMediator(a)
|
||||
user.addAcceptedArbitrator(a);
|
||||
user.addAcceptedMediator(getMediator(a)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ public class ArbitratorManager {
|
|||
}
|
||||
|
||||
public void addArbitrator(Arbitrator arbitrator, ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
|
||||
userModel.setRegisteredArbitrator(arbitrator);
|
||||
user.setRegisteredArbitrator(arbitrator);
|
||||
arbitratorsObservableMap.put(arbitrator.getNodeAddress(), arbitrator);
|
||||
arbitratorService.addArbitrator(arbitrator,
|
||||
() -> {
|
||||
|
@ -234,9 +234,9 @@ public class ArbitratorManager {
|
|||
}
|
||||
|
||||
public void removeArbitrator(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
|
||||
Arbitrator registeredArbitrator = userModel.getRegisteredArbitrator();
|
||||
Arbitrator registeredArbitrator = user.getRegisteredArbitrator();
|
||||
if (registeredArbitrator != null) {
|
||||
userModel.setRegisteredArbitrator(null);
|
||||
user.setRegisteredArbitrator(null);
|
||||
arbitratorsObservableMap.remove(registeredArbitrator.getNodeAddress());
|
||||
arbitratorService.removeArbitrator(registeredArbitrator,
|
||||
() -> {
|
||||
|
@ -278,7 +278,7 @@ public class ArbitratorManager {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void republishArbitrator() {
|
||||
Arbitrator registeredArbitrator = userModel.getRegisteredArbitrator();
|
||||
Arbitrator registeredArbitrator = user.getRegisteredArbitrator();
|
||||
if (registeredArbitrator != null) {
|
||||
addArbitrator(registeredArbitrator,
|
||||
this::updateArbitratorMap,
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package io.bisq.core.arbitration;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bisq.common.Payload;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.NetworkPayload;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.bouncycastle.util.encoders.Hex;
|
||||
|
||||
@EqualsAndHashCode
|
||||
public final class Attachment implements Payload {
|
||||
public final class Attachment implements NetworkPayload {
|
||||
// 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;
|
||||
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
package io.bisq.core.arbitration;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bisq.common.Payload;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.crypto.PubKeyRing;
|
||||
import io.bisq.common.network.NetworkPayload;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import io.bisq.common.util.Utilities;
|
||||
import io.bisq.core.arbitration.messages.DisputeCommunicationMsg;
|
||||
|
@ -43,7 +43,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
@Slf4j
|
||||
@EqualsAndHashCode
|
||||
public final class Dispute implements Payload {
|
||||
public final class Dispute implements NetworkPayload {
|
||||
// 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;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bisq.core.arbitration;
|
|||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistableEnvelope;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
|
@ -41,7 +41,7 @@ import java.util.stream.Stream;
|
|||
* Calls to the List are delegated because this class intercepts the add/remove calls so changes
|
||||
* can be saved to disc.
|
||||
*/
|
||||
public final class DisputeList implements Persistable {
|
||||
public final class DisputeList implements PersistableEnvelope {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import io.bisq.common.crypto.PubKeyRing;
|
|||
import io.bisq.common.handlers.FaultHandler;
|
||||
import io.bisq.common.handlers.ResultHandler;
|
||||
import io.bisq.common.locale.Res;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.common.proto.PersistenceProtoResolver;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import io.bisq.core.arbitration.messages.*;
|
||||
|
@ -169,18 +169,18 @@ public class DisputeManager {
|
|||
|
||||
private void applyMessages() {
|
||||
decryptedDirectMessageWithPubKeys.forEach(decryptedMessageWithPubKey -> {
|
||||
Msg msg = decryptedMessageWithPubKey.msg;
|
||||
log.debug("decryptedDirectMessageWithPubKeys.message " + msg);
|
||||
if (msg instanceof DisputeMsg)
|
||||
dispatchMessage((DisputeMsg) msg);
|
||||
NetworkEnvelope wireEnvelope = decryptedMessageWithPubKey.wireEnvelope;
|
||||
log.debug("decryptedDirectMessageWithPubKeys.message " + wireEnvelope);
|
||||
if (wireEnvelope instanceof DisputeMsg)
|
||||
dispatchMessage((DisputeMsg) wireEnvelope);
|
||||
});
|
||||
decryptedDirectMessageWithPubKeys.clear();
|
||||
|
||||
decryptedMailboxMessageWithPubKeys.forEach(decryptedMessageWithPubKey -> {
|
||||
Msg msg = decryptedMessageWithPubKey.msg;
|
||||
log.debug("decryptedMessageWithPubKey.message " + msg);
|
||||
if (msg instanceof DisputeMsg) {
|
||||
dispatchMessage((DisputeMsg) msg);
|
||||
NetworkEnvelope wireEnvelope = decryptedMessageWithPubKey.wireEnvelope;
|
||||
log.debug("decryptedMessageWithPubKey.message " + wireEnvelope);
|
||||
if (wireEnvelope instanceof DisputeMsg) {
|
||||
dispatchMessage((DisputeMsg) wireEnvelope);
|
||||
p2PService.removeEntryFromMailbox(decryptedMessageWithPubKey);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
package io.bisq.core.arbitration;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bisq.common.Payload;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.NetworkPayload;
|
||||
import io.bisq.core.arbitration.messages.DisputeCommunicationMsg;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
|
@ -36,7 +36,7 @@ import java.io.ObjectInputStream;
|
|||
import java.util.Date;
|
||||
|
||||
@EqualsAndHashCode
|
||||
public final class DisputeResult implements Payload {
|
||||
public final class DisputeResult implements NetworkPayload {
|
||||
// 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(DisputeResult.class);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bisq.core.arbitration.messages;
|
||||
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.core.arbitration.Attachment;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
|
@ -132,8 +132,8 @@ public final class DisputeCommunicationMsg extends DisputeMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Msg toProtoMsg() {
|
||||
PB.Msg.Builder msgBuilder = Msg.getMsgBuilder();
|
||||
public PB.WireEnvelope toProtoMsg() {
|
||||
PB.WireEnvelope.Builder msgBuilder = NetworkEnvelope.getMsgBuilder();
|
||||
return msgBuilder.setDisputeCommunicationMessage(PB.DisputeCommunicationMessage.newBuilder()
|
||||
.setDate(date)
|
||||
.setTradeId(tradeId)
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bisq.core.arbitration.messages;
|
||||
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.core.arbitration.DisputeResult;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
|
@ -46,8 +46,8 @@ public final class DisputeResultMsg extends DisputeMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Msg toProtoMsg() {
|
||||
PB.Msg.Builder msgBuilder = Msg.getMsgBuilder();
|
||||
public PB.WireEnvelope toProtoMsg() {
|
||||
PB.WireEnvelope.Builder msgBuilder = NetworkEnvelope.getMsgBuilder();
|
||||
return msgBuilder.setDisputeResultMessage(PB.DisputeResultMessage.newBuilder()
|
||||
.setDisputeResult(disputeResult.toProtoMessage())
|
||||
.setMyNodeAddress(myNodeAddress.toProtoMessage())
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bisq.core.arbitration.messages;
|
||||
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.core.arbitration.Dispute;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
|
@ -46,8 +46,8 @@ public final class OpenNewDisputeMsg extends DisputeMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Msg toProtoMsg() {
|
||||
PB.Msg.Builder msgBuilder = Msg.getMsgBuilder();
|
||||
public PB.WireEnvelope toProtoMsg() {
|
||||
PB.WireEnvelope.Builder msgBuilder = NetworkEnvelope.getMsgBuilder();
|
||||
return msgBuilder.setOpenNewDisputeMessage(PB.OpenNewDisputeMessage.newBuilder()
|
||||
.setDispute(dispute.toProtoMessage()).setMyNodeAddress(myNodeAddress.toProtoMessage()).setUid(getUID())).build();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bisq.core.arbitration.messages;
|
||||
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.core.arbitration.Dispute;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
|
@ -46,8 +46,8 @@ public final class PeerOpenedDisputeMsg extends DisputeMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Msg toProtoMsg() {
|
||||
PB.Msg.Builder msgBuilder = Msg.getMsgBuilder();
|
||||
public PB.WireEnvelope toProtoMsg() {
|
||||
PB.WireEnvelope.Builder msgBuilder = NetworkEnvelope.getMsgBuilder();
|
||||
return msgBuilder.setPeerOpenedDisputeMessage(PB.PeerOpenedDisputeMessage.newBuilder()
|
||||
.setDispute(dispute.toProtoMessage())
|
||||
.setMyNodeAddress(myNodeAddress.toProtoMessage())
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bisq.core.arbitration.messages;
|
|||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -46,8 +46,8 @@ public final class PeerPublishedPayoutTxMsg extends DisputeMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Msg toProtoMsg() {
|
||||
PB.Msg.Builder msgBuilder = Msg.getMsgBuilder();
|
||||
public PB.WireEnvelope toProtoMsg() {
|
||||
PB.WireEnvelope.Builder msgBuilder = NetworkEnvelope.getMsgBuilder();
|
||||
return msgBuilder.setPeerPublishedPayoutTxMessage(PB.PeerPublishedPayoutTxMessage.newBuilder()
|
||||
.setTransaction(ByteString.copyFrom(transaction))
|
||||
.setTradeId(tradeId)
|
||||
|
|
|
@ -20,7 +20,7 @@ package io.bisq.core.btc;
|
|||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import io.bisq.common.util.Utilities;
|
||||
import io.bisq.core.btc.wallet.WalletUtils;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
|
@ -44,7 +44,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
*/
|
||||
@EqualsAndHashCode
|
||||
@Slf4j
|
||||
public final class AddressEntry implements Persistable {
|
||||
public final class AddressEntry implements PersistablePayload {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package io.bisq.core.btc;
|
|||
import com.google.inject.Inject;
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistableEnvelope;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import lombok.Getter;
|
||||
|
@ -40,7 +40,7 @@ import java.util.stream.Stream;
|
|||
*/
|
||||
@ToString
|
||||
@Slf4j
|
||||
public final class AddressEntryList implements Persistable {
|
||||
public final class AddressEntryList implements PersistableEnvelope {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
|
@ -120,7 +120,7 @@ public final class AddressEntryList implements Persistable {
|
|||
|
||||
@Override
|
||||
public Message toProtoMessage() {
|
||||
final PB.Persistable build = PB.Persistable.newBuilder().setAddressEntryList(PB.AddressEntryList.newBuilder()
|
||||
final PB.DiscEnvelope build = PB.DiscEnvelope.newBuilder().setAddressEntryList(PB.AddressEntryList.newBuilder()
|
||||
.addAllAddressEntry(stream()
|
||||
.map(addressEntry -> ((PB.AddressEntry) addressEntry.toProtoMessage()))
|
||||
.collect(Collectors.toList())))
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
package io.bisq.core.btc.data;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bisq.common.Payload;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.NetworkPayload;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.bouncycastle.util.encoders.Hex;
|
||||
|
@ -28,10 +28,7 @@ import javax.annotation.concurrent.Immutable;
|
|||
|
||||
@EqualsAndHashCode
|
||||
@Immutable
|
||||
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;
|
||||
|
||||
public final class RawTransactionInput implements NetworkPayload, PersistablePayload {
|
||||
// Payload
|
||||
public final long index;
|
||||
public final byte[] parentTransaction;
|
||||
|
|
|
@ -23,7 +23,7 @@ import com.google.common.util.concurrent.SettableFuture;
|
|||
import com.google.inject.Inject;
|
||||
import io.bisq.common.UserThread;
|
||||
import io.bisq.common.handlers.ErrorMessageHandler;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.common.util.Utilities;
|
||||
import io.bisq.core.dao.blockchain.exceptions.BlockNotConnectingException;
|
||||
import io.bisq.core.dao.blockchain.json.JsonChainStateExporter;
|
||||
|
@ -162,9 +162,9 @@ public class BsqFullNode extends BsqNode {
|
|||
}
|
||||
|
||||
// TODO use handler class
|
||||
private void onMessage(Msg msg, Connection connection) {
|
||||
if (msg instanceof GetBsqBlocksRequest && connection.getPeersNodeAddressOptional().isPresent()) {
|
||||
GetBsqBlocksRequest getBsqBlocksRequest = (GetBsqBlocksRequest) msg;
|
||||
private void onMessage(NetworkEnvelope wireEnvelope, Connection connection) {
|
||||
if (wireEnvelope instanceof GetBsqBlocksRequest && connection.getPeersNodeAddressOptional().isPresent()) {
|
||||
GetBsqBlocksRequest getBsqBlocksRequest = (GetBsqBlocksRequest) wireEnvelope;
|
||||
final NodeAddress peersNodeAddress = connection.getPeersNodeAddressOptional().get();
|
||||
log.info("Received getBsqBlocksRequest with data: {} from {}",
|
||||
getBsqBlocksRequest.getFromBlockHeight(), peersNodeAddress);
|
||||
|
|
|
@ -23,7 +23,7 @@ import com.google.common.util.concurrent.SettableFuture;
|
|||
import com.google.inject.Inject;
|
||||
import io.bisq.common.UserThread;
|
||||
import io.bisq.common.handlers.ErrorMessageHandler;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.common.util.Utilities;
|
||||
import io.bisq.core.dao.blockchain.exceptions.BlockNotConnectingException;
|
||||
import io.bisq.core.dao.blockchain.p2p.GetBsqBlocksRequest;
|
||||
|
@ -133,9 +133,10 @@ public class BsqLiteNode extends BsqNode {
|
|||
// server delivered 5 times the GetBsqBlocksResponse. after restart it was ok again.
|
||||
// so issue is on fullnode side...
|
||||
byte[] pastRequests;
|
||||
private void onMessage(Msg msg, Connection connection) {
|
||||
if (msg instanceof GetBsqBlocksResponse && connection.getPeersNodeAddressOptional().isPresent()) {
|
||||
GetBsqBlocksResponse getBsqBlocksResponse = (GetBsqBlocksResponse) msg;
|
||||
|
||||
private void onMessage(NetworkEnvelope wireEnvelope, Connection connection) {
|
||||
if (wireEnvelope instanceof GetBsqBlocksResponse && connection.getPeersNodeAddressOptional().isPresent()) {
|
||||
GetBsqBlocksResponse getBsqBlocksResponse = (GetBsqBlocksResponse) wireEnvelope;
|
||||
byte[] bsqBlocksBytes = getBsqBlocksResponse.getBsqBlocksBytes();
|
||||
if (Arrays.equals(pastRequests, bsqBlocksBytes)) {
|
||||
log.error("We got that message already. That should not happen.");
|
||||
|
@ -162,8 +163,8 @@ public class BsqLiteNode extends BsqNode {
|
|||
throwable.printStackTrace();
|
||||
}
|
||||
});
|
||||
} else if (parseBlockchainComplete && msg instanceof NewBsqBlockBroadcastMsg) {
|
||||
NewBsqBlockBroadcastMsg newBsqBlockBroadcastMsg = (NewBsqBlockBroadcastMsg) msg;
|
||||
} else if (parseBlockchainComplete && wireEnvelope instanceof NewBsqBlockBroadcastMsg) {
|
||||
NewBsqBlockBroadcastMsg newBsqBlockBroadcastMsg = (NewBsqBlockBroadcastMsg) wireEnvelope;
|
||||
byte[] bsqBlockBytes = newBsqBlockBroadcastMsg.getBsqBlockBytes();
|
||||
BsqBlock bsqBlock = Utilities.<BsqBlock>deserialize(bsqBlockBytes);
|
||||
// Be safe and reset all mutable data in case the provider would not have done it
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package io.bisq.core.dao.blockchain.p2p;
|
||||
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.DirectMsg;
|
||||
import lombok.Getter;
|
||||
|
@ -22,13 +22,13 @@ public final class GetBsqBlocksRequest implements DirectMsg {
|
|||
|
||||
|
||||
@Override
|
||||
public PB.Msg toProtoMsg() {
|
||||
public PB.WireEnvelope toProtoMsg() {
|
||||
final PB.GetBsqBlocksRequest.Builder builder = PB.GetBsqBlocksRequest.newBuilder()
|
||||
.setFromBlockHeight(fromBlockHeight);
|
||||
return Msg.getMsgBuilder().setGetBsqBlocksRequest(builder).build();
|
||||
return NetworkEnvelope.getMsgBuilder().setGetBsqBlocksRequest(builder).build();
|
||||
}
|
||||
|
||||
public static Msg fromProto(PB.Msg msg) {
|
||||
public static NetworkEnvelope fromProto(PB.WireEnvelope msg) {
|
||||
return new GetBsqBlocksRequest(msg.getGetBsqBlocksRequest().getFromBlockHeight());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package io.bisq.core.dao.blockchain.p2p;
|
|||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.DirectMsg;
|
||||
import io.bisq.network.p2p.ExtendedDataSizePermission;
|
||||
|
@ -24,13 +24,13 @@ public final class GetBsqBlocksResponse implements DirectMsg, ExtendedDataSizePe
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Msg toProtoMsg() {
|
||||
public PB.WireEnvelope toProtoMsg() {
|
||||
final PB.GetBsqBlocksResponse.Builder builder = PB.GetBsqBlocksResponse.newBuilder()
|
||||
.setBsqBlocksBytes(ByteString.copyFrom(bsqBlocksBytes));
|
||||
return Msg.getMsgBuilder().setGetBsqBlocksResponse(builder).build();
|
||||
return NetworkEnvelope.getMsgBuilder().setGetBsqBlocksResponse(builder).build();
|
||||
}
|
||||
|
||||
public static Msg fromProto(PB.Msg msg) {
|
||||
public static NetworkEnvelope fromProto(PB.WireEnvelope msg) {
|
||||
return new GetBsqBlocksResponse(msg.getGetBsqBlocksResponse().getBsqBlocksBytes().toByteArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package io.bisq.core.dao.blockchain.p2p;
|
|||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.storage.messages.BroadcastMsg;
|
||||
import lombok.Getter;
|
||||
|
@ -19,10 +19,10 @@ public final class NewBsqBlockBroadcastMsg extends BroadcastMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Msg toProtoMsg() {
|
||||
public PB.WireEnvelope toProtoMsg() {
|
||||
final PB.NewBsqBlockBroadcastMsg.Builder builder = PB.NewBsqBlockBroadcastMsg.newBuilder()
|
||||
.setBsqBlockBytes(ByteString.copyFrom(bsqBlockBytes));
|
||||
return Msg.getMsgBuilder().setNewBsqBlockBroadcastMsg(builder).build();
|
||||
return NetworkEnvelope.getMsgBuilder().setNewBsqBlockBroadcastMsg(builder).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,7 +30,7 @@ public final class NewBsqBlockBroadcastMsg extends BroadcastMsg {
|
|||
return toProtoMsg().getNewBsqBlockBroadcastMsg();
|
||||
}
|
||||
|
||||
public static Msg fromProto(PB.Msg envelope) {
|
||||
public static NetworkEnvelope fromProto(PB.WireEnvelope envelope) {
|
||||
PB.NewBsqBlockBroadcastMsg msg = envelope.getNewBsqBlockBroadcastMsg();
|
||||
return new NewBsqBlockBroadcastMsg(msg.getBsqBlockBytes().toByteArray());
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.google.common.util.concurrent.SettableFuture;
|
|||
import io.bisq.common.Timer;
|
||||
import io.bisq.common.UserThread;
|
||||
import io.bisq.common.app.Log;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.common.util.Utilities;
|
||||
import io.bisq.core.dao.blockchain.vo.BsqBlock;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
|
@ -122,13 +122,13 @@ class RequestBsqBlocksHandler implements MessageListener {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void onMessage(Msg msg, Connection connection) {
|
||||
public void onMessage(NetworkEnvelope wireEnvelope, Connection connection) {
|
||||
if (connection.getPeersNodeAddressOptional().isPresent() &&
|
||||
connection.getPeersNodeAddressOptional().get().equals(peersNodeAddress)) {
|
||||
if (msg instanceof GetBsqBlocksResponse) {
|
||||
Log.traceCall(msg.toString() + "\n\tconnection=" + connection);
|
||||
if (wireEnvelope instanceof GetBsqBlocksResponse) {
|
||||
Log.traceCall(wireEnvelope.toString() + "\n\tconnection=" + connection);
|
||||
if (!stopped) {
|
||||
GetBsqBlocksResponse getBsqBlocksResponse = (GetBsqBlocksResponse) msg;
|
||||
GetBsqBlocksResponse getBsqBlocksResponse = (GetBsqBlocksResponse) wireEnvelope;
|
||||
stopTimeoutTimer();
|
||||
checkArgument(connection.getPeersNodeAddressOptional().isPresent(),
|
||||
"RequestDataHandler.onMessage: connection.getPeersNodeAddressOptional() must be present " +
|
||||
|
|
|
@ -20,7 +20,7 @@ package io.bisq.core.dao.blockchain.parse;
|
|||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistableEnvelope;
|
||||
import io.bisq.common.proto.PersistenceProtoResolver;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import io.bisq.common.util.FunctionalReadWriteLock;
|
||||
|
@ -46,7 +46,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
|||
// Represents mutable state of BSQ chain data
|
||||
// We get accessed the data from different threads so we need to make sure it is thread safe.
|
||||
@Slf4j
|
||||
public class BsqChainState implements Persistable {
|
||||
public class BsqChainState implements PersistableEnvelope {
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
|
||||
|
|
|
@ -18,14 +18,14 @@
|
|||
package io.bisq.core.dao.blockchain.vo;
|
||||
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Delegate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class BsqBlock implements Persistable {
|
||||
public class BsqBlock implements PersistablePayload {
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
@Delegate
|
||||
private final BsqBlockVo bsqBlockVo;
|
||||
|
|
|
@ -19,14 +19,14 @@ package io.bisq.core.dao.blockchain.vo;
|
|||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import lombok.Value;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Value
|
||||
@Immutable
|
||||
public class BsqBlockVo implements Persistable {
|
||||
public class BsqBlockVo implements PersistablePayload {
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
private final int height;
|
||||
|
|
|
@ -19,14 +19,14 @@ package io.bisq.core.dao.blockchain.vo;
|
|||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import lombok.Value;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Value
|
||||
@Immutable
|
||||
public class SpentInfo implements Persistable {
|
||||
public class SpentInfo implements PersistablePayload {
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
private final long blockHeight;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bisq.core.dao.blockchain.vo;
|
||||
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Delegate;
|
||||
|
||||
|
@ -27,7 +27,7 @@ import java.util.List;
|
|||
import java.util.Optional;
|
||||
|
||||
@Data
|
||||
public class Tx implements Persistable {
|
||||
public class Tx implements PersistablePayload {
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
@Delegate
|
||||
|
|
|
@ -19,14 +19,14 @@ package io.bisq.core.dao.blockchain.vo;
|
|||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import lombok.Value;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Value
|
||||
@Immutable
|
||||
public class TxIdIndexTuple implements Persistable {
|
||||
public class TxIdIndexTuple implements PersistablePayload {
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
private final String txId;
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
package io.bisq.core.dao.blockchain.vo;
|
||||
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Delegate;
|
||||
|
||||
@Data
|
||||
public class TxInput implements Persistable {
|
||||
public class TxInput implements PersistablePayload {
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
@Delegate
|
||||
|
|
|
@ -19,14 +19,14 @@ package io.bisq.core.dao.blockchain.vo;
|
|||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import lombok.Value;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Value
|
||||
@Immutable
|
||||
public class TxInputVo implements Persistable {
|
||||
public class TxInputVo implements PersistablePayload {
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
private final String txId;
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
package io.bisq.core.dao.blockchain.vo;
|
||||
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Delegate;
|
||||
import org.bitcoinj.core.Utils;
|
||||
|
||||
@Data
|
||||
public class TxOutput implements Persistable {
|
||||
public class TxOutput implements PersistablePayload {
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
@Delegate
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bisq.core.dao.blockchain.vo;
|
|||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import io.bisq.common.util.JsonExclude;
|
||||
import io.bisq.core.dao.blockchain.btcd.PubKeyScript;
|
||||
import lombok.Value;
|
||||
|
@ -31,7 +31,7 @@ import javax.annotation.concurrent.Immutable;
|
|||
@Slf4j
|
||||
@Value
|
||||
@Immutable
|
||||
public class TxOutputVo implements Persistable {
|
||||
public class TxOutputVo implements PersistablePayload {
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
private final int index;
|
||||
|
|
|
@ -19,14 +19,14 @@ package io.bisq.core.dao.blockchain.vo;
|
|||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import lombok.Value;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Value
|
||||
@Immutable
|
||||
public class TxVo implements Persistable {
|
||||
public class TxVo implements PersistablePayload {
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
private final String txVersion = Version.BSQ_TX_VERSION;
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bisq.core.dao.compensation;
|
|||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
|
|||
// Represents the state of the CompensationRequest data
|
||||
@Getter
|
||||
|
||||
public final class CompensationRequest implements Persistable {
|
||||
public final class CompensationRequest implements PersistablePayload {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bisq.core.dao.compensation;
|
|||
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.inject.Inject;
|
||||
import io.bisq.common.persistence.ListPersistable;
|
||||
import io.bisq.common.persistable.PersistableList;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import io.bisq.core.btc.wallet.BsqWalletService;
|
||||
import io.bisq.core.btc.wallet.BtcWalletService;
|
||||
|
@ -50,7 +50,7 @@ public class CompensationRequestManager {
|
|||
private final BsqWalletService bsqWalletService;
|
||||
private final CompensationRequestModel model;
|
||||
private final VotingDefaultValues votingDefaultValues;
|
||||
private final Storage<ListPersistable<CompensationRequest>> compensationRequestsStorage;
|
||||
private final Storage<PersistableList<CompensationRequest>> compensationRequestsStorage;
|
||||
|
||||
private CompensationRequest selectedCompensationRequest;
|
||||
private int bestChainHeight = -1;
|
||||
|
@ -69,7 +69,7 @@ public class CompensationRequestManager {
|
|||
DaoPeriodService daoPeriodService,
|
||||
CompensationRequestModel model,
|
||||
VotingDefaultValues votingDefaultValues,
|
||||
Storage<ListPersistable<CompensationRequest>> compensationRequestsStorage) {
|
||||
Storage<PersistableList<CompensationRequest>> compensationRequestsStorage) {
|
||||
this.p2PService = p2PService;
|
||||
this.daoPeriodService = daoPeriodService;
|
||||
this.btcWalletService = btcWalletService;
|
||||
|
@ -80,7 +80,7 @@ public class CompensationRequestManager {
|
|||
|
||||
observableList = FXCollections.observableArrayList(model.getList());
|
||||
|
||||
ListPersistable<CompensationRequest> persisted = compensationRequestsStorage.initAndGetPersistedWithFileName("CompensationRequests");
|
||||
PersistableList<CompensationRequest> persisted = compensationRequestsStorage.initAndGetPersistedWithFileName("CompensationRequests");
|
||||
if (persisted != null)
|
||||
model.setPersistedCompensationRequest(persisted.getList());
|
||||
|
||||
|
@ -121,7 +121,7 @@ public class CompensationRequestManager {
|
|||
if (!contains(compensationRequestPayload)) {
|
||||
model.addCompensationRequest(new CompensationRequest(compensationRequestPayload));
|
||||
if (storeLocally)
|
||||
compensationRequestsStorage.queueUpForSave(new ListPersistable<>(model.getList()), 500);
|
||||
compensationRequestsStorage.queueUpForSave(new PersistableList<>(model.getList()), 500);
|
||||
} else {
|
||||
log.warn("We have already an item with the same CompensationRequest.");
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ package io.bisq.core.dao.compensation;
|
|||
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.crypto.Sig;
|
||||
import io.bisq.common.persistable.PersistableEnvelope;
|
||||
import io.bisq.common.util.JsonExclude;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
|
@ -51,7 +52,8 @@ import java.util.concurrent.TimeUnit;
|
|||
@Slf4j
|
||||
@Getter
|
||||
@Setter
|
||||
public final class CompensationRequestPayload implements LazyProcessedStoragePayload, PersistedStoragePayload {
|
||||
// TODO There will be another object for PersistableEnvelope
|
||||
public final class CompensationRequestPayload implements LazyProcessedStoragePayload, PersistedStoragePayload, PersistableEnvelope {
|
||||
// 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 static final long TTL = TimeUnit.DAYS.toMillis(30);
|
||||
|
|
|
@ -19,12 +19,12 @@ package io.bisq.core.dao.vote;
|
|||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import io.bisq.core.dao.compensation.CompensationRequest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public final class CompensationRequestVoteItem implements Persistable {
|
||||
public final class CompensationRequestVoteItem implements PersistablePayload {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
private static final Logger log = LoggerFactory.getLogger(CompensationRequestVoteItem.class);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bisq.core.dao.vote;
|
||||
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
|
@ -30,7 +30,7 @@ import java.util.List;
|
|||
@ToString
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Slf4j
|
||||
public final class CompensationRequestVoteItemCollection extends VoteItem implements Persistable {
|
||||
public final class CompensationRequestVoteItemCollection extends VoteItem implements PersistablePayload {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bisq.core.dao.vote;
|
||||
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
@ -29,7 +29,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
|||
|
||||
//TODO if sent over wire make final
|
||||
@Slf4j
|
||||
public class VoteItem implements Persistable {
|
||||
public class VoteItem implements PersistablePayload {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bisq.core.dao.vote;
|
|||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import lombok.Getter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -29,7 +29,7 @@ import java.util.List;
|
|||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class VoteItemsList implements Persistable {
|
||||
public final class VoteItemsList implements PersistablePayload {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
private static final Logger log = LoggerFactory.getLogger(VoteItemsList.class);
|
||||
|
|
|
@ -20,8 +20,8 @@ package io.bisq.core.dao.vote;
|
|||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.inject.Inject;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.ListPersistable;
|
||||
import io.bisq.common.proto.ProtoHelper;
|
||||
import io.bisq.common.persistable.PersistableCollectionUtil;
|
||||
import io.bisq.common.persistable.PersistableList;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import io.bisq.common.util.Utilities;
|
||||
import io.bisq.core.btc.wallet.BsqWalletService;
|
||||
|
@ -55,7 +55,7 @@ public class VotingManager {
|
|||
private final BtcWalletService btcWalletService;
|
||||
private final BsqWalletService bsqWalletService;
|
||||
private final FeeService feeService;
|
||||
private final Storage<ListPersistable<VoteItemsList>> voteItemCollectionsStorage;
|
||||
private final Storage<PersistableList<VoteItemsList>> voteItemCollectionsStorage;
|
||||
private final CompensationRequestManager compensationRequestManager;
|
||||
private final DaoPeriodService daoPeriodService;
|
||||
private final VotingDefaultValues votingDefaultValues;
|
||||
|
@ -66,7 +66,7 @@ public class VotingManager {
|
|||
public VotingManager(BtcWalletService btcWalletService,
|
||||
BsqWalletService bsqWalletService,
|
||||
FeeService feeService,
|
||||
Storage<ListPersistable<VoteItemsList>> voteItemCollectionsStorage,
|
||||
Storage<PersistableList<VoteItemsList>> voteItemCollectionsStorage,
|
||||
CompensationRequestManager compensationRequestManager,
|
||||
DaoPeriodService daoPeriodService,
|
||||
VotingDefaultValues votingDefaultValues) {
|
||||
|
@ -78,7 +78,7 @@ public class VotingManager {
|
|||
this.daoPeriodService = daoPeriodService;
|
||||
this.votingDefaultValues = votingDefaultValues;
|
||||
|
||||
ListPersistable<VoteItemsList> persisted = voteItemCollectionsStorage.initAndGetPersistedWithFileName("VoteItemCollections");
|
||||
PersistableList<VoteItemsList> persisted = voteItemCollectionsStorage.initAndGetPersistedWithFileName("VoteItemCollections");
|
||||
if (persisted != null)
|
||||
voteItemsLists.addAll(persisted.getList());
|
||||
}
|
||||
|
@ -311,10 +311,10 @@ public class VotingManager {
|
|||
//TODO check equals code
|
||||
if (!voteItemsLists.contains(voteItemsList)) {
|
||||
voteItemsLists.add(voteItemsList);
|
||||
ListPersistable<VoteItemsList> serializable = new ListPersistable<>(voteItemsLists);
|
||||
serializable.setToProto((list) -> PB.Persistable.newBuilder()
|
||||
PersistableList<VoteItemsList> serializable = new PersistableList<>(voteItemsLists);
|
||||
serializable.setToProto((list) -> PB.DiscEnvelope.newBuilder()
|
||||
.setVoteItemsList(PB.VoteItemsList.newBuilder()
|
||||
.addAllVoteItem(ProtoHelper.collectionToProto(voteItemsList.getAllVoteItemList()))).build());
|
||||
.addAllVoteItem(PersistableCollectionUtil.collectionToProto(voteItemsList.getAllVoteItemList()))).build());
|
||||
voteItemCollectionsStorage.queueUpForSave(serializable, 500);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import com.google.inject.name.Named;
|
|||
import io.bisq.common.app.DevEnv;
|
||||
import io.bisq.common.crypto.KeyRing;
|
||||
import io.bisq.core.app.AppOptionKeys;
|
||||
import io.bisq.core.user.UserModel;
|
||||
import io.bisq.core.user.User;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.P2PService;
|
||||
import io.bisq.network.p2p.storage.HashMapChangedListener;
|
||||
|
@ -47,7 +47,7 @@ public class FilterManager {
|
|||
|
||||
private final P2PService p2PService;
|
||||
private final KeyRing keyRing;
|
||||
private final UserModel userModel;
|
||||
private final User user;
|
||||
private final ObjectProperty<Filter> filterProperty = new SimpleObjectProperty<>();
|
||||
|
||||
private static final String pubKeyAsHex = DevEnv.USE_DEV_PRIVILEGE_KEYS ?
|
||||
|
@ -61,11 +61,11 @@ public class FilterManager {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public FilterManager(P2PService p2PService, KeyRing keyRing, UserModel userModel,
|
||||
public FilterManager(P2PService p2PService, KeyRing keyRing, User user,
|
||||
@Named(AppOptionKeys.IGNORE_DEV_MSG_KEY) boolean ignoreDevMsg) {
|
||||
this.p2PService = p2PService;
|
||||
this.keyRing = keyRing;
|
||||
this.userModel = userModel;
|
||||
this.user = user;
|
||||
|
||||
if (!ignoreDevMsg) {
|
||||
p2PService.addHashSetChangedListener(new HashMapChangedListener() {
|
||||
|
@ -105,13 +105,13 @@ public class FilterManager {
|
|||
|
||||
public boolean addFilterMessageIfKeyIsValid(Filter filter, String privKeyString) {
|
||||
// if there is a previous message we remove that first
|
||||
if (userModel.getDevelopersFilter() != null)
|
||||
if (user.getDevelopersFilter() != null)
|
||||
removeFilterMessageIfKeyIsValid(privKeyString);
|
||||
|
||||
boolean isKeyValid = isKeyValid(privKeyString);
|
||||
if (isKeyValid) {
|
||||
signAndAddSignatureToFilter(filter);
|
||||
userModel.setDevelopersFilter(filter);
|
||||
user.setDevelopersFilter(filter);
|
||||
|
||||
boolean result = p2PService.addData(filter, true);
|
||||
if (result)
|
||||
|
@ -123,12 +123,12 @@ public class FilterManager {
|
|||
|
||||
public boolean removeFilterMessageIfKeyIsValid(String privKeyString) {
|
||||
if (isKeyValid(privKeyString)) {
|
||||
Filter filter = userModel.getDevelopersFilter();
|
||||
Filter filter = user.getDevelopersFilter();
|
||||
if (filter == null) {
|
||||
log.warn("Developers filter is null");
|
||||
} else if (p2PService.removeData(filter, true)) {
|
||||
log.trace("Remove filter from network was successful. FilterMessage = " + filter);
|
||||
userModel.setDevelopersFilter(null);
|
||||
user.setDevelopersFilter(null);
|
||||
} else {
|
||||
log.warn("Filter remove failed");
|
||||
}
|
||||
|
@ -172,6 +172,6 @@ public class FilterManager {
|
|||
|
||||
@Nullable
|
||||
public Filter getDevelopersFilter() {
|
||||
return userModel.getDevelopersFilter();
|
||||
return user.getDevelopersFilter();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@ import io.bisq.common.locale.CurrencyUtil;
|
|||
import io.bisq.common.monetary.Altcoin;
|
||||
import io.bisq.common.monetary.Price;
|
||||
import io.bisq.common.monetary.Volume;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.network.NetworkPayload;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import io.bisq.common.util.JsonExclude;
|
||||
import io.bisq.common.util.MathUtils;
|
||||
import io.bisq.common.util.Utilities;
|
||||
|
@ -28,7 +29,6 @@ import org.bitcoinj.core.Coin;
|
|||
import org.bitcoinj.utils.Fiat;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.Serializable;
|
||||
import java.security.PublicKey;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -38,7 +38,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Slf4j
|
||||
public class Offer implements Persistable, Serializable {
|
||||
public class Offer implements NetworkPayload, PersistablePayload {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Enums
|
||||
|
|
|
@ -25,7 +25,7 @@ import io.bisq.common.app.Log;
|
|||
import io.bisq.common.crypto.KeyRing;
|
||||
import io.bisq.common.handlers.ErrorMessageHandler;
|
||||
import io.bisq.common.handlers.ResultHandler;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.common.proto.PersistenceProtoResolver;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import io.bisq.core.btc.AddressEntry;
|
||||
|
@ -42,7 +42,7 @@ import io.bisq.core.trade.TradableList;
|
|||
import io.bisq.core.trade.closed.ClosedTradableManager;
|
||||
import io.bisq.core.trade.handlers.TransactionResultHandler;
|
||||
import io.bisq.core.user.Preferences;
|
||||
import io.bisq.core.user.UserModel;
|
||||
import io.bisq.core.user.User;
|
||||
import io.bisq.core.util.Validator;
|
||||
import io.bisq.network.p2p.*;
|
||||
import io.bisq.network.p2p.peers.PeerManager;
|
||||
|
@ -71,7 +71,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
|||
private static final long REFRESH_INTERVAL_MS = TimeUnit.MINUTES.toMillis(DevEnv.STRESS_TEST_MODE ? 4 : 4);
|
||||
|
||||
private final KeyRing keyRing;
|
||||
private final UserModel userModel;
|
||||
private final User user;
|
||||
private final P2PService p2PService;
|
||||
private final BtcWalletService walletService;
|
||||
private final TradeWalletService tradeWalletService;
|
||||
|
@ -92,7 +92,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
|||
|
||||
@Inject
|
||||
public OpenOfferManager(KeyRing keyRing,
|
||||
UserModel userModel,
|
||||
User user,
|
||||
P2PService p2PService,
|
||||
BtcWalletService walletService,
|
||||
TradeWalletService tradeWalletService,
|
||||
|
@ -104,7 +104,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
|||
PersistenceProtoResolver persistenceProtoResolver,
|
||||
@Named(Storage.STORAGE_DIR) File storageDir) {
|
||||
this.keyRing = keyRing;
|
||||
this.userModel = userModel;
|
||||
this.user = user;
|
||||
this.p2PService = p2PService;
|
||||
this.walletService = walletService;
|
||||
this.tradeWalletService = tradeWalletService;
|
||||
|
@ -191,9 +191,9 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
|||
// Handler for incoming offer availability requests
|
||||
// We get an encrypted message but don't do the signature check as we don't know the peer yet.
|
||||
// A basic sig check is in done also at decryption time
|
||||
Msg msg = decryptedMsgWithPubKey.msg;
|
||||
if (msg instanceof OfferAvailabilityRequest)
|
||||
handleOfferAvailabilityRequest((OfferAvailabilityRequest) msg, peerNodeAddress);
|
||||
NetworkEnvelope wireEnvelope = decryptedMsgWithPubKey.wireEnvelope;
|
||||
if (wireEnvelope instanceof OfferAvailabilityRequest)
|
||||
handleOfferAvailabilityRequest((OfferAvailabilityRequest) wireEnvelope, peerNodeAddress);
|
||||
}
|
||||
|
||||
|
||||
|
@ -271,7 +271,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
|||
tradeWalletService,
|
||||
bsqWalletService,
|
||||
offerBookService,
|
||||
userModel);
|
||||
user);
|
||||
PlaceOfferProtocol placeOfferProtocol = new PlaceOfferProtocol(
|
||||
model,
|
||||
transaction -> {
|
||||
|
@ -382,7 +382,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
|||
availabilityResult = AvailabilityResult.AVAILABLE;
|
||||
|
||||
// TODO mediators not impl yet
|
||||
List<NodeAddress> acceptedArbitrators = userModel.getAcceptedArbitratorAddresses();
|
||||
List<NodeAddress> acceptedArbitrators = user.getAcceptedArbitratorAddresses();
|
||||
if (acceptedArbitrators != null && !acceptedArbitrators.isEmpty()) {
|
||||
// Check also tradePrice to avoid failures after taker fee is paid caused by a too big difference
|
||||
// in trade price between the peers. Also here poor connectivity might cause market price API connection
|
||||
|
|
|
@ -21,7 +21,7 @@ import io.bisq.common.Timer;
|
|||
import io.bisq.common.UserThread;
|
||||
import io.bisq.common.handlers.ErrorMessageHandler;
|
||||
import io.bisq.common.handlers.ResultHandler;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.common.taskrunner.TaskRunner;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.availability.tasks.ProcessOfferAvailabilityResponse;
|
||||
|
@ -57,14 +57,14 @@ public class OfferAvailabilityProtocol {
|
|||
this.errorMessageHandler = errorMessageHandler;
|
||||
|
||||
decryptedDirectMessageListener = (decryptedMessageWithPubKey, peersNodeAddress) -> {
|
||||
Msg msg = decryptedMessageWithPubKey.msg;
|
||||
if (msg instanceof OfferMsg) {
|
||||
OfferMsg offerMessage = (OfferMsg) msg;
|
||||
NetworkEnvelope wireEnvelope = decryptedMessageWithPubKey.wireEnvelope;
|
||||
if (wireEnvelope instanceof OfferMsg) {
|
||||
OfferMsg offerMessage = (OfferMsg) wireEnvelope;
|
||||
Validator.nonEmptyStringOf(offerMessage.offerId);
|
||||
if (msg instanceof OfferAvailabilityResponse
|
||||
if (wireEnvelope instanceof OfferAvailabilityResponse
|
||||
&& model.offer.getId().equals(offerMessage.offerId)) {
|
||||
log.trace("handle OfferAvailabilityResponse = " + msg.getClass().getSimpleName() + " from " + peersNodeAddress);
|
||||
handle((OfferAvailabilityResponse) msg);
|
||||
log.trace("handle OfferAvailabilityResponse = " + wireEnvelope.getClass().getSimpleName() + " from " + peersNodeAddress);
|
||||
handle((OfferAvailabilityResponse) wireEnvelope);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -20,7 +20,7 @@ package io.bisq.core.offer.messages;
|
|||
import io.bisq.common.app.Capabilities;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.crypto.PubKeyRing;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.SupportedCapabilitiesMsg;
|
||||
|
||||
|
@ -62,8 +62,8 @@ public final class OfferAvailabilityRequest extends OfferMsg implements Supporte
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Msg toProtoMsg() {
|
||||
return Msg.getMsgBuilder()
|
||||
public PB.WireEnvelope toProtoMsg() {
|
||||
return NetworkEnvelope.getMsgBuilder()
|
||||
.setOfferAvailabilityRequest(PB.OfferAvailabilityRequest.newBuilder()
|
||||
.setOfferId(offerId)
|
||||
.setPubKeyRing(pubKeyRing.toProtoMessage())
|
||||
|
|
|
@ -20,7 +20,7 @@ package io.bisq.core.offer.messages;
|
|||
|
||||
import io.bisq.common.app.Capabilities;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.core.offer.AvailabilityResult;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.SupportedCapabilitiesMsg;
|
||||
|
@ -58,8 +58,8 @@ public final class OfferAvailabilityResponse extends OfferMsg implements Support
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Msg toProtoMsg() {
|
||||
PB.Msg.Builder msgBuilder = Msg.getMsgBuilder();
|
||||
public PB.WireEnvelope toProtoMsg() {
|
||||
PB.WireEnvelope.Builder msgBuilder = NetworkEnvelope.getMsgBuilder();
|
||||
return msgBuilder.setOfferAvailabilityResponse(PB.OfferAvailabilityResponse.newBuilder().setMessageVersion(getMsgVersion())
|
||||
.setOfferId(offerId)
|
||||
.setAvailabilityResult(PB.AvailabilityResult.valueOf(availabilityResult.name()))
|
||||
|
|
|
@ -23,7 +23,7 @@ import io.bisq.core.btc.wallet.BtcWalletService;
|
|||
import io.bisq.core.btc.wallet.TradeWalletService;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferBookService;
|
||||
import io.bisq.core.user.UserModel;
|
||||
import io.bisq.core.user.User;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -41,7 +41,7 @@ public class PlaceOfferModel implements Model {
|
|||
private final TradeWalletService tradeWalletService;
|
||||
private final BsqWalletService bsqWalletService;
|
||||
private final OfferBookService offerBookService;
|
||||
private final UserModel userModel;
|
||||
private final User user;
|
||||
|
||||
// Mutable
|
||||
@Setter
|
||||
|
@ -56,7 +56,7 @@ public class PlaceOfferModel implements Model {
|
|||
TradeWalletService tradeWalletService,
|
||||
BsqWalletService bsqWalletService,
|
||||
OfferBookService offerBookService,
|
||||
UserModel userModel) {
|
||||
User user) {
|
||||
this.offer = offer;
|
||||
this.reservedFundsForOffer = reservedFundsForOffer;
|
||||
this.useSavingsWallet = useSavingsWallet;
|
||||
|
@ -64,7 +64,7 @@ public class PlaceOfferModel implements Model {
|
|||
this.tradeWalletService = tradeWalletService;
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.offerBookService = offerBookService;
|
||||
this.userModel = userModel;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -55,10 +55,10 @@ public class CreateMakerFeeTx extends Task<PlaceOfferModel> {
|
|||
try {
|
||||
runInterceptHook();
|
||||
|
||||
NodeAddress selectedArbitratorNodeAddress = ArbitratorSelectionRule.select(model.getUserModel().getAcceptedArbitratorAddresses(),
|
||||
NodeAddress selectedArbitratorNodeAddress = ArbitratorSelectionRule.select(model.getUser().getAcceptedArbitratorAddresses(),
|
||||
model.getOffer());
|
||||
log.debug("selectedArbitratorAddress " + selectedArbitratorNodeAddress);
|
||||
Arbitrator selectedArbitrator = model.getUserModel().getAcceptedArbitratorByAddress(selectedArbitratorNodeAddress);
|
||||
Arbitrator selectedArbitrator = model.getUser().getAcceptedArbitratorByAddress(selectedArbitratorNodeAddress);
|
||||
checkNotNull(selectedArbitrator, "selectedArbitrator must not be null at CreateOfferFeeTx");
|
||||
BtcWalletService walletService = model.getWalletService();
|
||||
String id = offer.getId();
|
||||
|
|
|
@ -19,8 +19,8 @@ package io.bisq.core.payment;
|
|||
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.locale.TradeCurrency;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.proto.ProtoHelper;
|
||||
import io.bisq.common.persistable.PersistableCollectionUtil;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import io.bisq.core.payment.payload.PaymentAccountPayload;
|
||||
import io.bisq.core.payment.payload.PaymentMethod;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
|
@ -37,7 +37,7 @@ import java.util.stream.Collectors;
|
|||
@EqualsAndHashCode
|
||||
@ToString
|
||||
@Slf4j
|
||||
public abstract class PaymentAccount implements Persistable {
|
||||
public abstract class PaymentAccount implements PersistablePayload {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
|
@ -121,7 +121,7 @@ public abstract class PaymentAccount implements Persistable {
|
|||
.setCreationDate(creationDate)
|
||||
.setPaymentMethod(paymentMethod.toProtoMessage())
|
||||
.setAccountName(accountName)
|
||||
.addAllTradeCurrencies(ProtoHelper.collectionToProto(tradeCurrencies))
|
||||
.addAllTradeCurrencies(PersistableCollectionUtil.collectionToProto(tradeCurrencies))
|
||||
.setPaymentAccountPayload((PB.PaymentAccountPayload) paymentAccountPayload.toProtoMessage());
|
||||
Optional.ofNullable(selectedTradeCurrency).ifPresent(selectedTradeCurrency -> builder.setSelectedTradeCurrency((PB.TradeCurrency) selectedTradeCurrency.toProtoMessage()));
|
||||
return builder.build();
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
|
||||
package io.bisq.core.payment.payload;
|
||||
|
||||
import io.bisq.common.Payload;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.locale.CountryUtil;
|
||||
import io.bisq.common.network.NetworkPayload;
|
||||
import io.bisq.core.proto.ProtoUtil;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -32,7 +32,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
@EqualsAndHashCode
|
||||
@ToString
|
||||
@Slf4j
|
||||
public abstract class PaymentAccountPayload implements Payload {
|
||||
public abstract class PaymentAccountPayload implements NetworkPayload {
|
||||
// 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;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bisq.core.payment.payload;
|
|||
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.locale.Res;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
|
@ -40,7 +40,7 @@ import java.util.Optional;
|
|||
@Getter
|
||||
@ToString
|
||||
@Slf4j
|
||||
public final class PaymentMethod implements Persistable, Comparable {
|
||||
public final class PaymentMethod implements PersistablePayload, Comparable {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ package io.bisq.core.proto;
|
|||
|
||||
import com.google.inject.Provider;
|
||||
import io.bisq.common.locale.*;
|
||||
import io.bisq.common.persistence.ListPersistable;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistableEnvelope;
|
||||
import io.bisq.common.persistable.PersistableList;
|
||||
import io.bisq.common.proto.PersistenceProtoResolver;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import io.bisq.core.btc.AddressEntry;
|
||||
|
@ -16,7 +16,7 @@ import io.bisq.core.trade.*;
|
|||
import io.bisq.core.trade.statistics.TradeStatistics;
|
||||
import io.bisq.core.user.BlockChainExplorer;
|
||||
import io.bisq.core.user.Preferences;
|
||||
import io.bisq.core.user.User;
|
||||
import io.bisq.core.user.UserPayload;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.peers.peerexchange.Peer;
|
||||
import io.bisq.network.p2p.storage.SequenceNumberMap;
|
||||
|
@ -75,7 +75,7 @@ public class CoreDiskProtoResolver implements PersistenceProtoResolver {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Optional<Persistable> fromProto(PB.Persistable persistable) {
|
||||
public Optional<PersistableEnvelope> fromProto(PB.DiscEnvelope persistable) {
|
||||
if (Objects.isNull(persistable)) {
|
||||
log.warn("fromProtoBuf called with empty disk persistable.");
|
||||
return Optional.empty();
|
||||
|
@ -83,7 +83,7 @@ public class CoreDiskProtoResolver implements PersistenceProtoResolver {
|
|||
|
||||
log.debug("Convert protobuffer disk persistable: {}", persistable.getMessageCase());
|
||||
|
||||
Persistable result = null;
|
||||
PersistableEnvelope result = null;
|
||||
switch (persistable.getMessageCase()) {
|
||||
case ADDRESS_ENTRY_LIST:
|
||||
result = fillAddressEntryList(persistable, addressEntryListProvider.get());
|
||||
|
@ -98,13 +98,14 @@ public class CoreDiskProtoResolver implements PersistenceProtoResolver {
|
|||
result = getPeersList(persistable.getPeersList());
|
||||
break;
|
||||
case COMPENSATION_REQUEST_PAYLOAD:
|
||||
// TODO There will be another object for PersistableEnvelope
|
||||
result = CompensationRequestPayload.fromProto(persistable.getCompensationRequestPayload());
|
||||
break;
|
||||
case PREFERENCES:
|
||||
result = fillPreferences(persistable, preferencesProvider.get());
|
||||
break;
|
||||
case USER:
|
||||
result = User.fromProto(persistable.getUser());
|
||||
case USER_PAYLOAD:
|
||||
result = UserPayload.fromProto(persistable.getUserPayload());
|
||||
break;
|
||||
case SEQUENCE_NUMBER_MAP:
|
||||
result = SequenceNumberMap.fromProto(persistable.getSequenceNumberMap());
|
||||
|
@ -117,21 +118,21 @@ public class CoreDiskProtoResolver implements PersistenceProtoResolver {
|
|||
return Optional.ofNullable(result);
|
||||
}
|
||||
|
||||
private Persistable getTradableList(PB.TradableList tradableList) {
|
||||
private PersistableEnvelope getTradableList(PB.TradableList tradableList) {
|
||||
return TradableList.fromProto(tradableList, openOfferStorage, buyerAsMakerTradeStorage, buyerAsTakerTradeStorage, sellerAsMakerTradeStorage, sellerAsTakerTradeStorage, btcWalletService.get());
|
||||
}
|
||||
|
||||
private Persistable getTradeStatisticsList(PB.TradeStatisticsList tradeStatisticsList) {
|
||||
return new ListPersistable<>(tradeStatisticsList.getTradeStatisticsList().stream()
|
||||
private PersistableEnvelope getTradeStatisticsList(PB.TradeStatisticsList tradeStatisticsList) {
|
||||
return new PersistableList<>(tradeStatisticsList.getTradeStatisticsList().stream()
|
||||
.map(TradeStatistics::fromProto).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
private Persistable getPeersList(PB.PeersList envelope) {
|
||||
return new ListPersistable<>(envelope.getPeersList().stream().map(Peer::fromProto)
|
||||
private PersistableEnvelope getPeersList(PB.PeersList envelope) {
|
||||
return new PersistableList<>(envelope.getPeersList().stream().map(Peer::fromProto)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
private Preferences fillPreferences(PB.Persistable envelope, Preferences preferences) {
|
||||
private Preferences fillPreferences(PB.DiscEnvelope envelope, Preferences preferences) {
|
||||
final PB.Preferences env = envelope.getPreferences();
|
||||
preferences.setUserLanguage(env.getUserLanguage());
|
||||
PB.Country userCountry = env.getUserCountry();
|
||||
|
@ -187,7 +188,7 @@ public class CoreDiskProtoResolver implements PersistenceProtoResolver {
|
|||
return new Locale(locale.getLanguage(), locale.getCountry(), locale.getVariant());
|
||||
}
|
||||
|
||||
private AddressEntryList fillAddressEntryList(PB.Persistable envelope, AddressEntryList addressEntryList) {
|
||||
private AddressEntryList fillAddressEntryList(PB.DiscEnvelope envelope, AddressEntryList addressEntryList) {
|
||||
envelope.getAddressEntryList().getAddressEntryList().stream().forEach(addressEntry -> {
|
||||
final AddressEntry entry = new AddressEntry(addressEntry.getPubKey().toByteArray(),
|
||||
addressEntry.getPubKeyHash().toByteArray(),
|
||||
|
|
|
@ -2,7 +2,7 @@ package io.bisq.core.proto;
|
|||
|
||||
import io.bisq.common.crypto.PubKeyRing;
|
||||
import io.bisq.common.crypto.SealedAndSigned;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.common.proto.NetworkProtoResolver;
|
||||
import io.bisq.core.alert.Alert;
|
||||
import io.bisq.core.alert.PrivateNotificationMsg;
|
||||
|
@ -54,7 +54,7 @@ import javax.inject.Inject;
|
|||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static io.bisq.generated.protobuffer.PB.Msg.MessageCase.*;
|
||||
import static io.bisq.generated.protobuffer.PB.WireEnvelope.MessageCase.*;
|
||||
|
||||
/**
|
||||
* If the Messages class is giving errors in IntelliJ, you should change the IntelliJ IDEA Platform Properties file,
|
||||
|
@ -80,7 +80,7 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public Optional<Msg> fromProto(PB.Msg msg) {
|
||||
public Optional<NetworkEnvelope> fromProto(PB.WireEnvelope msg) {
|
||||
if (Objects.isNull(msg)) {
|
||||
log.warn("fromProtoBuf called with empty msg.");
|
||||
return Optional.empty();
|
||||
|
@ -93,7 +93,7 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
|
|||
log.trace("Convert protobuffer msg: {}", msg.toString());
|
||||
}
|
||||
|
||||
Msg result = null;
|
||||
NetworkEnvelope result = null;
|
||||
switch (msg.getMessageCase()) {
|
||||
case PING:
|
||||
result = getPing(msg);
|
||||
|
@ -195,25 +195,25 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
|
|||
// Msg
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private static Msg getOfferAvailabilityRequest(PB.Msg envelope) {
|
||||
private static NetworkEnvelope getOfferAvailabilityRequest(PB.WireEnvelope envelope) {
|
||||
PB.OfferAvailabilityRequest msg = envelope.getOfferAvailabilityRequest();
|
||||
return new OfferAvailabilityRequest(msg.getOfferId(), PubKeyRing.fromProto(msg.getPubKeyRing()), msg.getTakersTradePrice());
|
||||
}
|
||||
|
||||
private static Msg getPrivateNotificationMessage(PB.PrivateNotificationMessage privateNotificationMessage) {
|
||||
private static NetworkEnvelope getPrivateNotificationMessage(PB.PrivateNotificationMessage privateNotificationMessage) {
|
||||
return new PrivateNotificationMsg(getPrivateNotification(privateNotificationMessage.getPrivateNotificationPayload()),
|
||||
NodeAddress.fromProto(privateNotificationMessage.getMyNodeAddress()),
|
||||
privateNotificationMessage.getUid());
|
||||
}
|
||||
|
||||
private static Msg getPayoutTxPublishedMessage(PB.PayoutTxPublishedMessage payoutTxPublishedMessage) {
|
||||
private static NetworkEnvelope getPayoutTxPublishedMessage(PB.PayoutTxPublishedMessage payoutTxPublishedMessage) {
|
||||
return new PayoutTxPublishedMsg(payoutTxPublishedMessage.getTradeId(),
|
||||
payoutTxPublishedMessage.getPayoutTx().toByteArray(),
|
||||
NodeAddress.fromProto(payoutTxPublishedMessage.getSenderNodeAddress()),
|
||||
payoutTxPublishedMessage.getUid());
|
||||
}
|
||||
|
||||
private static Msg getOfferAvailabilityResponse(PB.Msg envelope) {
|
||||
private static NetworkEnvelope getOfferAvailabilityResponse(PB.WireEnvelope envelope) {
|
||||
PB.OfferAvailabilityResponse msg = envelope.getOfferAvailabilityResponse();
|
||||
return new OfferAvailabilityResponse(msg.getOfferId(),
|
||||
AvailabilityResult.valueOf(
|
||||
|
@ -222,11 +222,11 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
|
|||
|
||||
|
||||
@NotNull
|
||||
private static Msg getPrefixedSealedAndSignedMessage(PB.Msg envelope) {
|
||||
private static NetworkEnvelope getPrefixedSealedAndSignedMessage(PB.WireEnvelope envelope) {
|
||||
return getPrefixedSealedAndSignedMessage(envelope.getPrefixedSealedAndSignedMessage());
|
||||
}
|
||||
|
||||
private static Msg getFiatTransferStartedMessage(PB.FiatTransferStartedMessage fiatTransferStartedMessage) {
|
||||
private static NetworkEnvelope getFiatTransferStartedMessage(PB.FiatTransferStartedMessage fiatTransferStartedMessage) {
|
||||
return new FiatTransferStartedMsg(fiatTransferStartedMessage.getTradeId(),
|
||||
fiatTransferStartedMessage.getBuyerPayoutAddress(),
|
||||
NodeAddress.fromProto(fiatTransferStartedMessage.getSenderNodeAddress()),
|
||||
|
@ -235,7 +235,7 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
|
|||
);
|
||||
}
|
||||
|
||||
private static Msg getPublishDepositTxRequest(PB.PublishDepositTxRequest publishDepositTxRequest) {
|
||||
private static NetworkEnvelope getPublishDepositTxRequest(PB.PublishDepositTxRequest publishDepositTxRequest) {
|
||||
List<RawTransactionInput> rawTransactionInputs = publishDepositTxRequest.getMakerInputsList().stream()
|
||||
.map(rawTransactionInput -> new RawTransactionInput(rawTransactionInput.getIndex(),
|
||||
rawTransactionInput.getParentTransaction().toByteArray(), rawTransactionInput.getValue()))
|
||||
|
@ -254,7 +254,7 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
|
|||
publishDepositTxRequest.getUid());
|
||||
}
|
||||
|
||||
private static Msg getPayDepositRequest(PB.PayDepositRequest payDepositRequest) {
|
||||
private static NetworkEnvelope getPayDepositRequest(PB.PayDepositRequest payDepositRequest) {
|
||||
List<RawTransactionInput> rawTransactionInputs = payDepositRequest.getRawTransactionInputsList().stream()
|
||||
.map(rawTransactionInput -> new RawTransactionInput(rawTransactionInput.getIndex(),
|
||||
rawTransactionInput.getParentTransaction().toByteArray(), rawTransactionInput.getValue()))
|
||||
|
@ -284,14 +284,14 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
|
|||
NodeAddress.fromProto(payDepositRequest.getMediatorNodeAddress()));
|
||||
}
|
||||
|
||||
private static Msg getPeerPublishedPayoutTxMessage(PB.PeerPublishedPayoutTxMessage peerPublishedPayoutTxMessage) {
|
||||
private static NetworkEnvelope getPeerPublishedPayoutTxMessage(PB.PeerPublishedPayoutTxMessage peerPublishedPayoutTxMessage) {
|
||||
return new PeerPublishedPayoutTxMsg(peerPublishedPayoutTxMessage.getTransaction().toByteArray(),
|
||||
peerPublishedPayoutTxMessage.getTradeId(),
|
||||
NodeAddress.fromProto(peerPublishedPayoutTxMessage.getMyNodeAddress()),
|
||||
peerPublishedPayoutTxMessage.getUid());
|
||||
}
|
||||
|
||||
private static Msg getDisputeResultMessage(PB.DisputeResultMessage disputeResultMessage) {
|
||||
private static NetworkEnvelope getDisputeResultMessage(PB.DisputeResultMessage disputeResultMessage) {
|
||||
|
||||
PB.DisputeResult disputeResultproto = disputeResultMessage.getDisputeResult();
|
||||
DisputeResult disputeResult = new DisputeResult(disputeResultproto.getTradeId(),
|
||||
|
@ -309,17 +309,17 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
|
|||
disputeResultMessage.getUid());
|
||||
}
|
||||
|
||||
private static Msg getPeerOpenedDisputeMessage(PB.PeerOpenedDisputeMessage peerOpenedDisputeMessage) {
|
||||
private static NetworkEnvelope getPeerOpenedDisputeMessage(PB.PeerOpenedDisputeMessage peerOpenedDisputeMessage) {
|
||||
return new PeerOpenedDisputeMsg(ProtoUtil.getDispute(peerOpenedDisputeMessage.getDispute()),
|
||||
NodeAddress.fromProto(peerOpenedDisputeMessage.getMyNodeAddress()), peerOpenedDisputeMessage.getUid());
|
||||
}
|
||||
|
||||
private static Msg getOpenNewDisputeMessage(PB.OpenNewDisputeMessage openNewDisputeMessage) {
|
||||
private static NetworkEnvelope getOpenNewDisputeMessage(PB.OpenNewDisputeMessage openNewDisputeMessage) {
|
||||
return new OpenNewDisputeMsg(ProtoUtil.getDispute(openNewDisputeMessage.getDispute()),
|
||||
NodeAddress.fromProto(openNewDisputeMessage.getMyNodeAddress()), openNewDisputeMessage.getUid());
|
||||
}
|
||||
|
||||
private static Msg getDisputeCommunicationMessage(PB.DisputeCommunicationMessage disputeCommunicationMessage) {
|
||||
private static NetworkEnvelope getDisputeCommunicationMessage(PB.DisputeCommunicationMessage disputeCommunicationMessage) {
|
||||
return new DisputeCommunicationMsg(disputeCommunicationMessage.getTradeId(),
|
||||
disputeCommunicationMessage.getTraderId(),
|
||||
disputeCommunicationMessage.getSenderIsTrader(),
|
||||
|
@ -334,7 +334,7 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
|
|||
disputeCommunicationMessage.getUid());
|
||||
}
|
||||
|
||||
private static Msg getFinalizePayoutTxRequest(PB.FinalizePayoutTxRequest finalizePayoutTxRequest) {
|
||||
private static NetworkEnvelope getFinalizePayoutTxRequest(PB.FinalizePayoutTxRequest finalizePayoutTxRequest) {
|
||||
return new FinalizePayoutTxRequest(finalizePayoutTxRequest.getTradeId(),
|
||||
finalizePayoutTxRequest.getSellerSignature().toByteArray(),
|
||||
finalizePayoutTxRequest.getSellerPayoutAddress(),
|
||||
|
@ -342,21 +342,21 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
|
|||
finalizePayoutTxRequest.getUid());
|
||||
}
|
||||
|
||||
private static Msg getDepositTxPublishedMessage(PB.DepositTxPublishedMessage depositTxPublishedMessage) {
|
||||
private static NetworkEnvelope getDepositTxPublishedMessage(PB.DepositTxPublishedMessage depositTxPublishedMessage) {
|
||||
return new DepositTxPublishedMsg(depositTxPublishedMessage.getTradeId(),
|
||||
depositTxPublishedMessage.getDepositTx().toByteArray(),
|
||||
NodeAddress.fromProto(depositTxPublishedMessage.getSenderNodeAddress()), depositTxPublishedMessage.getUid());
|
||||
}
|
||||
|
||||
private static Msg getRemoveMailBoxDataMessage(PB.RemoveMailboxDataMessage msg) {
|
||||
private static NetworkEnvelope getRemoveMailBoxDataMessage(PB.RemoveMailboxDataMessage msg) {
|
||||
return new RemoveMailboxDataMsg(getProtectedMailBoxStorageEntry(msg.getProtectedStorageEntry()));
|
||||
}
|
||||
|
||||
public static Msg getAddDataMessage(PB.Msg envelope) {
|
||||
public static NetworkEnvelope getAddDataMessage(PB.WireEnvelope envelope) {
|
||||
return new AddDataMsg(getProtectedOrMailboxStorageEntry(envelope.getAddDataMessage().getEntry()));
|
||||
}
|
||||
|
||||
private static Msg getRemoveDataMessage(PB.Msg envelope) {
|
||||
private static NetworkEnvelope getRemoveDataMessage(PB.WireEnvelope envelope) {
|
||||
return new RemoveDataMsg(getProtectedStorageEntry(envelope.getRemoveDataMessage().getProtectedStorageEntry()));
|
||||
}
|
||||
|
||||
|
@ -371,7 +371,7 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
|
|||
}
|
||||
|
||||
@NotNull
|
||||
private static Msg getGetDataResponse(PB.Msg envelope) {
|
||||
private static NetworkEnvelope getGetDataResponse(PB.WireEnvelope envelope) {
|
||||
HashSet<ProtectedStorageEntry> set = new HashSet<>(
|
||||
envelope.getGetDataResponse().getDataSetList()
|
||||
.stream()
|
||||
|
@ -382,8 +382,8 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
|
|||
}
|
||||
|
||||
@NotNull
|
||||
private static Msg getGetPeersResponse(PB.Msg envelope) {
|
||||
Msg result;
|
||||
private static NetworkEnvelope getGetPeersResponse(PB.WireEnvelope envelope) {
|
||||
NetworkEnvelope result;
|
||||
PB.GetPeersResponse msg = envelope.getGetPeersResponse();
|
||||
HashSet<Peer> set = new HashSet<>(
|
||||
msg.getReportedPeersList()
|
||||
|
@ -396,9 +396,9 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
|
|||
}
|
||||
|
||||
@NotNull
|
||||
private static Msg getGetPeersRequest(PB.Msg envelope) {
|
||||
private static NetworkEnvelope getGetPeersRequest(PB.WireEnvelope envelope) {
|
||||
NodeAddress nodeAddress;
|
||||
Msg result;
|
||||
NetworkEnvelope result;
|
||||
PB.GetPeersRequest msg = envelope.getGetPeersRequest();
|
||||
nodeAddress = new NodeAddress(msg.getSenderNodeAddress().getHostName(), msg.getSenderNodeAddress().getPort());
|
||||
HashSet<Peer> set = new HashSet<>(
|
||||
|
@ -412,9 +412,9 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
|
|||
}
|
||||
|
||||
@NotNull
|
||||
private static Msg getGetUpdatedDataRequest(PB.Msg envelope) {
|
||||
private static NetworkEnvelope getGetUpdatedDataRequest(PB.WireEnvelope envelope) {
|
||||
NodeAddress nodeAddress;
|
||||
Msg result;
|
||||
NetworkEnvelope result;
|
||||
PB.GetUpdatedDataRequest msg = envelope.getGetUpdatedDataRequest();
|
||||
nodeAddress = new NodeAddress(msg.getSenderNodeAddress().getHostName(), msg.getSenderNodeAddress().getPort());
|
||||
Set<byte[]> updatedDataRequestSet = ProtoUtil.getByteSet(msg.getExcludedKeysList());
|
||||
|
@ -423,20 +423,20 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
|
|||
}
|
||||
|
||||
@NotNull
|
||||
private static Msg getPreliminaryGetDataRequest(PB.Msg envelope) {
|
||||
Msg result;
|
||||
private static NetworkEnvelope getPreliminaryGetDataRequest(PB.WireEnvelope envelope) {
|
||||
NetworkEnvelope result;
|
||||
result = new PreliminaryGetDataRequest(envelope.getPreliminaryGetDataRequest().getNonce(),
|
||||
ProtoUtil.getByteSet(envelope.getPreliminaryGetDataRequest().getExcludedKeysList()));
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Msg getCloseConnectionMessage(PB.Msg msg) {
|
||||
private static NetworkEnvelope getCloseConnectionMessage(PB.WireEnvelope msg) {
|
||||
return new CloseConnectionMsg(msg.getCloseConnectionMessage().getReason());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Msg getRefreshTTLMessage(PB.Msg msg) {
|
||||
private static NetworkEnvelope getRefreshTTLMessage(PB.WireEnvelope msg) {
|
||||
PB.RefreshOfferMsg refreshOfferMsg = msg.getRefreshOfferMsg();
|
||||
return new RefreshOfferMsg(refreshOfferMsg.getHashOfDataAndSeqNr().toByteArray(),
|
||||
refreshOfferMsg.getSignature().toByteArray(),
|
||||
|
@ -445,15 +445,15 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
|
|||
}
|
||||
|
||||
@NotNull
|
||||
private static Msg getPong(PB.Msg envelope) {
|
||||
Msg result;
|
||||
private static NetworkEnvelope getPong(PB.WireEnvelope envelope) {
|
||||
NetworkEnvelope result;
|
||||
result = new Pong(envelope.getPong().getRequestNonce());
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Msg getPing(PB.Msg envelope) {
|
||||
Msg result;
|
||||
private static NetworkEnvelope getPing(PB.WireEnvelope envelope) {
|
||||
NetworkEnvelope result;
|
||||
result = new Ping(envelope.getPing().getNonce(), envelope.getPing().getLastRoundTripTime());
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bisq.core.proto;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistableEnvelope;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
@ -31,18 +31,18 @@ import java.util.List;
|
|||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ViewPathAsString implements Persistable {
|
||||
public class ViewPathAsString implements PersistableEnvelope {
|
||||
@Getter
|
||||
@Setter
|
||||
List<String> viewPath = Lists.newArrayList();
|
||||
|
||||
@Override
|
||||
public Message toProtoMessage() {
|
||||
return CollectionUtils.isEmpty(viewPath) ? PB.Persistable.newBuilder().setViewPathAsString(PB.ViewPathAsString.newBuilder()).build()
|
||||
: PB.Persistable.newBuilder().setViewPathAsString(PB.ViewPathAsString.newBuilder().addAllViewPath(viewPath)).build();
|
||||
return CollectionUtils.isEmpty(viewPath) ? PB.DiscEnvelope.newBuilder().setViewPathAsString(PB.ViewPathAsString.newBuilder()).build()
|
||||
: PB.DiscEnvelope.newBuilder().setViewPathAsString(PB.ViewPathAsString.newBuilder().addAllViewPath(viewPath)).build();
|
||||
}
|
||||
|
||||
public static Persistable fromProto(PB.ViewPathAsString viewPathAsString) {
|
||||
public static PersistableEnvelope fromProto(PB.ViewPathAsString viewPathAsString) {
|
||||
return new ViewPathAsString(viewPathAsString.getViewPathList());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,10 +19,10 @@ package io.bisq.core.trade;
|
|||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bisq.common.Payload;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.crypto.PubKeyRing;
|
||||
import io.bisq.common.monetary.Price;
|
||||
import io.bisq.common.network.NetworkPayload;
|
||||
import io.bisq.common.util.JsonExclude;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.core.payment.payload.PaymentAccountPayload;
|
||||
|
@ -40,7 +40,7 @@ import javax.annotation.concurrent.Immutable;
|
|||
@Slf4j
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
@Immutable
|
||||
public final class Contract implements Payload {
|
||||
public final class Contract implements NetworkPayload {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@JsonExclude
|
||||
public static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
|
|
|
@ -17,17 +17,12 @@
|
|||
|
||||
package io.bisq.core.trade;
|
||||
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import io.bisq.core.btc.wallet.BtcWalletService;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OpenOffer;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface Tradable extends Persistable {
|
||||
public interface Tradable extends PersistablePayload {
|
||||
Offer getOffer();
|
||||
|
||||
Date getDate();
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
package io.bisq.core.trade;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.proto.ProtoHelper;
|
||||
import io.bisq.common.persistable.PersistableCollectionUtil;
|
||||
import io.bisq.common.persistable.PersistableEnvelope;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import io.bisq.core.btc.wallet.BtcWalletService;
|
||||
import io.bisq.core.offer.OpenOffer;
|
||||
|
@ -36,7 +36,7 @@ import java.util.stream.Collectors;
|
|||
import java.util.stream.Stream;
|
||||
|
||||
@Slf4j
|
||||
public final class TradableList<T extends Tradable> implements Persistable {
|
||||
public final class TradableList<T extends Tradable> implements PersistableEnvelope {
|
||||
@Getter
|
||||
private List<T> list = new ArrayList<>();
|
||||
|
||||
|
@ -69,8 +69,8 @@ public final class TradableList<T extends Tradable> implements Persistable {
|
|||
|
||||
@Override
|
||||
public Message toProtoMessage() {
|
||||
return PB.Persistable.newBuilder().setTradableList(PB.TradableList.newBuilder()
|
||||
.addAllTradable(ProtoHelper.collectionToProto(list))).build();
|
||||
return PB.DiscEnvelope.newBuilder().setTradableList(PB.TradableList.newBuilder()
|
||||
.addAllTradable(PersistableCollectionUtil.collectionToProto(list))).build();
|
||||
}
|
||||
|
||||
public static TradableList fromProto(PB.TradableList proto,
|
||||
|
|
|
@ -41,7 +41,7 @@ import io.bisq.core.offer.Offer;
|
|||
import io.bisq.core.offer.OpenOfferManager;
|
||||
import io.bisq.core.trade.protocol.ProcessModel;
|
||||
import io.bisq.core.trade.protocol.TradeProtocol;
|
||||
import io.bisq.core.user.UserModel;
|
||||
import io.bisq.core.user.User;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.DecryptedMsgWithPubKey;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
|
@ -296,7 +296,7 @@ public abstract class Trade implements Tradable, Model {
|
|||
TradeWalletService tradeWalletService,
|
||||
TradeManager tradeManager,
|
||||
OpenOfferManager openOfferManager,
|
||||
UserModel userModel,
|
||||
User user,
|
||||
FilterManager filterManager,
|
||||
KeyRing keyRing,
|
||||
boolean useSavingsWallet,
|
||||
|
@ -309,7 +309,7 @@ public abstract class Trade implements Tradable, Model {
|
|||
btcWalletService,
|
||||
bsqWalletService,
|
||||
tradeWalletService,
|
||||
userModel,
|
||||
user,
|
||||
filterManager,
|
||||
keyRing,
|
||||
useSavingsWallet,
|
||||
|
@ -741,13 +741,13 @@ public abstract class Trade implements Tradable, Model {
|
|||
public void applyArbitratorNodeAddress(NodeAddress arbitratorNodeAddress) {
|
||||
this.arbitratorNodeAddress = arbitratorNodeAddress;
|
||||
|
||||
Arbitrator arbitrator = processModel.getUserModel().getAcceptedArbitratorByAddress(arbitratorNodeAddress);
|
||||
Arbitrator arbitrator = processModel.getUser().getAcceptedArbitratorByAddress(arbitratorNodeAddress);
|
||||
checkNotNull(arbitrator, "arbitrator must not be null");
|
||||
arbitratorBtcPubKey = arbitrator.getBtcPubKey();
|
||||
}
|
||||
|
||||
public byte[] getArbitratorBtcPubKey() {
|
||||
Arbitrator arbitrator = processModel.getUserModel().getAcceptedArbitratorByAddress(arbitratorNodeAddress);
|
||||
Arbitrator arbitrator = processModel.getUser().getAcceptedArbitratorByAddress(arbitratorNodeAddress);
|
||||
checkNotNull(arbitrator, "arbitrator must not be null");
|
||||
arbitratorBtcPubKey = arbitrator.getBtcPubKey();
|
||||
|
||||
|
@ -762,7 +762,7 @@ public abstract class Trade implements Tradable, Model {
|
|||
public void applyMediatorNodeAddress(NodeAddress mediatorNodeAddress) {
|
||||
this.mediatorNodeAddress = mediatorNodeAddress;
|
||||
|
||||
Mediator mediator = processModel.getUserModel().getAcceptedMediatorByAddress(mediatorNodeAddress);
|
||||
Mediator mediator = processModel.getUser().getAcceptedMediatorByAddress(mediatorNodeAddress);
|
||||
checkNotNull(mediator, "mediator must not be null");
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import io.bisq.common.crypto.KeyRing;
|
|||
import io.bisq.common.handlers.ErrorMessageHandler;
|
||||
import io.bisq.common.handlers.FaultHandler;
|
||||
import io.bisq.common.handlers.ResultHandler;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.common.proto.PersistenceProtoResolver;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import io.bisq.core.btc.AddressEntry;
|
||||
|
@ -46,7 +46,7 @@ import io.bisq.core.trade.messages.PayDepositRequest;
|
|||
import io.bisq.core.trade.messages.TradeMsg;
|
||||
import io.bisq.core.trade.statistics.TradeStatistics;
|
||||
import io.bisq.core.trade.statistics.TradeStatisticsManager;
|
||||
import io.bisq.core.user.UserModel;
|
||||
import io.bisq.core.user.User;
|
||||
import io.bisq.core.util.Validator;
|
||||
import io.bisq.network.p2p.*;
|
||||
import io.bisq.network.p2p.messaging.DecryptedMailboxListener;
|
||||
|
@ -78,7 +78,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
|||
public class TradeManager {
|
||||
private static final Logger log = LoggerFactory.getLogger(TradeManager.class);
|
||||
|
||||
private final UserModel userModel;
|
||||
private final User user;
|
||||
private final KeyRing keyRing;
|
||||
private final BtcWalletService btcWalletService;
|
||||
private final BsqWalletService bsqWalletService;
|
||||
|
@ -102,7 +102,7 @@ public class TradeManager {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public TradeManager(UserModel userModel,
|
||||
public TradeManager(User user,
|
||||
KeyRing keyRing,
|
||||
BtcWalletService btcWalletService,
|
||||
BsqWalletService bsqWalletService,
|
||||
|
@ -116,7 +116,7 @@ public class TradeManager {
|
|||
TradeStatisticsManager tradeStatisticsManager,
|
||||
PersistenceProtoResolver persistenceProtoResolver,
|
||||
@Named(Storage.STORAGE_DIR) File storageDir) {
|
||||
this.userModel = userModel;
|
||||
this.user = user;
|
||||
this.keyRing = keyRing;
|
||||
this.btcWalletService = btcWalletService;
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
|
@ -138,12 +138,12 @@ public class TradeManager {
|
|||
p2PService.addDecryptedDirectMessageListener(new DecryptedDirectMessageListener() {
|
||||
@Override
|
||||
public void onDirectMessage(DecryptedMsgWithPubKey decryptedMsgWithPubKey, NodeAddress peerNodeAddress) {
|
||||
Msg msg = decryptedMsgWithPubKey.msg;
|
||||
NetworkEnvelope wireEnvelope = decryptedMsgWithPubKey.wireEnvelope;
|
||||
|
||||
// Handler for incoming initial network_messages from taker
|
||||
if (msg instanceof PayDepositRequest) {
|
||||
log.trace("Received PayDepositRequest: " + msg);
|
||||
handleInitialTakeOfferRequest((PayDepositRequest) msg, peerNodeAddress);
|
||||
if (wireEnvelope instanceof PayDepositRequest) {
|
||||
log.trace("Received PayDepositRequest: " + wireEnvelope);
|
||||
handleInitialTakeOfferRequest((PayDepositRequest) wireEnvelope, peerNodeAddress);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -154,10 +154,10 @@ public class TradeManager {
|
|||
public void onMailboxMessageAdded(DecryptedMsgWithPubKey decryptedMsgWithPubKey, NodeAddress senderNodeAddress) {
|
||||
log.trace("onMailboxMessageAdded decryptedMessageWithPubKey: " + decryptedMsgWithPubKey);
|
||||
log.trace("onMailboxMessageAdded senderAddress: " + senderNodeAddress);
|
||||
Msg msg = decryptedMsgWithPubKey.msg;
|
||||
if (msg instanceof TradeMsg) {
|
||||
log.trace("Received TradeMessage: " + msg);
|
||||
String tradeId = ((TradeMsg) msg).tradeId;
|
||||
NetworkEnvelope wireEnvelope = decryptedMsgWithPubKey.wireEnvelope;
|
||||
if (wireEnvelope instanceof TradeMsg) {
|
||||
log.trace("Received TradeMessage: " + wireEnvelope);
|
||||
String tradeId = ((TradeMsg) wireEnvelope).tradeId;
|
||||
Optional<Trade> tradeOptional = trades.stream().filter(e -> e.getId().equals(tradeId)).findAny();
|
||||
// The mailbox message will be removed inside the tasks after they are processed successfully
|
||||
if (tradeOptional.isPresent())
|
||||
|
@ -306,7 +306,7 @@ public class TradeManager {
|
|||
tradeWalletService,
|
||||
this,
|
||||
openOfferManager,
|
||||
userModel,
|
||||
user,
|
||||
filterManager,
|
||||
keyRing,
|
||||
useSavingsWallet,
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bisq.core.trade.messages;
|
|||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.MailboxMsg;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
|
@ -56,8 +56,8 @@ public final class DepositTxPublishedMsg extends TradeMsg implements MailboxMsg
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Msg toProtoMsg() {
|
||||
PB.Msg.Builder msgBuilder = Msg.getMsgBuilder();
|
||||
public PB.WireEnvelope toProtoMsg() {
|
||||
PB.WireEnvelope.Builder msgBuilder = NetworkEnvelope.getMsgBuilder();
|
||||
return msgBuilder.setDepositTxPublishedMessage(PB.DepositTxPublishedMessage.newBuilder()
|
||||
.setMessageVersion(getMsgVersion())
|
||||
.setTradeId(tradeId)
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bisq.core.trade.messages;
|
|||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.MailboxMsg;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
|
@ -60,8 +60,8 @@ public final class FiatTransferStartedMsg extends TradeMsg implements MailboxMsg
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Msg toProtoMsg() {
|
||||
PB.Msg.Builder msgBuilder = Msg.getMsgBuilder();
|
||||
public PB.WireEnvelope toProtoMsg() {
|
||||
PB.WireEnvelope.Builder msgBuilder = NetworkEnvelope.getMsgBuilder();
|
||||
return msgBuilder.setFiatTransferStartedMessage(msgBuilder.getFiatTransferStartedMessageBuilder()
|
||||
.setMessageVersion(getMsgVersion())
|
||||
.setTradeId(tradeId)
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bisq.core.trade.messages;
|
|||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.MailboxMsg;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
|
@ -61,8 +61,8 @@ public final class FinalizePayoutTxRequest extends TradeMsg implements MailboxMs
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Msg toProtoMsg() {
|
||||
PB.Msg.Builder msgBuilder = Msg.getMsgBuilder();
|
||||
public PB.WireEnvelope toProtoMsg() {
|
||||
PB.WireEnvelope.Builder msgBuilder = NetworkEnvelope.getMsgBuilder();
|
||||
return msgBuilder.setFinalizePayoutTxRequest(PB.FinalizePayoutTxRequest.newBuilder()
|
||||
.setMessageVersion(getMsgVersion())
|
||||
.setTradeId(tradeId)
|
||||
|
|
|
@ -20,7 +20,7 @@ package io.bisq.core.trade.messages;
|
|||
import com.google.protobuf.ByteString;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.crypto.PubKeyRing;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.core.btc.data.RawTransactionInput;
|
||||
import io.bisq.core.payment.payload.PaymentAccountPayload;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
|
@ -105,8 +105,8 @@ public final class PayDepositRequest extends TradeMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Msg toProtoMsg() {
|
||||
PB.Msg.Builder msgBuilder = Msg.getMsgBuilder();
|
||||
public PB.WireEnvelope toProtoMsg() {
|
||||
PB.WireEnvelope.Builder msgBuilder = NetworkEnvelope.getMsgBuilder();
|
||||
PB.PayDepositRequest.Builder builderForValue = PB.PayDepositRequest.newBuilder()
|
||||
.setTradeId(tradeId)
|
||||
.setTradeAmount(tradeAmount)
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bisq.core.trade.messages;
|
|||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.MailboxMsg;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
|
@ -55,8 +55,8 @@ public final class PayoutTxPublishedMsg extends TradeMsg implements MailboxMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Msg toProtoMsg() {
|
||||
PB.Msg.Builder msgBuilder = Msg.getMsgBuilder();
|
||||
public PB.WireEnvelope toProtoMsg() {
|
||||
PB.WireEnvelope.Builder msgBuilder = NetworkEnvelope.getMsgBuilder();
|
||||
return msgBuilder.setPayoutTxPublishedMessage(msgBuilder.getPayoutTxPublishedMessageBuilder()
|
||||
.setUid(uid)
|
||||
.setMessageVersion(getMsgVersion())
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bisq.core.trade.messages;
|
|||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.common.util.Utilities;
|
||||
import io.bisq.core.btc.data.RawTransactionInput;
|
||||
import io.bisq.core.payment.payload.PaymentAccountPayload;
|
||||
|
@ -88,8 +88,8 @@ public final class PublishDepositTxRequest extends TradeMsg implements MailboxMs
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Msg toProtoMsg() {
|
||||
PB.Msg.Builder msgBuilder = Msg.getMsgBuilder();
|
||||
public PB.WireEnvelope toProtoMsg() {
|
||||
PB.WireEnvelope.Builder msgBuilder = NetworkEnvelope.getMsgBuilder();
|
||||
return msgBuilder.setPublishDepositTxRequest(msgBuilder.getPublishDepositTxRequestBuilder()
|
||||
.setMessageVersion(getMsgVersion())
|
||||
.setTradeId(tradeId)
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bisq.core.trade.protocol;
|
|||
|
||||
import io.bisq.common.handlers.ErrorMessageHandler;
|
||||
import io.bisq.common.handlers.ResultHandler;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.core.trade.BuyerAsMakerTrade;
|
||||
import io.bisq.core.trade.Trade;
|
||||
import io.bisq.core.trade.messages.DepositTxPublishedMsg;
|
||||
|
@ -83,18 +83,18 @@ public class BuyerAsMakerProtocol extends TradeProtocol implements BuyerProtocol
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void doApplyMailboxMessage(Msg msg, Trade trade) {
|
||||
public void doApplyMailboxMessage(NetworkEnvelope wireEnvelope, Trade trade) {
|
||||
this.trade = trade;
|
||||
|
||||
if (msg instanceof MailboxMsg) {
|
||||
MailboxMsg mailboxMessage = (MailboxMsg) msg;
|
||||
if (wireEnvelope instanceof MailboxMsg) {
|
||||
MailboxMsg mailboxMessage = (MailboxMsg) wireEnvelope;
|
||||
NodeAddress peerNodeAddress = mailboxMessage.getSenderNodeAddress();
|
||||
if (msg instanceof DepositTxPublishedMsg)
|
||||
handle((DepositTxPublishedMsg) msg, peerNodeAddress);
|
||||
else if (msg instanceof PayoutTxPublishedMsg)
|
||||
handle((PayoutTxPublishedMsg) msg, peerNodeAddress);
|
||||
if (wireEnvelope instanceof DepositTxPublishedMsg)
|
||||
handle((DepositTxPublishedMsg) wireEnvelope, peerNodeAddress);
|
||||
else if (wireEnvelope instanceof PayoutTxPublishedMsg)
|
||||
handle((PayoutTxPublishedMsg) wireEnvelope, peerNodeAddress);
|
||||
else
|
||||
log.error("We received an unhandled MailboxMessage" + msg.toString());
|
||||
log.error("We received an unhandled MailboxMessage" + wireEnvelope.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package io.bisq.core.trade.protocol;
|
|||
|
||||
import io.bisq.common.handlers.ErrorMessageHandler;
|
||||
import io.bisq.common.handlers.ResultHandler;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.core.trade.BuyerAsTakerTrade;
|
||||
import io.bisq.core.trade.Trade;
|
||||
import io.bisq.core.trade.messages.PayoutTxPublishedMsg;
|
||||
|
@ -73,15 +73,15 @@ public class BuyerAsTakerProtocol extends TradeProtocol implements BuyerProtocol
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void doApplyMailboxMessage(Msg msg, Trade trade) {
|
||||
public void doApplyMailboxMessage(NetworkEnvelope wireEnvelope, Trade trade) {
|
||||
this.trade = trade;
|
||||
final NodeAddress senderNodeAddress = ((MailboxMsg) msg).getSenderNodeAddress();
|
||||
if (msg instanceof PublishDepositTxRequest)
|
||||
handle((PublishDepositTxRequest) msg, senderNodeAddress);
|
||||
else if (msg instanceof PayoutTxPublishedMsg) {
|
||||
handle((PayoutTxPublishedMsg) msg, senderNodeAddress);
|
||||
final NodeAddress senderNodeAddress = ((MailboxMsg) wireEnvelope).getSenderNodeAddress();
|
||||
if (wireEnvelope instanceof PublishDepositTxRequest)
|
||||
handle((PublishDepositTxRequest) wireEnvelope, senderNodeAddress);
|
||||
else if (wireEnvelope instanceof PayoutTxPublishedMsg) {
|
||||
handle((PayoutTxPublishedMsg) wireEnvelope, senderNodeAddress);
|
||||
} else
|
||||
log.error("We received an unhandled MailboxMessage" + msg.toString());
|
||||
log.error("We received an unhandled MailboxMessage" + wireEnvelope.toString());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ import com.google.protobuf.Message;
|
|||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.crypto.KeyRing;
|
||||
import io.bisq.common.crypto.PubKeyRing;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.proto.ProtoHelper;
|
||||
import io.bisq.common.persistable.PersistableCollectionUtil;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import io.bisq.common.taskrunner.Model;
|
||||
import io.bisq.core.btc.data.RawTransactionInput;
|
||||
import io.bisq.core.btc.wallet.BsqWalletService;
|
||||
|
@ -39,7 +39,7 @@ import io.bisq.core.trade.MakerTrade;
|
|||
import io.bisq.core.trade.Trade;
|
||||
import io.bisq.core.trade.TradeManager;
|
||||
import io.bisq.core.trade.messages.TradeMsg;
|
||||
import io.bisq.core.user.UserModel;
|
||||
import io.bisq.core.user.User;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.DecryptedMsgWithPubKey;
|
||||
import io.bisq.network.p2p.MailboxMsg;
|
||||
|
@ -59,7 +59,7 @@ import java.util.List;
|
|||
|
||||
@Getter
|
||||
@Slf4j
|
||||
public class ProcessModel implements Model, Persistable {
|
||||
public class ProcessModel implements Model, PersistablePayload {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
|
@ -73,7 +73,7 @@ public class ProcessModel implements Model, Persistable {
|
|||
transient private TradeWalletService tradeWalletService;
|
||||
transient private Offer offer;
|
||||
@Getter
|
||||
transient private UserModel userModel;
|
||||
transient private User user;
|
||||
transient private FilterManager filterManager;
|
||||
@Getter
|
||||
transient private KeyRing keyRing;
|
||||
|
@ -132,7 +132,7 @@ public class ProcessModel implements Model, Persistable {
|
|||
BtcWalletService walletService,
|
||||
BsqWalletService bsqWalletService,
|
||||
TradeWalletService tradeWalletService,
|
||||
UserModel userModel,
|
||||
User user,
|
||||
FilterManager filterManager,
|
||||
KeyRing keyRing,
|
||||
boolean useSavingsWallet,
|
||||
|
@ -143,14 +143,14 @@ public class ProcessModel implements Model, Persistable {
|
|||
this.btcWalletService = walletService;
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.tradeWalletService = tradeWalletService;
|
||||
this.userModel = userModel;
|
||||
this.user = user;
|
||||
this.filterManager = filterManager;
|
||||
this.keyRing = keyRing;
|
||||
this.p2PService = p2PService;
|
||||
this.useSavingsWallet = useSavingsWallet;
|
||||
fundsNeededForTradeAsLong = fundsNeededForTrade.value;
|
||||
offerId = offer.getId();
|
||||
accountId = userModel.getAccountId();
|
||||
accountId = user.getAccountId();
|
||||
pubKeyRing = keyRing.getPubKeyRing();
|
||||
}
|
||||
|
||||
|
@ -171,9 +171,9 @@ public class ProcessModel implements Model, Persistable {
|
|||
public PaymentAccountPayload getPaymentAccountPayload(Trade trade) {
|
||||
PaymentAccount paymentAccount;
|
||||
if (trade instanceof MakerTrade)
|
||||
paymentAccount = userModel.getPaymentAccount(offer.getMakerPaymentAccountId());
|
||||
paymentAccount = user.getPaymentAccount(offer.getMakerPaymentAccountId());
|
||||
else
|
||||
paymentAccount = userModel.getPaymentAccount(trade.getTakerPaymentAccountId());
|
||||
paymentAccount = user.getPaymentAccount(trade.getTakerPaymentAccountId());
|
||||
return paymentAccount != null ? paymentAccount.getPaymentAccountPayload() : null;
|
||||
}
|
||||
|
||||
|
@ -226,10 +226,10 @@ public class ProcessModel implements Model, Persistable {
|
|||
.setPubKeyRing(pubKeyRing.toProtoMessage())
|
||||
.setTakeOfferFeeTxId(takeOfferFeeTxId)
|
||||
.setPayoutTxSignature(ByteString.copyFrom(payoutTxSignature))
|
||||
.addAllTakerAcceptedArbitratorNodeAddresses(ProtoHelper.collectionToProto(takerAcceptedArbitratorNodeAddresses))
|
||||
.addAllTakerAcceptedMediatorNodeAddresses(ProtoHelper.collectionToProto(takerAcceptedMediatorNodeAddresses))
|
||||
.addAllTakerAcceptedArbitratorNodeAddresses(PersistableCollectionUtil.collectionToProto(takerAcceptedArbitratorNodeAddresses))
|
||||
.addAllTakerAcceptedMediatorNodeAddresses(PersistableCollectionUtil.collectionToProto(takerAcceptedMediatorNodeAddresses))
|
||||
.setPreparedDepositTx(ByteString.copyFrom(preparedDepositTx))
|
||||
.addAllRawTransactionInputs(ProtoHelper.collectionToProto(rawTransactionInputs))
|
||||
.addAllRawTransactionInputs(PersistableCollectionUtil.collectionToProto(rawTransactionInputs))
|
||||
.setChangeOutputValue(changeOutputValue)
|
||||
.setChangeOutputAddress(changeOutputAddress)
|
||||
.setUseSavingsWallet(useSavingsWallet)
|
||||
|
@ -243,7 +243,7 @@ public class ProcessModel implements Model, Persistable {
|
|||
public void removeMailboxMessageAfterProcessing(Trade trade) {
|
||||
if (tradeMessage instanceof MailboxMsg &&
|
||||
decryptedMsgWithPubKey != null &&
|
||||
decryptedMsgWithPubKey.msg.equals(tradeMessage)) {
|
||||
decryptedMsgWithPubKey.wireEnvelope.equals(tradeMessage)) {
|
||||
log.debug("Remove decryptedMsgWithPubKey from P2P network. decryptedMsgWithPubKey = " + decryptedMsgWithPubKey);
|
||||
p2PService.removeEntryFromMailbox(decryptedMsgWithPubKey);
|
||||
trade.removeDecryptedMsgWithPubKey(decryptedMsgWithPubKey);
|
||||
|
|
|
@ -20,7 +20,7 @@ package io.bisq.core.trade.protocol;
|
|||
|
||||
import io.bisq.common.handlers.ErrorMessageHandler;
|
||||
import io.bisq.common.handlers.ResultHandler;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.core.trade.SellerAsMakerTrade;
|
||||
import io.bisq.core.trade.Trade;
|
||||
import io.bisq.core.trade.messages.DepositTxPublishedMsg;
|
||||
|
@ -74,16 +74,16 @@ public class SellerAsMakerProtocol extends TradeProtocol implements SellerProtoc
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void doApplyMailboxMessage(Msg msg, Trade trade) {
|
||||
public void doApplyMailboxMessage(NetworkEnvelope wireEnvelope, Trade trade) {
|
||||
this.trade = trade;
|
||||
|
||||
NodeAddress peerNodeAddress = ((MailboxMsg) msg).getSenderNodeAddress();
|
||||
if (msg instanceof DepositTxPublishedMsg)
|
||||
handle((DepositTxPublishedMsg) msg, peerNodeAddress);
|
||||
else if (msg instanceof FiatTransferStartedMsg)
|
||||
handle((FiatTransferStartedMsg) msg, peerNodeAddress);
|
||||
NodeAddress peerNodeAddress = ((MailboxMsg) wireEnvelope).getSenderNodeAddress();
|
||||
if (wireEnvelope instanceof DepositTxPublishedMsg)
|
||||
handle((DepositTxPublishedMsg) wireEnvelope, peerNodeAddress);
|
||||
else if (wireEnvelope instanceof FiatTransferStartedMsg)
|
||||
handle((FiatTransferStartedMsg) wireEnvelope, peerNodeAddress);
|
||||
else
|
||||
log.error("We received an unhandled MailboxMessage" + msg.toString());
|
||||
log.error("We received an unhandled MailboxMessage" + wireEnvelope.toString());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package io.bisq.core.trade.protocol;
|
|||
|
||||
import io.bisq.common.handlers.ErrorMessageHandler;
|
||||
import io.bisq.common.handlers.ResultHandler;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.core.trade.SellerAsTakerTrade;
|
||||
import io.bisq.core.trade.Trade;
|
||||
import io.bisq.core.trade.messages.FiatTransferStartedMsg;
|
||||
|
@ -60,17 +60,17 @@ public class SellerAsTakerProtocol extends TradeProtocol implements SellerProtoc
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void doApplyMailboxMessage(Msg msg, Trade trade) {
|
||||
public void doApplyMailboxMessage(NetworkEnvelope wireEnvelope, Trade trade) {
|
||||
this.trade = trade;
|
||||
|
||||
if (msg instanceof MailboxMsg) {
|
||||
NodeAddress peerNodeAddress = ((MailboxMsg) msg).getSenderNodeAddress();
|
||||
if (msg instanceof PublishDepositTxRequest)
|
||||
handle((PublishDepositTxRequest) msg, peerNodeAddress);
|
||||
else if (msg instanceof FiatTransferStartedMsg)
|
||||
handle((FiatTransferStartedMsg) msg, peerNodeAddress);
|
||||
if (wireEnvelope instanceof MailboxMsg) {
|
||||
NodeAddress peerNodeAddress = ((MailboxMsg) wireEnvelope).getSenderNodeAddress();
|
||||
if (wireEnvelope instanceof PublishDepositTxRequest)
|
||||
handle((PublishDepositTxRequest) wireEnvelope, peerNodeAddress);
|
||||
else if (wireEnvelope instanceof FiatTransferStartedMsg)
|
||||
handle((FiatTransferStartedMsg) wireEnvelope, peerNodeAddress);
|
||||
else
|
||||
log.error("We received an unhandled MailboxMessage" + msg.toString());
|
||||
log.error("We received an unhandled MailboxMessage" + wireEnvelope.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package io.bisq.core.trade.protocol;
|
|||
import io.bisq.common.Timer;
|
||||
import io.bisq.common.UserThread;
|
||||
import io.bisq.common.crypto.PubKeyRing;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.network.NetworkEnvelope;
|
||||
import io.bisq.core.trade.MakerTrade;
|
||||
import io.bisq.core.trade.Trade;
|
||||
import io.bisq.core.trade.TradeManager;
|
||||
|
@ -54,10 +54,10 @@ public abstract class TradeProtocol {
|
|||
PubKeyRing tradingPeerPubKeyRing = processModel.getTradingPeer().getPubKeyRing();
|
||||
PublicKey signaturePubKey = decryptedMessageWithPubKey.signaturePubKey;
|
||||
if (tradingPeerPubKeyRing != null && signaturePubKey.equals(tradingPeerPubKeyRing.getSignaturePubKey())) {
|
||||
Msg msg = decryptedMessageWithPubKey.msg;
|
||||
log.trace("handleNewMessage: message = " + msg.getClass().getSimpleName() + " from " + peersNodeAddress);
|
||||
if (msg instanceof TradeMsg) {
|
||||
TradeMsg tradeMessage = (TradeMsg) msg;
|
||||
NetworkEnvelope wireEnvelope = decryptedMessageWithPubKey.wireEnvelope;
|
||||
log.trace("handleNewMessage: message = " + wireEnvelope.getClass().getSimpleName() + " from " + peersNodeAddress);
|
||||
if (wireEnvelope instanceof TradeMsg) {
|
||||
TradeMsg tradeMessage = (TradeMsg) wireEnvelope;
|
||||
nonEmptyStringOf(tradeMessage.tradeId);
|
||||
|
||||
if (tradeMessage.tradeId.equals(processModel.getOfferId()))
|
||||
|
@ -92,16 +92,16 @@ public abstract class TradeProtocol {
|
|||
}
|
||||
|
||||
public void applyMailboxMessage(DecryptedMsgWithPubKey decryptedMsgWithPubKey, Trade trade) {
|
||||
log.debug("applyMailboxMessage " + decryptedMsgWithPubKey.msg);
|
||||
log.debug("applyMailboxMessage " + decryptedMsgWithPubKey.wireEnvelope);
|
||||
if (decryptedMsgWithPubKey.signaturePubKey.equals(processModel.getTradingPeer().getPubKeyRing().getSignaturePubKey())) {
|
||||
processModel.setDecryptedMsgWithPubKey(decryptedMsgWithPubKey);
|
||||
doApplyMailboxMessage(decryptedMsgWithPubKey.msg, trade);
|
||||
doApplyMailboxMessage(decryptedMsgWithPubKey.wireEnvelope, trade);
|
||||
} else {
|
||||
log.error("SignaturePubKey in message does not match the SignaturePubKey we have stored to that trading peer.");
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void doApplyMailboxMessage(Msg msg, Trade trade);
|
||||
protected abstract void doApplyMailboxMessage(NetworkEnvelope wireEnvelope, Trade trade);
|
||||
|
||||
protected abstract void doHandleDecryptedMessage(TradeMsg tradeMessage, NodeAddress peerNodeAddress);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package io.bisq.core.trade.protocol;
|
|||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.crypto.PubKeyRing;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.persistable.PersistablePayload;
|
||||
import io.bisq.core.btc.data.RawTransactionInput;
|
||||
import io.bisq.core.payment.payload.PaymentAccountPayload;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
|
@ -34,7 +34,7 @@ import java.util.List;
|
|||
@Slf4j
|
||||
@Getter
|
||||
@Setter
|
||||
public final class TradingPeer implements Persistable {
|
||||
public final class TradingPeer implements PersistablePayload {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import io.bisq.core.btc.wallet.WalletService;
|
|||
import io.bisq.core.trade.Trade;
|
||||
import io.bisq.core.trade.protocol.ArbitratorSelectionRule;
|
||||
import io.bisq.core.trade.protocol.tasks.TradeTask;
|
||||
import io.bisq.core.user.UserModel;
|
||||
import io.bisq.core.user.User;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bitcoinj.core.Address;
|
||||
|
@ -52,11 +52,11 @@ public class CreateTakerFeeTx extends TradeTask {
|
|||
try {
|
||||
runInterceptHook();
|
||||
|
||||
UserModel userModel = processModel.getUserModel();
|
||||
NodeAddress selectedArbitratorNodeAddress = ArbitratorSelectionRule.select(userModel.getAcceptedArbitratorAddresses(),
|
||||
User user = processModel.getUser();
|
||||
NodeAddress selectedArbitratorNodeAddress = ArbitratorSelectionRule.select(user.getAcceptedArbitratorAddresses(),
|
||||
processModel.getOffer());
|
||||
log.debug("selectedArbitratorAddress " + selectedArbitratorNodeAddress);
|
||||
Arbitrator selectedArbitrator = userModel.getAcceptedArbitratorByAddress(selectedArbitratorNodeAddress);
|
||||
Arbitrator selectedArbitrator = user.getAcceptedArbitratorByAddress(selectedArbitratorNodeAddress);
|
||||
checkNotNull(selectedArbitrator, "selectedArbitrator must not be null at CreateTakeOfferFeeTx");
|
||||
BtcWalletService walletService = processModel.getBtcWalletService();
|
||||
String id = processModel.getOffer().getId();
|
||||
|
|
|
@ -35,7 +35,7 @@ public class TakerSelectArbitrator extends TradeTask {
|
|||
try {
|
||||
runInterceptHook();
|
||||
|
||||
trade.applyArbitratorNodeAddress(ArbitratorSelectionRule.select(processModel.getUserModel().getAcceptedArbitratorAddresses(), processModel.getOffer()));
|
||||
trade.applyArbitratorNodeAddress(ArbitratorSelectionRule.select(processModel.getUser().getAcceptedArbitratorAddresses(), processModel.getOffer()));
|
||||
|
||||
complete();
|
||||
} catch (Throwable t) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue