mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-25 07:10:48 -04:00
Use PopupManager for queuing popups, improve version handling, deactivate focus requests, add popup when getting disconnection because of version conflict
This commit is contained in:
parent
ba4a228fed
commit
a264fa4e0b
94 changed files with 421 additions and 288 deletions
|
@ -28,34 +28,46 @@ public class Version {
|
||||||
|
|
||||||
// The version nr. for the objects sent over the network. A change will break the serialization of old objects.
|
// The version nr. for the objects sent over the network. A change will break the serialization of old objects.
|
||||||
// If objects are used for both network and database the network version is applied.
|
// If objects are used for both network and database the network version is applied.
|
||||||
public static final long NETWORK_PROTOCOL_VERSION = 2;
|
public static final long P2P_NETWORK_VERSION = 1;
|
||||||
|
|
||||||
// The version nr. of the serialized data stored to disc. A change will break the serialization of old objects.
|
// The version nr. of the serialized data stored to disc. A change will break the serialization of old objects.
|
||||||
public static final long LOCAL_DB_VERSION = 2;
|
public static final long LOCAL_DB_VERSION = 1;
|
||||||
|
|
||||||
// The version nr. of the current protocol. The offer holds that version.
|
// The version nr. of the current protocol. The offer holds that version.
|
||||||
// A taker will check the version of the offers to see if his version is compatible.
|
// A taker will check the version of the offers to see if his version is compatible.
|
||||||
// TODO not used yet
|
public static final long TRADE_PROTOCOL_VERSION = 1;
|
||||||
public static final long PROTOCOL_VERSION = 1;
|
|
||||||
|
|
||||||
// The version for the bitcoin network (Mainnet = 0, TestNet = 1, Regtest = 2)
|
|
||||||
private static int NETWORK_ID;
|
|
||||||
|
|
||||||
public static int getNetworkId() {
|
public static int getP2PMessageVersion() {
|
||||||
return NETWORK_ID;
|
// A changed NETWORK_PROTOCOL_VERSION for the serialized objects does not trigger reliable a disconnect.
|
||||||
|
// TODO investigate why, but java serialisation should be replaced anyway, so using one existing field
|
||||||
|
// for the version is fine.
|
||||||
|
// BTC_NETWORK_ID is 0, 1 or 2, we use for changes at NETWORK_PROTOCOL_VERSION a multiplication with 10
|
||||||
|
// to avoid conflicts:
|
||||||
|
// E.g. btc BTC_NETWORK_ID=1, NETWORK_PROTOCOL_VERSION=1 -> getNetworkId()=2;
|
||||||
|
// BTC_NETWORK_ID=0, NETWORK_PROTOCOL_VERSION=2 -> getNetworkId()=2; -> wrong
|
||||||
|
return BTC_NETWORK_ID + 10 * (int) P2P_NETWORK_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setNetworkId(int networkId) {
|
// The version for the bitcoin network (Mainnet = 0, TestNet = 1, Regtest = 2)
|
||||||
NETWORK_ID = networkId;
|
private static int BTC_NETWORK_ID;
|
||||||
|
|
||||||
|
public static void setBtcNetworkId(int btcNetworkId) {
|
||||||
|
BTC_NETWORK_ID = btcNetworkId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getBtcNetworkId() {
|
||||||
|
return BTC_NETWORK_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printVersion() {
|
public static void printVersion() {
|
||||||
log.info("Version{" +
|
log.info("Version{" +
|
||||||
"VERSION=" + VERSION +
|
"VERSION=" + VERSION +
|
||||||
", NETWORK_PROTOCOL_VERSION=" + NETWORK_PROTOCOL_VERSION +
|
", P2P_NETWORK_VERSION=" + P2P_NETWORK_VERSION +
|
||||||
", LOCAL_DB_VERSION=" + LOCAL_DB_VERSION +
|
", LOCAL_DB_VERSION=" + LOCAL_DB_VERSION +
|
||||||
", PROTOCOL_VERSION=" + PROTOCOL_VERSION +
|
", TRADE_PROTOCOL_VERSION=" + TRADE_PROTOCOL_VERSION +
|
||||||
", NETWORK_ID=" + NETWORK_ID +
|
", BTC_NETWORK_ID=" + BTC_NETWORK_ID +
|
||||||
|
", getP2PNetworkId()=" + getP2PMessageVersion() +
|
||||||
'}');
|
'}');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.util.Arrays;
|
||||||
|
|
||||||
public class ByteArray implements Serializable {
|
public class ByteArray implements Serializable {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
public final byte[] bytes;
|
public final byte[] bytes;
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ import java.security.spec.X509EncodedKeySpec;
|
||||||
*/
|
*/
|
||||||
public class PubKeyRing implements Serializable {
|
public class PubKeyRing implements Serializable {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(PubKeyRing.class);
|
private static final Logger log = LoggerFactory.getLogger(PubKeyRing.class);
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Arrays;
|
||||||
|
|
||||||
public final class SealedAndSigned implements Serializable {
|
public final class SealedAndSigned implements Serializable {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
public final byte[] encryptedSecretKey;
|
public final byte[] encryptedSecretKey;
|
||||||
public final byte[] encryptedPayloadWithHmac;
|
public final byte[] encryptedPayloadWithHmac;
|
||||||
|
|
|
@ -133,14 +133,14 @@ public class FileManager<T> {
|
||||||
executor.schedule(saveFileTask, delayInMilli, TimeUnit.MILLISECONDS);
|
executor.schedule(saveFileTask, delayInMilli, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized T read(File file) {
|
public synchronized T read(File file) throws IOException, ClassNotFoundException {
|
||||||
log.debug("read" + file);
|
log.debug("read" + file);
|
||||||
try (final FileInputStream fileInputStream = new FileInputStream(file);
|
try (final FileInputStream fileInputStream = new FileInputStream(file);
|
||||||
final ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream)) {
|
final ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream)) {
|
||||||
return (T) objectInputStream.readObject();
|
return (T) objectInputStream.readObject();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
log.error("Exception at read: " + t.getMessage());
|
log.error("Exception at read: " + t.getMessage());
|
||||||
return null;
|
throw t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,12 +176,12 @@ public class FileManager<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void removeAndBackupFile(String fileName) throws IOException {
|
public synchronized void removeAndBackupFile(String fileName) throws IOException {
|
||||||
File corruptedBackupDir = new File(Paths.get(dir.getAbsolutePath(), "corrupted").toString());
|
File corruptedBackupDir = new File(Paths.get(dir.getAbsolutePath(), "backup_of_corrupted_data").toString());
|
||||||
if (!corruptedBackupDir.exists())
|
if (!corruptedBackupDir.exists())
|
||||||
if (!corruptedBackupDir.mkdir())
|
if (!corruptedBackupDir.mkdir())
|
||||||
log.warn("make dir failed");
|
log.warn("make dir failed");
|
||||||
|
|
||||||
File corruptedFile = new File(Paths.get(dir.getAbsolutePath(), "corrupted", fileName).toString());
|
File corruptedFile = new File(Paths.get(dir.getAbsolutePath(), "backup_of_corrupted_data", fileName).toString());
|
||||||
renameTempFileToFile(storageFile, corruptedFile);
|
renameTempFileToFile(storageFile, corruptedFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
package io.bitsquare.storage;
|
package io.bitsquare.storage;
|
||||||
|
|
||||||
import com.google.common.base.Throwables;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -158,23 +157,20 @@ public class Storage<T extends Serializable> {
|
||||||
log.trace("Backup {} completed in {}msec", storageFile, System.currentTimeMillis() - now);
|
log.trace("Backup {} completed in {}msec", storageFile, System.currentTimeMillis() - now);
|
||||||
|
|
||||||
return persistedObject;
|
return persistedObject;
|
||||||
} catch (ClassCastException | IOException e) {
|
} catch (Throwable t) {
|
||||||
e.printStackTrace();
|
log.error("Version of persisted class has changed. We cannot read the persisted data anymore. " +
|
||||||
log.error("Version of persisted class has changed. We cannot read the persisted data anymore. We make a backup and remove the inconsistent " +
|
"We make a backup and remove the inconsistent file.");
|
||||||
"file.");
|
log.error(t.getMessage());
|
||||||
try {
|
try {
|
||||||
// In case the persisted data have been critical (keys) we keep a backup which might be used for recovery
|
// We keep a backup which might be used for recovery
|
||||||
fileManager.removeAndBackupFile(fileName);
|
fileManager.removeAndBackupFile(fileName);
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
log.error(e1.getMessage());
|
log.error(e1.getMessage());
|
||||||
// We swallow Exception if backup fails
|
// We swallow Exception if backup fails
|
||||||
}
|
}
|
||||||
databaseCorruptionHandler.onFileCorrupted(storageFile.getName());
|
if (databaseCorruptionHandler != null)
|
||||||
} catch (Throwable throwable) {
|
databaseCorruptionHandler.onFileCorrupted(storageFile.getName());
|
||||||
throwable.printStackTrace();
|
|
||||||
log.error(throwable.getMessage());
|
|
||||||
Throwables.propagate(throwable);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public final class Alert implements PubKeyProtectedExpirablePayload {
|
public final class Alert implements PubKeyProtectedExpirablePayload {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
private static final long TTL = TimeUnit.DAYS.toMillis(10);
|
private static final long TTL = TimeUnit.DAYS.toMillis(10);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public final class Arbitrator implements PubKeyProtectedExpirablePayload {
|
public final class Arbitrator implements PubKeyProtectedExpirablePayload {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
public static final long TTL = TimeUnit.DAYS.toMillis(10);
|
public static final long TTL = TimeUnit.DAYS.toMillis(10);
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ import java.util.List;
|
||||||
|
|
||||||
public class Dispute implements Serializable {
|
public class Dispute implements Serializable {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
private static final Logger log = LoggerFactory.getLogger(Dispute.class);
|
private static final Logger log = LoggerFactory.getLogger(Dispute.class);
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -32,7 +32,7 @@ import java.util.Date;
|
||||||
|
|
||||||
public class DisputeResult implements Serializable {
|
public class DisputeResult implements Serializable {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
private static final Logger log = LoggerFactory.getLogger(DisputeResult.class);
|
private static final Logger log = LoggerFactory.getLogger(DisputeResult.class);
|
||||||
|
|
||||||
public enum FeePaymentPolicy {
|
public enum FeePaymentPolicy {
|
||||||
|
|
|
@ -34,7 +34,7 @@ import java.util.List;
|
||||||
|
|
||||||
public final class DisputeDirectMessage extends DisputeMessage {
|
public final class DisputeDirectMessage extends DisputeMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
private static final Logger log = LoggerFactory.getLogger(DisputeDirectMessage.class);
|
private static final Logger log = LoggerFactory.getLogger(DisputeDirectMessage.class);
|
||||||
|
|
||||||
private final long date;
|
private final long date;
|
||||||
|
@ -188,7 +188,7 @@ public final class DisputeDirectMessage extends DisputeMessage {
|
||||||
|
|
||||||
public static class Attachment implements Serializable {
|
public static class Attachment implements Serializable {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
private static final Logger log = LoggerFactory.getLogger(Attachment.class);
|
private static final Logger log = LoggerFactory.getLogger(Attachment.class);
|
||||||
|
|
||||||
private final byte[] bytes;
|
private final byte[] bytes;
|
||||||
|
|
|
@ -21,10 +21,10 @@ import io.bitsquare.app.Version;
|
||||||
import io.bitsquare.p2p.messaging.MailboxMessage;
|
import io.bitsquare.p2p.messaging.MailboxMessage;
|
||||||
|
|
||||||
public abstract class DisputeMessage implements MailboxMessage {
|
public abstract class DisputeMessage implements MailboxMessage {
|
||||||
private final int networkId = Version.getNetworkId();
|
private final int messageVersion = Version.getP2PMessageVersion();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int networkId() {
|
public int getMessageVersion() {
|
||||||
return networkId;
|
return messageVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import io.bitsquare.p2p.NodeAddress;
|
||||||
|
|
||||||
public final class DisputeResultMessage extends DisputeMessage {
|
public final class DisputeResultMessage extends DisputeMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
public final DisputeResult disputeResult;
|
public final DisputeResult disputeResult;
|
||||||
private final NodeAddress myNodeAddress;
|
private final NodeAddress myNodeAddress;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import io.bitsquare.p2p.NodeAddress;
|
||||||
|
|
||||||
public final class OpenNewDisputeMessage extends DisputeMessage {
|
public final class OpenNewDisputeMessage extends DisputeMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
public final Dispute dispute;
|
public final Dispute dispute;
|
||||||
private final NodeAddress myNodeAddress;
|
private final NodeAddress myNodeAddress;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import io.bitsquare.p2p.NodeAddress;
|
||||||
|
|
||||||
public final class PeerOpenedDisputeMessage extends DisputeMessage {
|
public final class PeerOpenedDisputeMessage extends DisputeMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
public final Dispute dispute;
|
public final Dispute dispute;
|
||||||
private final NodeAddress myNodeAddress;
|
private final NodeAddress myNodeAddress;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Arrays;
|
||||||
|
|
||||||
public final class PeerPublishedPayoutTxMessage extends DisputeMessage {
|
public final class PeerPublishedPayoutTxMessage extends DisputeMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
public final byte[] transaction;
|
public final byte[] transaction;
|
||||||
public final String tradeId;
|
public final String tradeId;
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Arrays;
|
||||||
|
|
||||||
public class RawInput implements Serializable {
|
public class RawInput implements Serializable {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
public final long index;
|
public final long index;
|
||||||
public final byte[] parentTransaction;
|
public final byte[] parentTransaction;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.io.Serializable;
|
||||||
|
|
||||||
public class AliPayAccountContractData extends PaymentAccountContractData implements Serializable {
|
public class AliPayAccountContractData extends PaymentAccountContractData implements Serializable {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
private String accountNr;
|
private String accountNr;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.io.Serializable;
|
||||||
|
|
||||||
public class BlockChainAccountContractData extends PaymentAccountContractData implements Serializable {
|
public class BlockChainAccountContractData extends PaymentAccountContractData implements Serializable {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
private String address;
|
private String address;
|
||||||
// used in crypto note coins. not supported now but hopefully in future, so leave it for now.
|
// used in crypto note coins. not supported now but hopefully in future, so leave it for now.
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.io.Serializable;
|
||||||
|
|
||||||
public class OKPayAccountContractData extends PaymentAccountContractData implements Serializable {
|
public class OKPayAccountContractData extends PaymentAccountContractData implements Serializable {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
private String accountNr;
|
private String accountNr;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.io.Serializable;
|
||||||
|
|
||||||
public abstract class PaymentAccountContractData implements Serializable {
|
public abstract class PaymentAccountContractData implements Serializable {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
private final String paymentMethodName;
|
private final String paymentMethodName;
|
||||||
private final String id;
|
private final String id;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.io.Serializable;
|
||||||
|
|
||||||
public class PerfectMoneyAccountContractData extends PaymentAccountContractData implements Serializable {
|
public class PerfectMoneyAccountContractData extends PaymentAccountContractData implements Serializable {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
private String accountNr;
|
private String accountNr;
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class SepaAccountContractData extends PaymentAccountContractData implements Serializable {
|
public class SepaAccountContractData extends PaymentAccountContractData implements Serializable {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(SepaAccountContractData.class);
|
private static final Logger log = LoggerFactory.getLogger(SepaAccountContractData.class);
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.io.Serializable;
|
||||||
|
|
||||||
public class SwishAccountContractData extends PaymentAccountContractData implements Serializable {
|
public class SwishAccountContractData extends PaymentAccountContractData implements Serializable {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
private String mobileNr;
|
private String mobileNr;
|
||||||
private String holderName;
|
private String holderName;
|
||||||
|
|
|
@ -36,7 +36,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||||
public class Contract implements Serializable {
|
public class Contract implements Serializable {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
@JsonExclude
|
@JsonExclude
|
||||||
public static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
public static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
public final Offer offer;
|
public final Offer offer;
|
||||||
private final long tradeAmount;
|
private final long tradeAmount;
|
||||||
|
|
|
@ -49,7 +49,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
public final class Offer implements PubKeyProtectedExpirablePayload {
|
public final class Offer implements PubKeyProtectedExpirablePayload {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
@JsonExclude
|
@JsonExclude
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
@JsonExclude
|
@JsonExclude
|
||||||
private static final Logger log = LoggerFactory.getLogger(Offer.class);
|
private static final Logger log = LoggerFactory.getLogger(Offer.class);
|
||||||
|
|
||||||
|
@ -58,7 +58,6 @@ public final class Offer implements PubKeyProtectedExpirablePayload {
|
||||||
"take that offer.";
|
"take that offer.";
|
||||||
public static final String TAC_TAKER = "With taking the offer I commit to the trade conditions as defined.";
|
public static final String TAC_TAKER = "With taking the offer I commit to the trade conditions as defined.";
|
||||||
|
|
||||||
|
|
||||||
public enum Direction {BUY, SELL}
|
public enum Direction {BUY, SELL}
|
||||||
|
|
||||||
public enum State {
|
public enum State {
|
||||||
|
@ -71,12 +70,11 @@ public final class Offer implements PubKeyProtectedExpirablePayload {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// key attributes for lookup
|
|
||||||
private final String id;
|
private final String id;
|
||||||
private final Direction direction;
|
private final Direction direction;
|
||||||
private final String currencyCode;
|
private final String currencyCode;
|
||||||
private final long date;
|
private final long date;
|
||||||
|
private final long protocolVersion;
|
||||||
private final long fiatPrice;
|
private final long fiatPrice;
|
||||||
private final long amount;
|
private final long amount;
|
||||||
private final long minAmount;
|
private final long minAmount;
|
||||||
|
@ -138,6 +136,8 @@ public final class Offer implements PubKeyProtectedExpirablePayload {
|
||||||
this.arbitratorNodeAddresses = arbitratorNodeAddresses;
|
this.arbitratorNodeAddresses = arbitratorNodeAddresses;
|
||||||
this.acceptedCountryCodes = acceptedCountryCodes;
|
this.acceptedCountryCodes = acceptedCountryCodes;
|
||||||
|
|
||||||
|
protocolVersion = Version.TRADE_PROTOCOL_VERSION;
|
||||||
|
|
||||||
date = new Date().getTime();
|
date = new Date().getTime();
|
||||||
setState(State.UNDEFINED);
|
setState(State.UNDEFINED);
|
||||||
}
|
}
|
||||||
|
@ -258,6 +258,9 @@ public final class Offer implements PubKeyProtectedExpirablePayload {
|
||||||
return pubKeyRing.getSignaturePubKey();
|
return pubKeyRing.getSignaturePubKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getProtocolVersion() {
|
||||||
|
return protocolVersion;
|
||||||
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
|
|
|
@ -22,7 +22,7 @@ import io.bitsquare.common.crypto.PubKeyRing;
|
||||||
|
|
||||||
public final class OfferAvailabilityRequest extends OfferMessage {
|
public final class OfferAvailabilityRequest extends OfferMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
private final PubKeyRing pubKeyRing;
|
private final PubKeyRing pubKeyRing;
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import io.bitsquare.app.Version;
|
||||||
|
|
||||||
public final class OfferAvailabilityResponse extends OfferMessage {
|
public final class OfferAvailabilityResponse extends OfferMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
public final boolean isAvailable;
|
public final boolean isAvailable;
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,9 @@ import javax.annotation.concurrent.Immutable;
|
||||||
@Immutable
|
@Immutable
|
||||||
public abstract class OfferMessage implements DirectMessage {
|
public abstract class OfferMessage implements DirectMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
private final int networkId = Version.getNetworkId();
|
private final int messageVersion = Version.getP2PMessageVersion();
|
||||||
public final String offerId;
|
public final String offerId;
|
||||||
|
|
||||||
protected OfferMessage(String offerId) {
|
protected OfferMessage(String offerId) {
|
||||||
|
@ -35,14 +35,14 @@ public abstract class OfferMessage implements DirectMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int networkId() {
|
public int getMessageVersion() {
|
||||||
return networkId;
|
return messageVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "OfferMessage{" +
|
return "OfferMessage{" +
|
||||||
"networkId=" + networkId +
|
"messageVersion=" + messageVersion +
|
||||||
", offerId='" + offerId + '\'' +
|
", offerId='" + offerId + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Arrays;
|
||||||
@Immutable
|
@Immutable
|
||||||
public final class DepositTxPublishedMessage extends TradeMessage implements MailboxMessage {
|
public final class DepositTxPublishedMessage extends TradeMessage implements MailboxMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
public final byte[] depositTx;
|
public final byte[] depositTx;
|
||||||
private final NodeAddress senderNodeAddress;
|
private final NodeAddress senderNodeAddress;
|
||||||
|
|
|
@ -26,7 +26,7 @@ import javax.annotation.concurrent.Immutable;
|
||||||
@Immutable
|
@Immutable
|
||||||
public final class FiatTransferStartedMessage extends TradeMessage implements MailboxMessage {
|
public final class FiatTransferStartedMessage extends TradeMessage implements MailboxMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
public final String buyerPayoutAddress;
|
public final String buyerPayoutAddress;
|
||||||
private final NodeAddress senderNodeAddress;
|
private final NodeAddress senderNodeAddress;
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Arrays;
|
||||||
@Immutable
|
@Immutable
|
||||||
public final class FinalizePayoutTxRequest extends TradeMessage implements MailboxMessage {
|
public final class FinalizePayoutTxRequest extends TradeMessage implements MailboxMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
public final byte[] sellerSignature;
|
public final byte[] sellerSignature;
|
||||||
public final String sellerPayoutAddress;
|
public final String sellerPayoutAddress;
|
||||||
|
|
|
@ -31,7 +31,7 @@ import java.util.List;
|
||||||
@Immutable
|
@Immutable
|
||||||
public final class PayDepositRequest extends TradeMessage implements MailboxMessage {
|
public final class PayDepositRequest extends TradeMessage implements MailboxMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
public final long tradeAmount;
|
public final long tradeAmount;
|
||||||
public final byte[] takerTradeWalletPubKey;
|
public final byte[] takerTradeWalletPubKey;
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Arrays;
|
||||||
@Immutable
|
@Immutable
|
||||||
public final class PayoutTxFinalizedMessage extends TradeMessage implements MailboxMessage {
|
public final class PayoutTxFinalizedMessage extends TradeMessage implements MailboxMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
public final byte[] payoutTx;
|
public final byte[] payoutTx;
|
||||||
private final NodeAddress senderNodeAddress;
|
private final NodeAddress senderNodeAddress;
|
||||||
|
|
|
@ -31,7 +31,7 @@ import java.util.List;
|
||||||
@Immutable
|
@Immutable
|
||||||
public final class PublishDepositTxRequest extends TradeMessage {
|
public final class PublishDepositTxRequest extends TradeMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(PublishDepositTxRequest.class);
|
private static final Logger log = LoggerFactory.getLogger(PublishDepositTxRequest.class);
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,9 @@ import javax.annotation.concurrent.Immutable;
|
||||||
@Immutable
|
@Immutable
|
||||||
public abstract class TradeMessage implements DirectMessage {
|
public abstract class TradeMessage implements DirectMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
private final int networkId = Version.getNetworkId();
|
private final int messageVersion = Version.getP2PMessageVersion();
|
||||||
public final String tradeId;
|
public final String tradeId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,7 +51,7 @@ public abstract class TradeMessage implements DirectMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int networkId() {
|
public int getMessageVersion() {
|
||||||
return networkId;
|
return messageVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,18 +128,24 @@ public class BitsquareApp extends Application {
|
||||||
injector = Guice.createInjector(bitsquareAppModule);
|
injector = Guice.createInjector(bitsquareAppModule);
|
||||||
injector.getInstance(InjectorViewFactory.class).setInjector(injector);
|
injector.getInstance(InjectorViewFactory.class).setInjector(injector);
|
||||||
|
|
||||||
Version.setNetworkId(injector.getInstance(BitsquareEnvironment.class).getBitcoinNetwork().ordinal());
|
Version.setBtcNetworkId(injector.getInstance(BitsquareEnvironment.class).getBitcoinNetwork().ordinal());
|
||||||
|
|
||||||
// load the main view and create the main scene
|
|
||||||
CachingViewLoader viewLoader = injector.getInstance(CachingViewLoader.class);
|
|
||||||
mainView = (MainView) viewLoader.load(MainView.class);
|
|
||||||
mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
|
|
||||||
|
|
||||||
Storage.setDatabaseCorruptionHandler((String fileName) -> {
|
Storage.setDatabaseCorruptionHandler((String fileName) -> {
|
||||||
corruptedDatabaseFiles.add(fileName);
|
corruptedDatabaseFiles.add(fileName);
|
||||||
if (mainView != null)
|
if (mainView != null)
|
||||||
mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
|
mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// load the main view and create the main scene
|
||||||
|
CachingViewLoader viewLoader = injector.getInstance(CachingViewLoader.class);
|
||||||
|
mainView = (MainView) viewLoader.load(MainView.class);
|
||||||
|
mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
|
||||||
|
|
||||||
|
/* Storage.setDatabaseCorruptionHandler((String fileName) -> {
|
||||||
|
corruptedDatabaseFiles.add(fileName);
|
||||||
|
if (mainView != null)
|
||||||
|
mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
|
||||||
|
});*/
|
||||||
|
|
||||||
scene = new Scene(mainView.getRoot(), 1000, 740);
|
scene = new Scene(mainView.getRoot(), 1000, 740);
|
||||||
scene.getStylesheets().setAll(
|
scene.getStylesheets().setAll(
|
||||||
|
|
|
@ -73,7 +73,8 @@ public class AddressTextField extends AnchorPane {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
textField.focusTraversableProperty().set(focusTraversableProperty().get());
|
textField.focusTraversableProperty().set(focusTraversableProperty().get());
|
||||||
focusedProperty().addListener((ov, oldValue, newValue) -> textField.requestFocus());
|
//TODO app wide focus
|
||||||
|
//focusedProperty().addListener((ov, oldValue, newValue) -> textField.requestFocus());
|
||||||
|
|
||||||
Label copyIcon = new Label();
|
Label copyIcon = new Label();
|
||||||
copyIcon.setLayoutY(3);
|
copyIcon.setLayoutY(3);
|
||||||
|
|
|
@ -67,7 +67,8 @@ public class TextFieldWithCopyIcon extends AnchorPane {
|
||||||
AnchorPane.setRightAnchor(textField, 30.0);
|
AnchorPane.setRightAnchor(textField, 30.0);
|
||||||
AnchorPane.setLeftAnchor(textField, 0.0);
|
AnchorPane.setLeftAnchor(textField, 0.0);
|
||||||
textField.focusTraversableProperty().set(focusTraversableProperty().get());
|
textField.focusTraversableProperty().set(focusTraversableProperty().get());
|
||||||
focusedProperty().addListener((ov, oldValue, newValue) -> textField.requestFocus());
|
//TODO app wide focus
|
||||||
|
//focusedProperty().addListener((ov, oldValue, newValue) -> textField.requestFocus());
|
||||||
|
|
||||||
getChildren().addAll(textField, copyIcon);
|
getChildren().addAll(textField, copyIcon);
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,8 @@ public class TxIdTextField extends AnchorPane {
|
||||||
AnchorPane.setRightAnchor(textField, 55.0);
|
AnchorPane.setRightAnchor(textField, 55.0);
|
||||||
AnchorPane.setLeftAnchor(textField, 0.0);
|
AnchorPane.setLeftAnchor(textField, 0.0);
|
||||||
textField.focusTraversableProperty().set(focusTraversableProperty().get());
|
textField.focusTraversableProperty().set(focusTraversableProperty().get());
|
||||||
focusedProperty().addListener((ov, oldValue, newValue) -> textField.requestFocus());
|
//TODO app wide focus
|
||||||
|
//focusedProperty().addListener((ov, oldValue, newValue) -> textField.requestFocus());
|
||||||
|
|
||||||
getChildren().addAll(textField, copyIcon, progressIndicator);
|
getChildren().addAll(textField, copyIcon, progressIndicator);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package io.bitsquare.gui.main;
|
package io.bitsquare.gui.main;
|
||||||
|
|
||||||
import io.bitsquare.BitsquareException;
|
import io.bitsquare.BitsquareException;
|
||||||
|
import io.bitsquare.app.BitsquareApp;
|
||||||
import io.bitsquare.common.UserThread;
|
import io.bitsquare.common.UserThread;
|
||||||
import io.bitsquare.common.util.Tuple2;
|
import io.bitsquare.common.util.Tuple2;
|
||||||
import io.bitsquare.gui.Navigation;
|
import io.bitsquare.gui.Navigation;
|
||||||
|
@ -184,11 +185,18 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||||
|
|
||||||
if (!persistedFilesCorrupted.isEmpty()) {
|
if (!persistedFilesCorrupted.isEmpty()) {
|
||||||
// show warning that some files has been corrupted
|
// show warning that some files has been corrupted
|
||||||
new Popup().warning("Those data base file(s) are not compatible with our current code base." +
|
new Popup().warning("We detected incompatible data base files!\n\n" +
|
||||||
"\n" + persistedFilesCorrupted.toString() +
|
"Those database file(s) are not compatible with our current code base:" +
|
||||||
"\n\nWe made a backup of the corrupted file(s) and applied the default values." +
|
"\n" + persistedFilesCorrupted.toString() +
|
||||||
"\n\nThe backup is located at: [data directory]/db/corrupted"
|
"\n\nWe made a backup of the corrupted file(s) and applied the default values to a new " +
|
||||||
).show();
|
"database version." +
|
||||||
|
"\n\nThe backup is located at:\n[you local app data directory]/db/backup_of_corrupted_data.\n\n" +
|
||||||
|
"Please check if you have the latest version of Bitsquare installed.\n" +
|
||||||
|
"You can download it at:\nhttps://github.com/bitsquare/bitsquare/releases\n\n" +
|
||||||
|
"Please restart the application.")
|
||||||
|
.closeButtonText("Shut down")
|
||||||
|
.onClose(BitsquareApp.shutDownHandler::run)
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
transitions.fadeOutAndRemove(splashScreen, 1500, actionEvent -> disposeSplashScreen());
|
transitions.fadeOutAndRemove(splashScreen, 1500, actionEvent -> disposeSplashScreen());
|
||||||
|
@ -358,7 +366,8 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||||
model.walletServiceErrorMsg.addListener((ov, oldValue, newValue) -> {
|
model.walletServiceErrorMsg.addListener((ov, oldValue, newValue) -> {
|
||||||
if (newValue != null) {
|
if (newValue != null) {
|
||||||
btcInfoLabel.setId("splash-error-state-msg");
|
btcInfoLabel.setId("splash-error-state-msg");
|
||||||
btcNetworkWarnMsgPopup = new Popup().warning(newValue).show();
|
btcNetworkWarnMsgPopup = new Popup().warning(newValue);
|
||||||
|
btcNetworkWarnMsgPopup.show();
|
||||||
} else {
|
} else {
|
||||||
btcInfoLabel.setId("footer-pane");
|
btcInfoLabel.setId("footer-pane");
|
||||||
if (btcNetworkWarnMsgPopup != null)
|
if (btcNetworkWarnMsgPopup != null)
|
||||||
|
@ -407,7 +416,8 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||||
p2PNetworkLabel.idProperty().bind(model.p2PNetworkLabelId);
|
p2PNetworkLabel.idProperty().bind(model.p2PNetworkLabelId);
|
||||||
model.p2PNetworkWarnMsg.addListener((ov, oldValue, newValue) -> {
|
model.p2PNetworkWarnMsg.addListener((ov, oldValue, newValue) -> {
|
||||||
if (newValue != null) {
|
if (newValue != null) {
|
||||||
p2PNetworkWarnMsgPopup = new Popup().warning(newValue).show();
|
p2PNetworkWarnMsgPopup = new Popup().warning(newValue);
|
||||||
|
p2PNetworkWarnMsgPopup.show();
|
||||||
} else if (p2PNetworkWarnMsgPopup != null) {
|
} else if (p2PNetworkWarnMsgPopup != null) {
|
||||||
p2PNetworkWarnMsgPopup.hide();
|
p2PNetworkWarnMsgPopup.hide();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,9 @@ import io.bitsquare.locale.CountryUtil;
|
||||||
import io.bitsquare.locale.CurrencyUtil;
|
import io.bitsquare.locale.CurrencyUtil;
|
||||||
import io.bitsquare.p2p.P2PService;
|
import io.bitsquare.p2p.P2PService;
|
||||||
import io.bitsquare.p2p.P2PServiceListener;
|
import io.bitsquare.p2p.P2PServiceListener;
|
||||||
|
import io.bitsquare.p2p.network.CloseConnectionReason;
|
||||||
|
import io.bitsquare.p2p.network.Connection;
|
||||||
|
import io.bitsquare.p2p.network.ConnectionListener;
|
||||||
import io.bitsquare.payment.OKPayAccount;
|
import io.bitsquare.payment.OKPayAccount;
|
||||||
import io.bitsquare.trade.Trade;
|
import io.bitsquare.trade.Trade;
|
||||||
import io.bitsquare.trade.TradeManager;
|
import io.bitsquare.trade.TradeManager;
|
||||||
|
@ -187,7 +190,7 @@ public class MainViewModel implements ViewModel {
|
||||||
"There might be some network connection problems.\n\n" +
|
"There might be some network connection problems.\n\n" +
|
||||||
"Please restart and try again.")
|
"Please restart and try again.")
|
||||||
.closeButtonText("Shut down")
|
.closeButtonText("Shut down")
|
||||||
.onClose(() -> BitsquareApp.shutDownHandler.run())
|
.onClose(BitsquareApp.shutDownHandler::run)
|
||||||
.show();
|
.show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -211,6 +214,34 @@ public class MainViewModel implements ViewModel {
|
||||||
private BooleanProperty initP2PNetwork() {
|
private BooleanProperty initP2PNetwork() {
|
||||||
final BooleanProperty p2pNetworkInitialized = new SimpleBooleanProperty();
|
final BooleanProperty p2pNetworkInitialized = new SimpleBooleanProperty();
|
||||||
p2PNetworkInfo.set("Connecting to Tor network...");
|
p2PNetworkInfo.set("Connecting to Tor network...");
|
||||||
|
p2PService.getNetworkNode().addConnectionListener(new ConnectionListener() {
|
||||||
|
@Override
|
||||||
|
public void onConnection(Connection connection) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisconnect(CloseConnectionReason closeConnectionReason, Connection connection) {
|
||||||
|
// We only check at seed nodes as they are running the latest version
|
||||||
|
// Other disconnects might be caused by peers running an older version
|
||||||
|
if (connection.getPeerType() == Connection.PeerType.SEED_NODE &&
|
||||||
|
closeConnectionReason == CloseConnectionReason.RULE_VIOLATION) {
|
||||||
|
new Popup()
|
||||||
|
.warning("You got disconnected from a seed node.\n\n" +
|
||||||
|
"Reason for getting disconnected: " + connection.getRuleViolation().name() + "\n\n" +
|
||||||
|
"It might be that your installed version is not compatible with " +
|
||||||
|
"the network.\n\n" +
|
||||||
|
"Please check if you run the latest software version.\n" +
|
||||||
|
"You can download the latest version of Bitsquare at:\n" +
|
||||||
|
"https://github.com/bitsquare/bitsquare/releases/\n\n" +
|
||||||
|
"")
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable throwable) {
|
||||||
|
}
|
||||||
|
});
|
||||||
p2PService.start(new P2PServiceListener() {
|
p2PService.start(new P2PServiceListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTorNodeReady() {
|
public void onTorNodeReady() {
|
||||||
|
@ -348,8 +379,9 @@ public class MainViewModel implements ViewModel {
|
||||||
if (walletService.getWallet().isEncrypted() &&
|
if (walletService.getWallet().isEncrypted() &&
|
||||||
(openOfferManager.getOpenOffers().size() > 0
|
(openOfferManager.getOpenOffers().size() > 0
|
||||||
|| tradeManager.getTrades().size() > 0
|
|| tradeManager.getTrades().size() > 0
|
||||||
|| disputeManager.getDisputesAsObservableList().size() > 0))
|
|| disputeManager.getDisputesAsObservableList().size() > 0)) {
|
||||||
walletPasswordPopup.show().onAesKey(aesKey -> tradeWalletService.setAesKey(aesKey));
|
walletPasswordPopup.onAesKey(aesKey -> tradeWalletService.setAesKey(aesKey)).show();
|
||||||
|
}
|
||||||
|
|
||||||
if (tradeManager.pendingTradesInitializedProperty().get() && isSplashScreenRemoved.get())
|
if (tradeManager.pendingTradesInitializedProperty().get() && isSplashScreenRemoved.get())
|
||||||
applyTradePeriodState();
|
applyTradePeriodState();
|
||||||
|
|
|
@ -24,6 +24,7 @@ import io.bitsquare.common.UserThread;
|
||||||
import io.bitsquare.common.util.Tuple2;
|
import io.bitsquare.common.util.Tuple2;
|
||||||
import io.bitsquare.gui.common.view.ActivatableViewAndModel;
|
import io.bitsquare.gui.common.view.ActivatableViewAndModel;
|
||||||
import io.bitsquare.gui.common.view.FxmlView;
|
import io.bitsquare.gui.common.view.FxmlView;
|
||||||
|
import io.bitsquare.gui.popups.EnterPrivKeyPopup;
|
||||||
import io.bitsquare.gui.popups.Popup;
|
import io.bitsquare.gui.popups.Popup;
|
||||||
import io.bitsquare.gui.util.FormBuilder;
|
import io.bitsquare.gui.util.FormBuilder;
|
||||||
import io.bitsquare.gui.util.ImageUtil;
|
import io.bitsquare.gui.util.ImageUtil;
|
||||||
|
|
|
@ -114,13 +114,13 @@ public class SeedWordsView extends ActivatableView<GridPane, Void> {
|
||||||
|
|
||||||
|
|
||||||
private void askForPassword() {
|
private void askForPassword() {
|
||||||
walletPasswordPopup.show().onAesKey(aesKey -> {
|
walletPasswordPopup.onAesKey(aesKey -> {
|
||||||
Wallet wallet = walletService.getWallet();
|
Wallet wallet = walletService.getWallet();
|
||||||
KeyCrypter keyCrypter = wallet.getKeyCrypter();
|
KeyCrypter keyCrypter = wallet.getKeyCrypter();
|
||||||
keyChainSeed = wallet.getKeyChainSeed();
|
keyChainSeed = wallet.getKeyChainSeed();
|
||||||
DeterministicSeed decryptedSeed = keyChainSeed.decrypt(keyCrypter, "", aesKey);
|
DeterministicSeed decryptedSeed = keyChainSeed.decrypt(keyCrypter, "", aesKey);
|
||||||
showSeedScreen(decryptedSeed);
|
showSeedScreen(decryptedSeed);
|
||||||
});
|
}).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showSeedScreen(DeterministicSeed seed) {
|
private void showSeedScreen(DeterministicSeed seed) {
|
||||||
|
|
|
@ -21,9 +21,9 @@ import io.bitsquare.arbitration.Dispute;
|
||||||
import io.bitsquare.arbitration.DisputeManager;
|
import io.bitsquare.arbitration.DisputeManager;
|
||||||
import io.bitsquare.common.crypto.KeyRing;
|
import io.bitsquare.common.crypto.KeyRing;
|
||||||
import io.bitsquare.gui.common.view.FxmlView;
|
import io.bitsquare.gui.common.view.FxmlView;
|
||||||
import io.bitsquare.gui.main.disputes.DisputeSummaryPopup;
|
|
||||||
import io.bitsquare.gui.main.disputes.trader.TraderDisputeView;
|
import io.bitsquare.gui.main.disputes.trader.TraderDisputeView;
|
||||||
import io.bitsquare.gui.popups.ContractPopup;
|
import io.bitsquare.gui.popups.ContractPopup;
|
||||||
|
import io.bitsquare.gui.popups.DisputeSummaryPopup;
|
||||||
import io.bitsquare.gui.popups.TradeDetailsPopup;
|
import io.bitsquare.gui.popups.TradeDetailsPopup;
|
||||||
import io.bitsquare.gui.util.BSFormatter;
|
import io.bitsquare.gui.util.BSFormatter;
|
||||||
import io.bitsquare.trade.TradeManager;
|
import io.bitsquare.trade.TradeManager;
|
||||||
|
|
|
@ -29,8 +29,8 @@ import io.bitsquare.gui.common.view.ActivatableView;
|
||||||
import io.bitsquare.gui.common.view.FxmlView;
|
import io.bitsquare.gui.common.view.FxmlView;
|
||||||
import io.bitsquare.gui.components.HyperlinkWithIcon;
|
import io.bitsquare.gui.components.HyperlinkWithIcon;
|
||||||
import io.bitsquare.gui.components.TableGroupHeadline;
|
import io.bitsquare.gui.components.TableGroupHeadline;
|
||||||
import io.bitsquare.gui.main.disputes.DisputeSummaryPopup;
|
|
||||||
import io.bitsquare.gui.popups.ContractPopup;
|
import io.bitsquare.gui.popups.ContractPopup;
|
||||||
|
import io.bitsquare.gui.popups.DisputeSummaryPopup;
|
||||||
import io.bitsquare.gui.popups.Popup;
|
import io.bitsquare.gui.popups.Popup;
|
||||||
import io.bitsquare.gui.popups.TradeDetailsPopup;
|
import io.bitsquare.gui.popups.TradeDetailsPopup;
|
||||||
import io.bitsquare.gui.util.BSFormatter;
|
import io.bitsquare.gui.util.BSFormatter;
|
||||||
|
|
|
@ -310,10 +310,11 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doWithdraw(Coin amount, FutureCallback<Transaction> callback) {
|
private void doWithdraw(Coin amount, FutureCallback<Transaction> callback) {
|
||||||
if (walletService.getWallet().isEncrypted())
|
if (walletService.getWallet().isEncrypted()) {
|
||||||
walletPasswordPopup.show().onAesKey(aesKey -> sendFunds(amount, aesKey, callback));
|
walletPasswordPopup.onAesKey(aesKey -> sendFunds(amount, aesKey, callback)).show();
|
||||||
else
|
} else {
|
||||||
sendFunds(amount, null, callback);
|
sendFunds(amount, null, callback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendFunds(Coin amount, KeyParameter aesKey, FutureCallback<Transaction> callback) {
|
private void sendFunds(Coin amount, KeyParameter aesKey, FutureCallback<Transaction> callback) {
|
||||||
|
|
|
@ -253,10 +253,10 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
||||||
|
|
||||||
void onPlaceOffer(Offer offer, TransactionResultHandler resultHandler) {
|
void onPlaceOffer(Offer offer, TransactionResultHandler resultHandler) {
|
||||||
if (walletService.getWallet().isEncrypted() && tradeWalletService.getAesKey() == null) {
|
if (walletService.getWallet().isEncrypted() && tradeWalletService.getAesKey() == null) {
|
||||||
walletPasswordPopup.show().onAesKey(aesKey -> {
|
walletPasswordPopup.onAesKey(aesKey -> {
|
||||||
tradeWalletService.setAesKey(aesKey);
|
tradeWalletService.setAesKey(aesKey);
|
||||||
doPlaceOffer(offer, resultHandler);
|
doPlaceOffer(offer, resultHandler);
|
||||||
});
|
}).show();
|
||||||
} else {
|
} else {
|
||||||
doPlaceOffer(offer, resultHandler);
|
doPlaceOffer(offer, resultHandler);
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,7 +220,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onShowInfo(boolean isPaymentAccountValidForOffer, boolean hasMatchingArbitrator) {
|
private void onShowInfo(boolean isPaymentAccountValidForOffer, boolean hasMatchingArbitrator, boolean hasSameProtocolVersion) {
|
||||||
if (!hasMatchingArbitrator) {
|
if (!hasMatchingArbitrator) {
|
||||||
showWarning("You don't have an arbitrator selected.",
|
showWarning("You don't have an arbitrator selected.",
|
||||||
"You need to setup at least one arbitrator to be able to trade.\n" +
|
"You need to setup at least one arbitrator to be able to trade.\n" +
|
||||||
|
@ -229,6 +229,13 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
showWarning("You don't have a payment account with the payment method required for that offer.",
|
showWarning("You don't have a payment account with the payment method required for that offer.",
|
||||||
"You need to setup a payment account with that payment method if you want to take that offer.\n" +
|
"You need to setup a payment account with that payment method if you want to take that offer.\n" +
|
||||||
"Do you want to do this now?", PaymentAccountView.class);
|
"Do you want to do this now?", PaymentAccountView.class);
|
||||||
|
} else if (!hasSameProtocolVersion) {
|
||||||
|
new Popup().information("That offer requires a different protocol version as the one used in your " +
|
||||||
|
"version of the software." +
|
||||||
|
"\n\n" + "Please check if you have the latest version installed, otherwise the user " +
|
||||||
|
"who created the offer has used an older version.\n" +
|
||||||
|
"You cannot trade with an incompatible protocol version.")
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,39 +425,42 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
boolean isTradable;
|
boolean isTradable;
|
||||||
boolean isPaymentAccountValidForOffer;
|
boolean isPaymentAccountValidForOffer;
|
||||||
boolean hasMatchingArbitrator;
|
boolean hasMatchingArbitrator;
|
||||||
|
boolean hasSameProtocolVersion;
|
||||||
|
|
||||||
{
|
{
|
||||||
button.setGraphic(iconView);
|
button.setGraphic(iconView);
|
||||||
button.setMinWidth(70);
|
button.setMinWidth(70);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyIfTradable(final Offer offer) {
|
|
||||||
TableRow tableRow = getTableRow();
|
|
||||||
if (tableRow != null) {
|
|
||||||
isPaymentAccountValidForOffer = model.isPaymentAccountValidForOffer(offer);
|
|
||||||
hasMatchingArbitrator = model.hasMatchingArbitrator(offer);
|
|
||||||
isTradable = isPaymentAccountValidForOffer && hasMatchingArbitrator;
|
|
||||||
|
|
||||||
tableRow.setOpacity(isTradable ? 1 : 0.4);
|
|
||||||
|
|
||||||
if (isTradable) {
|
|
||||||
// set first row button as default
|
|
||||||
button.setDefaultButton(getIndex() == 0);
|
|
||||||
tableRow.setOnMouseClicked(null);
|
|
||||||
} else {
|
|
||||||
button.setDefaultButton(false);
|
|
||||||
tableRow.setOnMouseClicked(e -> onShowInfo(isPaymentAccountValidForOffer, hasMatchingArbitrator));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateItem(final OfferBookListItem newItem, boolean empty) {
|
public void updateItem(final OfferBookListItem newItem, boolean empty) {
|
||||||
super.updateItem(newItem, empty);
|
super.updateItem(newItem, empty);
|
||||||
|
|
||||||
if (newItem != null && !empty) {
|
if (newItem != null && !empty) {
|
||||||
final Offer offer = newItem.getOffer();
|
final Offer offer = newItem.getOffer();
|
||||||
verifyIfTradable(offer);
|
|
||||||
|
TableRow tableRow = getTableRow();
|
||||||
|
if (tableRow != null) {
|
||||||
|
isPaymentAccountValidForOffer = model.isPaymentAccountValidForOffer(offer);
|
||||||
|
hasMatchingArbitrator = model.hasMatchingArbitrator(offer);
|
||||||
|
hasSameProtocolVersion = model.hasSameProtocolVersion(offer);
|
||||||
|
isTradable = isPaymentAccountValidForOffer && hasMatchingArbitrator &&
|
||||||
|
hasSameProtocolVersion;
|
||||||
|
|
||||||
|
tableRow.setOpacity(isTradable ? 1 : 0.4);
|
||||||
|
|
||||||
|
if (isTradable) {
|
||||||
|
// set first row button as default
|
||||||
|
button.setDefaultButton(getIndex() == 0);
|
||||||
|
tableRow.setOnMouseClicked(null);
|
||||||
|
} else {
|
||||||
|
button.setDefaultButton(false);
|
||||||
|
tableRow.setOnMouseClicked(e ->
|
||||||
|
onShowInfo(isPaymentAccountValidForOffer, hasMatchingArbitrator,
|
||||||
|
hasSameProtocolVersion));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String title;
|
String title;
|
||||||
if (isTradable) {
|
if (isTradable) {
|
||||||
if (model.isMyOffer(offer)) {
|
if (model.isMyOffer(offer)) {
|
||||||
|
@ -465,7 +475,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
} else {
|
} else {
|
||||||
title = "Not matching";
|
title = "Not matching";
|
||||||
iconView.setId(null);
|
iconView.setId(null);
|
||||||
button.setOnAction(e -> onShowInfo(isPaymentAccountValidForOffer, hasMatchingArbitrator));
|
button.setOnAction(e -> onShowInfo(isPaymentAccountValidForOffer, hasMatchingArbitrator, hasSameProtocolVersion));
|
||||||
}
|
}
|
||||||
|
|
||||||
button.setText(title);
|
button.setText(title);
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package io.bitsquare.gui.main.offer.offerbook;
|
package io.bitsquare.gui.main.offer.offerbook;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import io.bitsquare.app.Version;
|
||||||
import io.bitsquare.common.handlers.ErrorMessageHandler;
|
import io.bitsquare.common.handlers.ErrorMessageHandler;
|
||||||
import io.bitsquare.common.handlers.ResultHandler;
|
import io.bitsquare.common.handlers.ResultHandler;
|
||||||
import io.bitsquare.gui.common.model.ActivatableViewModel;
|
import io.bitsquare.gui.common.model.ActivatableViewModel;
|
||||||
|
@ -281,7 +282,6 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean hasMatchingArbitrator(Offer offer) {
|
public boolean hasMatchingArbitrator(Offer offer) {
|
||||||
for (NodeAddress offerArbitratorNodeAddress : offer.getArbitratorNodeAddresses()) {
|
for (NodeAddress offerArbitratorNodeAddress : offer.getArbitratorNodeAddresses()) {
|
||||||
for (NodeAddress acceptedArbitratorNodeAddress : user.getAcceptedArbitratorAddresses()) {
|
for (NodeAddress acceptedArbitratorNodeAddress : user.getAcceptedArbitratorAddresses()) {
|
||||||
|
@ -291,4 +291,8 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasSameProtocolVersion(Offer offer) {
|
||||||
|
return offer.getProtocolVersion() == Version.TRADE_PROTOCOL_VERSION;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,10 +167,10 @@ class TakeOfferDataModel extends ActivatableDataModel {
|
||||||
// have it persisted as well.
|
// have it persisted as well.
|
||||||
void onTakeOffer(TradeResultHandler tradeResultHandler) {
|
void onTakeOffer(TradeResultHandler tradeResultHandler) {
|
||||||
if (walletService.getWallet().isEncrypted() && tradeWalletService.getAesKey() == null) {
|
if (walletService.getWallet().isEncrypted() && tradeWalletService.getAesKey() == null) {
|
||||||
walletPasswordPopup.show().onAesKey(aesKey -> {
|
walletPasswordPopup.onAesKey(aesKey -> {
|
||||||
tradeWalletService.setAesKey(aesKey);
|
tradeWalletService.setAesKey(aesKey);
|
||||||
doTakeOffer(tradeResultHandler);
|
doTakeOffer(tradeResultHandler);
|
||||||
});
|
}).show();
|
||||||
} else {
|
} else {
|
||||||
doTakeOffer(tradeResultHandler);
|
doTakeOffer(tradeResultHandler);
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,11 +182,11 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
|
||||||
.subscribe((observable, oldValue, newValue) -> {
|
.subscribe((observable, oldValue, newValue) -> {
|
||||||
if (!oldValue && newValue) {
|
if (!oldValue && newValue) {
|
||||||
isOfferAvailablePopup = new Popup().information(BSResources.get("takeOffer.fundsBox.isOfferAvailable"))
|
isOfferAvailablePopup = new Popup().information(BSResources.get("takeOffer.fundsBox.isOfferAvailable"))
|
||||||
.show()
|
|
||||||
.onClose(() -> {
|
.onClose(() -> {
|
||||||
model.resetErrorMessage();
|
model.resetErrorMessage();
|
||||||
close();
|
close();
|
||||||
}).show();
|
});
|
||||||
|
isOfferAvailablePopup.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -170,9 +170,9 @@ public class PendingTradesDataModel extends ActivatableDataModel {
|
||||||
|
|
||||||
void onWithdrawRequest(String toAddress) {
|
void onWithdrawRequest(String toAddress) {
|
||||||
checkNotNull(trade, "trade must not be null");
|
checkNotNull(trade, "trade must not be null");
|
||||||
if (walletService.getWallet().isEncrypted())
|
if (walletService.getWallet().isEncrypted()) {
|
||||||
walletPasswordPopup.show().onAesKey(aesKey -> doWithdrawRequest(toAddress, aesKey));
|
walletPasswordPopup.onAesKey(aesKey -> doWithdrawRequest(toAddress, aesKey)).show();
|
||||||
else
|
} else
|
||||||
doWithdrawRequest(toAddress, null);
|
doWithdrawRequest(toAddress, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,8 +110,9 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
|
||||||
// Focus selectedItem from model
|
// Focus selectedItem from model
|
||||||
int index = table.getItems().indexOf(model.getSelectedItem());
|
int index = table.getItems().indexOf(model.getSelectedItem());
|
||||||
UserThread.execute(() -> {
|
UserThread.execute(() -> {
|
||||||
table.requestFocus();
|
//TODO app wide focus
|
||||||
UserThread.execute(() -> table.getFocusModel().focus(index));
|
//table.requestFocus();
|
||||||
|
//UserThread.execute(() -> table.getFocusModel().focus(index));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -151,9 +152,10 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
|
||||||
// Select and focus selectedItem from model
|
// Select and focus selectedItem from model
|
||||||
int index = table.getItems().indexOf(selectedItem);
|
int index = table.getItems().indexOf(selectedItem);
|
||||||
UserThread.execute(() -> {
|
UserThread.execute(() -> {
|
||||||
|
//TODO app wide focus
|
||||||
table.getSelectionModel().select(index);
|
table.getSelectionModel().select(index);
|
||||||
table.requestFocus();
|
//table.requestFocus();
|
||||||
UserThread.execute(() -> table.getFocusModel().focus(index));
|
//UserThread.execute(() -> table.getFocusModel().focus(index));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,11 +69,12 @@ public class CompletedView extends TradeStepDetailsView {
|
||||||
// We need to handle both cases: Address not set and address already set (when returning from other view)
|
// We need to handle both cases: Address not set and address already set (when returning from other view)
|
||||||
// We get address validation after focus out, so first make sure we loose focus and then set it again as hint for user to put address in
|
// We get address validation after focus out, so first make sure we loose focus and then set it again as hint for user to put address in
|
||||||
UserThread.execute(() -> {
|
UserThread.execute(() -> {
|
||||||
withdrawAddressTextField.requestFocus();
|
//TODO app wide focus
|
||||||
UserThread.execute(() -> {
|
// withdrawAddressTextField.requestFocus();
|
||||||
|
/* UserThread.execute(() -> {
|
||||||
this.requestFocus();
|
this.requestFocus();
|
||||||
UserThread.execute(() -> withdrawAddressTextField.requestFocus());
|
UserThread.execute(() -> withdrawAddressTextField.requestFocus());
|
||||||
});
|
});*/
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class ContractPopup extends Popup {
|
||||||
width = 850;
|
width = 850;
|
||||||
createGridPane();
|
createGridPane();
|
||||||
addContent();
|
addContent();
|
||||||
createPopup();
|
display();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,8 @@ public class ContractPopup extends Popup {
|
||||||
addLabelTxIdTextField(gridPane, ++rowIndex, "Payout transaction ID:", dispute.getPayoutTxId());
|
addLabelTxIdTextField(gridPane, ++rowIndex, "Payout transaction ID:", dispute.getPayoutTxId());
|
||||||
|
|
||||||
Button cancelButton = addButtonAfterGroup(gridPane, ++rowIndex, "Close");
|
Button cancelButton = addButtonAfterGroup(gridPane, ++rowIndex, "Close");
|
||||||
cancelButton.requestFocus();
|
//TODO app wide focus
|
||||||
|
//cancelButton.requestFocus();
|
||||||
cancelButton.setOnAction(e -> {
|
cancelButton.setOnAction(e -> {
|
||||||
closeHandlerOptional.ifPresent(closeHandler -> closeHandler.run());
|
closeHandlerOptional.ifPresent(closeHandler -> closeHandler.run());
|
||||||
hide();
|
hide();
|
||||||
|
|
|
@ -46,15 +46,14 @@ public class DisplayAlertMessagePopup extends Popup {
|
||||||
public DisplayAlertMessagePopup() {
|
public DisplayAlertMessagePopup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DisplayAlertMessagePopup show() {
|
public void show() {
|
||||||
width = 700;
|
width = 700;
|
||||||
// need to set headLine, otherwise the fields will not be created in addHeadLine
|
// need to set headLine, otherwise the fields will not be created in addHeadLine
|
||||||
headLine = "Important information!";
|
headLine = "Important information!";
|
||||||
createGridPane();
|
createGridPane();
|
||||||
addHeadLine();
|
addHeadLine();
|
||||||
addContent();
|
addContent();
|
||||||
createPopup();
|
PopupManager.queueForDisplay(this);
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DisplayAlertMessagePopup alertMessage(Alert alert) {
|
public DisplayAlertMessagePopup alertMessage(Alert alert) {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.bitsquare.gui.main.disputes;
|
package io.bitsquare.gui.popups;
|
||||||
|
|
||||||
import io.bitsquare.arbitration.Dispute;
|
import io.bitsquare.arbitration.Dispute;
|
||||||
import io.bitsquare.arbitration.DisputeManager;
|
import io.bitsquare.arbitration.DisputeManager;
|
||||||
|
@ -26,7 +26,6 @@ import io.bitsquare.btc.TradeWalletService;
|
||||||
import io.bitsquare.btc.WalletService;
|
import io.bitsquare.btc.WalletService;
|
||||||
import io.bitsquare.btc.exceptions.TransactionVerificationException;
|
import io.bitsquare.btc.exceptions.TransactionVerificationException;
|
||||||
import io.bitsquare.common.util.Tuple2;
|
import io.bitsquare.common.util.Tuple2;
|
||||||
import io.bitsquare.gui.popups.Popup;
|
|
||||||
import io.bitsquare.gui.util.BSFormatter;
|
import io.bitsquare.gui.util.BSFormatter;
|
||||||
import io.bitsquare.gui.util.Layout;
|
import io.bitsquare.gui.util.Layout;
|
||||||
import io.bitsquare.gui.util.Transitions;
|
import io.bitsquare.gui.util.Transitions;
|
||||||
|
@ -89,7 +88,7 @@ public class DisputeSummaryPopup extends Popup {
|
||||||
width = 850;
|
width = 850;
|
||||||
createGridPane();
|
createGridPane();
|
||||||
addContent();
|
addContent();
|
||||||
createPopup();
|
PopupManager.queueForDisplay(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DisputeSummaryPopup onClose(Runnable closeHandler) {
|
public DisputeSummaryPopup onClose(Runnable closeHandler) {
|
|
@ -64,7 +64,7 @@ public class EmptyWalletPopup extends Popup {
|
||||||
this.formatter = formatter;
|
this.formatter = formatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmptyWalletPopup show() {
|
public void show() {
|
||||||
if (headLine == null)
|
if (headLine == null)
|
||||||
headLine = "Empty wallet";
|
headLine = "Empty wallet";
|
||||||
|
|
||||||
|
@ -72,8 +72,7 @@ public class EmptyWalletPopup extends Popup {
|
||||||
createGridPane();
|
createGridPane();
|
||||||
addHeadLine();
|
addHeadLine();
|
||||||
addContent();
|
addContent();
|
||||||
createPopup();
|
PopupManager.queueForDisplay(this);
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmptyWalletPopup onClose(Runnable closeHandler) {
|
public EmptyWalletPopup onClose(Runnable closeHandler) {
|
||||||
|
|
|
@ -15,11 +15,10 @@
|
||||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.bitsquare.gui.main.account.arbitratorregistration;
|
package io.bitsquare.gui.popups;
|
||||||
|
|
||||||
import io.bitsquare.app.BitsquareApp;
|
import io.bitsquare.app.BitsquareApp;
|
||||||
import io.bitsquare.gui.components.InputTextField;
|
import io.bitsquare.gui.components.InputTextField;
|
||||||
import io.bitsquare.gui.popups.Popup;
|
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
|
@ -50,7 +49,7 @@ public class EnterPrivKeyPopup extends Popup {
|
||||||
public EnterPrivKeyPopup() {
|
public EnterPrivKeyPopup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public EnterPrivKeyPopup show() {
|
public void show() {
|
||||||
if (gridPane != null) {
|
if (gridPane != null) {
|
||||||
rowIndex = -1;
|
rowIndex = -1;
|
||||||
gridPane.getChildren().clear();
|
gridPane.getChildren().clear();
|
||||||
|
@ -63,9 +62,7 @@ public class EnterPrivKeyPopup extends Popup {
|
||||||
addHeadLine();
|
addHeadLine();
|
||||||
addInputFields();
|
addInputFields();
|
||||||
addButtons();
|
addButtons();
|
||||||
createPopup();
|
PopupManager.queueForDisplay(this);
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EnterPrivKeyPopup onClose(Runnable closeHandler) {
|
public EnterPrivKeyPopup onClose(Runnable closeHandler) {
|
|
@ -79,7 +79,7 @@ public class OfferDetailsPopup extends Popup {
|
||||||
width = 850;
|
width = 850;
|
||||||
createGridPane();
|
createGridPane();
|
||||||
addContent();
|
addContent();
|
||||||
createPopup();
|
display();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ public class OfferDetailsPopup extends Popup {
|
||||||
width = 850;
|
width = 850;
|
||||||
createGridPane();
|
createGridPane();
|
||||||
addContent();
|
addContent();
|
||||||
createPopup();
|
display();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class OpenEmergencyTicketPopup extends Popup {
|
||||||
public OpenEmergencyTicketPopup() {
|
public OpenEmergencyTicketPopup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public OpenEmergencyTicketPopup show() {
|
public void show() {
|
||||||
if (headLine == null)
|
if (headLine == null)
|
||||||
headLine = "Open support ticket";
|
headLine = "Open support ticket";
|
||||||
|
|
||||||
|
@ -50,8 +50,7 @@ public class OpenEmergencyTicketPopup extends Popup {
|
||||||
createGridPane();
|
createGridPane();
|
||||||
addHeadLine();
|
addHeadLine();
|
||||||
addContent();
|
addContent();
|
||||||
createPopup();
|
PopupManager.queueForDisplay(this);
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OpenEmergencyTicketPopup onOpenTicket(ResultHandler openTicketHandler) {
|
public OpenEmergencyTicketPopup onOpenTicket(ResultHandler openTicketHandler) {
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class Popup {
|
||||||
public Popup() {
|
public Popup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Popup show() {
|
public void show() {
|
||||||
createGridPane();
|
createGridPane();
|
||||||
addHeadLine();
|
addHeadLine();
|
||||||
|
|
||||||
|
@ -91,13 +91,16 @@ public class Popup {
|
||||||
|
|
||||||
addCloseButton();
|
addCloseButton();
|
||||||
addDontShowAgainCheckBox();
|
addDontShowAgainCheckBox();
|
||||||
createPopup();
|
PopupManager.queueForDisplay(this);
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hide() {
|
public void hide() {
|
||||||
MainView.removeBlur();
|
MainView.removeBlur();
|
||||||
stage.hide();
|
if (stage != null)
|
||||||
|
stage.hide();
|
||||||
|
else
|
||||||
|
log.warn("Stage is null");
|
||||||
|
PopupManager.isHidden(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Popup onClose(Runnable closeHandler) {
|
public Popup onClose(Runnable closeHandler) {
|
||||||
|
@ -207,7 +210,7 @@ public class Popup {
|
||||||
FxTimer.runLater(Duration.ofMillis(Transitions.DEFAULT_DURATION), () -> MainView.blurLight());
|
FxTimer.runLater(Duration.ofMillis(Transitions.DEFAULT_DURATION), () -> MainView.blurLight());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createPopup() {
|
public void display() {
|
||||||
if (owner == null)
|
if (owner == null)
|
||||||
owner = MainView.getRootContainer();
|
owner = MainView.getRootContainer();
|
||||||
|
|
||||||
|
@ -333,7 +336,8 @@ public class Popup {
|
||||||
if (actionHandlerOptional.isPresent() || actionButtonText != null) {
|
if (actionHandlerOptional.isPresent() || actionButtonText != null) {
|
||||||
actionButton = new Button(actionButtonText == null ? "Ok" : actionButtonText);
|
actionButton = new Button(actionButtonText == null ? "Ok" : actionButtonText);
|
||||||
actionButton.setDefaultButton(true);
|
actionButton.setDefaultButton(true);
|
||||||
actionButton.requestFocus();
|
//TODO app wide focus
|
||||||
|
//actionButton.requestFocus();
|
||||||
actionButton.setOnAction(event -> {
|
actionButton.setOnAction(event -> {
|
||||||
hide();
|
hide();
|
||||||
actionHandlerOptional.ifPresent(actionHandler -> actionHandler.run());
|
actionHandlerOptional.ifPresent(actionHandler -> actionHandler.run());
|
||||||
|
@ -367,4 +371,12 @@ public class Popup {
|
||||||
else
|
else
|
||||||
truncatedMessage = message;
|
truncatedMessage = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Popup{" +
|
||||||
|
"headLine='" + headLine + '\'' +
|
||||||
|
", message='" + message + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
40
gui/src/main/java/io/bitsquare/gui/popups/PopupManager.java
Normal file
40
gui/src/main/java/io/bitsquare/gui/popups/PopupManager.java
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
package io.bitsquare.gui.popups;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
|
||||||
|
class PopupManager {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(PopupManager.class);
|
||||||
|
private static Queue<Popup> popups = new LinkedBlockingQueue<>(3);
|
||||||
|
private static Popup displayedPopup;
|
||||||
|
|
||||||
|
static void queueForDisplay(Popup popup) {
|
||||||
|
boolean result = popups.offer(popup);
|
||||||
|
if (!result)
|
||||||
|
log.warn("The capacity is full with popups in the queue.\n\t" +
|
||||||
|
"Not added new popup=" + popup);
|
||||||
|
displayNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void isHidden(Popup popup) {
|
||||||
|
if (displayedPopup == null || displayedPopup == popup) {
|
||||||
|
displayedPopup = null;
|
||||||
|
displayNext();
|
||||||
|
} else {
|
||||||
|
log.warn("We got a isHidden called with a wrong popup.\n\t" +
|
||||||
|
"popup (argument)=" + popup + "\n\tdisplayedPopup=" + displayedPopup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void displayNext() {
|
||||||
|
if (displayedPopup == null) {
|
||||||
|
if (!popups.isEmpty()) {
|
||||||
|
displayedPopup = popups.poll();
|
||||||
|
displayedPopup.display();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -51,7 +51,7 @@ public class SelectDepositTxPopup extends Popup {
|
||||||
public SelectDepositTxPopup() {
|
public SelectDepositTxPopup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SelectDepositTxPopup show() {
|
public void show() {
|
||||||
if (headLine == null)
|
if (headLine == null)
|
||||||
headLine = "Select deposit transaction for dispute";
|
headLine = "Select deposit transaction for dispute";
|
||||||
|
|
||||||
|
@ -60,8 +60,7 @@ public class SelectDepositTxPopup extends Popup {
|
||||||
addHeadLine();
|
addHeadLine();
|
||||||
addContent();
|
addContent();
|
||||||
addCloseButton();
|
addCloseButton();
|
||||||
createPopup();
|
PopupManager.queueForDisplay(this);
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SelectDepositTxPopup onSelect(Consumer<Transaction> selectHandler) {
|
public SelectDepositTxPopup onSelect(Consumer<Transaction> selectHandler) {
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class SendAlertMessagePopup extends Popup {
|
||||||
public SendAlertMessagePopup() {
|
public SendAlertMessagePopup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SendAlertMessagePopup show() {
|
public void show() {
|
||||||
if (headLine == null)
|
if (headLine == null)
|
||||||
headLine = "Send global notification";
|
headLine = "Send global notification";
|
||||||
|
|
||||||
|
@ -67,8 +67,7 @@ public class SendAlertMessagePopup extends Popup {
|
||||||
createGridPane();
|
createGridPane();
|
||||||
addHeadLine();
|
addHeadLine();
|
||||||
addContent();
|
addContent();
|
||||||
createPopup();
|
PopupManager.queueForDisplay(this);
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SendAlertMessagePopup onAddAlertMessage(SendAlertMessageHandler sendAlertMessageHandler) {
|
public SendAlertMessagePopup onAddAlertMessage(SendAlertMessageHandler sendAlertMessageHandler) {
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class TradeDetailsPopup extends Popup {
|
||||||
width = 850;
|
width = 850;
|
||||||
createGridPane();
|
createGridPane();
|
||||||
addContent();
|
addContent();
|
||||||
createPopup();
|
display();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,8 @@ public class TradeDetailsPopup extends Popup {
|
||||||
}
|
}
|
||||||
|
|
||||||
Button cancelButton = addButtonAfterGroup(gridPane, ++rowIndex, "Close");
|
Button cancelButton = addButtonAfterGroup(gridPane, ++rowIndex, "Close");
|
||||||
cancelButton.requestFocus();
|
//TODO app wide focus
|
||||||
|
//cancelButton.requestFocus();
|
||||||
cancelButton.setOnAction(e -> {
|
cancelButton.setOnAction(e -> {
|
||||||
closeHandlerOptional.ifPresent(closeHandler -> closeHandler.run());
|
closeHandlerOptional.ifPresent(closeHandler -> closeHandler.run());
|
||||||
hide();
|
hide();
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class WalletPasswordPopup extends Popup {
|
||||||
this.walletService = walletService;
|
this.walletService = walletService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WalletPasswordPopup show() {
|
public void show() {
|
||||||
if (gridPane != null) {
|
if (gridPane != null) {
|
||||||
rowIndex = -1;
|
rowIndex = -1;
|
||||||
gridPane.getChildren().clear();
|
gridPane.getChildren().clear();
|
||||||
|
@ -77,9 +77,7 @@ public class WalletPasswordPopup extends Popup {
|
||||||
addHeadLine();
|
addHeadLine();
|
||||||
addInputFields();
|
addInputFields();
|
||||||
addButtons();
|
addButtons();
|
||||||
createPopup();
|
PopupManager.queueForDisplay(this);
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public WalletPasswordPopup onClose(Runnable closeHandler) {
|
public WalletPasswordPopup onClose(Runnable closeHandler) {
|
||||||
|
|
|
@ -10,7 +10,12 @@
|
||||||
<appender-ref ref="CONSOLE_APPENDER"/>
|
<appender-ref ref="CONSOLE_APPENDER"/>
|
||||||
</root>
|
</root>
|
||||||
|
|
||||||
|
|
||||||
<!-- <logger name="io.bitsquare.p2p.peers.PeerGroup" level="TRACE"/>
|
<!-- <logger name="io.bitsquare.p2p.peers.PeerGroup" level="TRACE"/>
|
||||||
|
|
||||||
|
<logger name="io.bitsquare.storage.Storage" level="WARN"/>
|
||||||
|
<logger name="io.bitsquare.storage.FileManager" level="WARN"/>
|
||||||
|
|
||||||
<logger name="io.bitsquare.p2p.P2PService" level="TRACE"/>
|
<logger name="io.bitsquare.p2p.P2PService" level="TRACE"/>
|
||||||
<logger name="io.bitsquare.p2p.storage.ProtectedExpirableDataStorage" level="TRACE"/>
|
<logger name="io.bitsquare.p2p.storage.ProtectedExpirableDataStorage" level="TRACE"/>
|
||||||
<logger name="io.bitsquare.p2p.network.LocalhostNetworkNode" level="TRACE"/>
|
<logger name="io.bitsquare.p2p.network.LocalhostNetworkNode" level="TRACE"/>
|
||||||
|
|
|
@ -10,9 +10,9 @@ import java.util.Arrays;
|
||||||
|
|
||||||
public final class PrefixedSealedAndSignedMessage implements MailboxMessage, SendersNodeAddressMessage {
|
public final class PrefixedSealedAndSignedMessage implements MailboxMessage, SendersNodeAddressMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
private final int networkId = Version.getNetworkId();
|
private final int messageVersion = Version.getP2PMessageVersion();
|
||||||
private final NodeAddress senderNodeAddress;
|
private final NodeAddress senderNodeAddress;
|
||||||
public final SealedAndSigned sealedAndSigned;
|
public final SealedAndSigned sealedAndSigned;
|
||||||
public final byte[] addressPrefixHash;
|
public final byte[] addressPrefixHash;
|
||||||
|
@ -29,14 +29,14 @@ public final class PrefixedSealedAndSignedMessage implements MailboxMessage, Sen
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int networkId() {
|
public int getMessageVersion() {
|
||||||
return networkId;
|
return messageVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SealedAndSignedMessage{" +
|
return "SealedAndSignedMessage{" +
|
||||||
"networkId=" + networkId +
|
"messageVersion=" + messageVersion +
|
||||||
", sealedAndSigned=" + sealedAndSigned +
|
", sealedAndSigned=" + sealedAndSigned +
|
||||||
", receiverAddressMaskHash.hashCode()=" + Arrays.toString(addressPrefixHash).hashCode() +
|
", receiverAddressMaskHash.hashCode()=" + Arrays.toString(addressPrefixHash).hashCode() +
|
||||||
'}';
|
'}';
|
||||||
|
|
|
@ -3,5 +3,5 @@ package io.bitsquare.p2p;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public interface Message extends Serializable {
|
public interface Message extends Serializable {
|
||||||
int networkId();
|
int getMessageVersion();
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,8 +108,6 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init(boolean useLocalhost, int networkId, File storageDir) {
|
private void init(boolean useLocalhost, int networkId, File storageDir) {
|
||||||
Log.traceCall();
|
|
||||||
|
|
||||||
connectionNodeAddressListener = (observable, oldValue, newValue) -> {
|
connectionNodeAddressListener = (observable, oldValue, newValue) -> {
|
||||||
UserThread.execute(() -> numConnectedPeers.set(networkNode.getNodeAddressesOfConfirmedConnections().size()));
|
UserThread.execute(() -> numConnectedPeers.set(networkNode.getNodeAddressesOfConfirmedConnections().size()));
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,9 +24,9 @@ import java.security.PublicKey;
|
||||||
|
|
||||||
public final class DecryptedMsgWithPubKey implements DirectMessage {
|
public final class DecryptedMsgWithPubKey implements DirectMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
private final int networkId = Version.getNetworkId();
|
private final int messageVersion = Version.getP2PMessageVersion();
|
||||||
public final Message message;
|
public final Message message;
|
||||||
public final PublicKey signaturePubKey;
|
public final PublicKey signaturePubKey;
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ public final class DecryptedMsgWithPubKey implements DirectMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int networkId() {
|
public int getMessageVersion() {
|
||||||
return networkId;
|
return messageVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -63,7 +63,7 @@ public final class DecryptedMsgWithPubKey implements DirectMessage {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DecryptedMsgWithPubKey{" +
|
return "DecryptedMsgWithPubKey{" +
|
||||||
"networkId=" + networkId +
|
"messageVersion=" + messageVersion +
|
||||||
", message=" + message +
|
", message=" + message +
|
||||||
", signaturePubKey.hashCode()=" + signaturePubKey.hashCode() +
|
", signaturePubKey.hashCode()=" + signaturePubKey.hashCode() +
|
||||||
'}';
|
'}';
|
||||||
|
|
|
@ -6,7 +6,6 @@ public enum CloseConnectionReason {
|
||||||
RESET(false),
|
RESET(false),
|
||||||
SOCKET_TIMEOUT(false),
|
SOCKET_TIMEOUT(false),
|
||||||
TERMINATED(false), // EOFException
|
TERMINATED(false), // EOFException
|
||||||
INCOMPATIBLE_DATA(false),
|
|
||||||
UNKNOWN_EXCEPTION(false),
|
UNKNOWN_EXCEPTION(false),
|
||||||
|
|
||||||
// Planned
|
// Planned
|
||||||
|
|
|
@ -177,10 +177,8 @@ public class Connection implements MessageListener {
|
||||||
objectToWrite = message;
|
objectToWrite = message;
|
||||||
}
|
}
|
||||||
if (!stopped) {
|
if (!stopped) {
|
||||||
synchronized (objectOutputStream) {
|
objectOutputStream.writeObject(objectToWrite);
|
||||||
objectOutputStream.writeObject(objectToWrite);
|
objectOutputStream.flush();
|
||||||
objectOutputStream.flush();
|
|
||||||
}
|
|
||||||
sharedModel.updateLastActivityDate();
|
sharedModel.updateLastActivityDate();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -243,7 +241,7 @@ public class Connection implements MessageListener {
|
||||||
this.peerType = peerType;
|
this.peerType = peerType;
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void setPeersNodeAddress(NodeAddress peerNodeAddress) {
|
private void setPeersNodeAddress(NodeAddress peerNodeAddress) {
|
||||||
checkNotNull(peerNodeAddress, "peerAddress must not be null");
|
checkNotNull(peerNodeAddress, "peerAddress must not be null");
|
||||||
peersNodeAddressOptional = Optional.of(peerNodeAddress);
|
peersNodeAddressOptional = Optional.of(peerNodeAddress);
|
||||||
|
|
||||||
|
@ -264,7 +262,7 @@ public class Connection implements MessageListener {
|
||||||
// Getters
|
// Getters
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public synchronized Optional<NodeAddress> getPeersNodeAddressOptional() {
|
public Optional<NodeAddress> getPeersNodeAddressOptional() {
|
||||||
return peersNodeAddressOptional;
|
return peersNodeAddressOptional;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,6 +290,10 @@ public class Connection implements MessageListener {
|
||||||
return nodeAddressProperty;
|
return nodeAddressProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RuleViolation getRuleViolation() {
|
||||||
|
return sharedModel.getRuleViolation();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// ShutDown
|
// ShutDown
|
||||||
|
@ -436,11 +438,11 @@ public class Connection implements MessageListener {
|
||||||
this.socket = socket;
|
this.socket = socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void updateLastActivityDate() {
|
public void updateLastActivityDate() {
|
||||||
lastActivityDate = new Date();
|
lastActivityDate = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized Date getLastActivityDate() {
|
public Date getLastActivityDate() {
|
||||||
return lastActivityDate;
|
return lastActivityDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,11 +479,9 @@ public class Connection implements MessageListener {
|
||||||
closeConnectionReason = CloseConnectionReason.RESET;
|
closeConnectionReason = CloseConnectionReason.RESET;
|
||||||
} else if (e instanceof SocketTimeoutException || e instanceof TimeoutException) {
|
} else if (e instanceof SocketTimeoutException || e instanceof TimeoutException) {
|
||||||
closeConnectionReason = CloseConnectionReason.SOCKET_TIMEOUT;
|
closeConnectionReason = CloseConnectionReason.SOCKET_TIMEOUT;
|
||||||
log.debug("TimeoutException at socket " + socket.toString() + "\n\tconnection={}" + this);
|
log.warn("SocketTimeoutException at socket " + socket.toString() + "\n\tconnection={}" + this);
|
||||||
} else if (e instanceof EOFException) {
|
} else if (e instanceof EOFException) {
|
||||||
closeConnectionReason = CloseConnectionReason.TERMINATED;
|
closeConnectionReason = CloseConnectionReason.TERMINATED;
|
||||||
} else if (e instanceof NoClassDefFoundError || e instanceof ClassNotFoundException) {
|
|
||||||
closeConnectionReason = CloseConnectionReason.INCOMPATIBLE_DATA;
|
|
||||||
} else {
|
} else {
|
||||||
closeConnectionReason = CloseConnectionReason.UNKNOWN_EXCEPTION;
|
closeConnectionReason = CloseConnectionReason.UNKNOWN_EXCEPTION;
|
||||||
log.warn("Unknown reason for exception at socket {}\n\tconnection={}\n\tException=",
|
log.warn("Unknown reason for exception at socket {}\n\tconnection={}\n\tException=",
|
||||||
|
@ -499,7 +499,7 @@ public class Connection implements MessageListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized Socket getSocket() {
|
public Socket getSocket() {
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,9 +522,9 @@ public class Connection implements MessageListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// InputHandler
|
// InputHandler
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Runs in same thread as Connection
|
// Runs in same thread as Connection
|
||||||
private static class InputHandler implements Runnable {
|
private static class InputHandler implements Runnable {
|
||||||
|
@ -547,11 +547,15 @@ public class Connection implements MessageListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
stopped = true;
|
if (!stopped) {
|
||||||
try {
|
try {
|
||||||
objectInputStream.close();
|
objectInputStream.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
log.error("IOException at InputHandler.stop\n" + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
stopped = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,7 +577,7 @@ public class Connection implements MessageListener {
|
||||||
|
|
||||||
int size = ByteArrayUtils.objectToByteArray(rawInputObject).length;
|
int size = ByteArrayUtils.objectToByteArray(rawInputObject).length;
|
||||||
if (size > getMaxMsgSize()) {
|
if (size > getMaxMsgSize()) {
|
||||||
sharedModel.reportInvalidRequest(RuleViolation.MAX_MSG_SIZE_EXCEEDED);
|
reportInvalidRequest(RuleViolation.MAX_MSG_SIZE_EXCEEDED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -585,36 +589,38 @@ public class Connection implements MessageListener {
|
||||||
//log.trace("Read object compressed data size: " + size);
|
//log.trace("Read object compressed data size: " + size);
|
||||||
serializable = Utils.decompress(compressedObjectAsBytes);
|
serializable = Utils.decompress(compressedObjectAsBytes);
|
||||||
} else {
|
} else {
|
||||||
sharedModel.reportInvalidRequest(RuleViolation.INVALID_DATA_TYPE);
|
reportInvalidRequest(RuleViolation.INVALID_DATA_TYPE);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (rawInputObject instanceof Serializable) {
|
if (rawInputObject instanceof Serializable) {
|
||||||
serializable = (Serializable) rawInputObject;
|
serializable = (Serializable) rawInputObject;
|
||||||
} else {
|
} else {
|
||||||
sharedModel.reportInvalidRequest(RuleViolation.INVALID_DATA_TYPE);
|
reportInvalidRequest(RuleViolation.INVALID_DATA_TYPE);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//log.trace("Read object decompressed data size: " + ByteArrayUtils.objectToByteArray(serializable).length);
|
//log.trace("Read object decompressed data size: " + ByteArrayUtils.objectToByteArray(serializable).length);
|
||||||
|
|
||||||
// compressed size might be bigger theoretically so we check again after decompression
|
// compressed size might be bigger theoretically so we check again after decompression
|
||||||
if (size > getMaxMsgSize()) {
|
if (size > getMaxMsgSize()) {
|
||||||
sharedModel.reportInvalidRequest(RuleViolation.MAX_MSG_SIZE_EXCEEDED);
|
reportInvalidRequest(RuleViolation.MAX_MSG_SIZE_EXCEEDED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sharedModel.connection.violatesThrottleLimit()) {
|
if (sharedModel.connection.violatesThrottleLimit()) {
|
||||||
sharedModel.reportInvalidRequest(RuleViolation.THROTTLE_LIMIT_EXCEEDED);
|
reportInvalidRequest(RuleViolation.THROTTLE_LIMIT_EXCEEDED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(serializable instanceof Message)) {
|
if (!(serializable instanceof Message)) {
|
||||||
sharedModel.reportInvalidRequest(RuleViolation.INVALID_DATA_TYPE);
|
reportInvalidRequest(RuleViolation.INVALID_DATA_TYPE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Message message = (Message) serializable;
|
Message message = (Message) serializable;
|
||||||
if (message.networkId() != Version.getNetworkId()) {
|
if (message.getMessageVersion() != Version.getP2PMessageVersion()) {
|
||||||
sharedModel.reportInvalidRequest(RuleViolation.WRONG_NETWORK_ID);
|
reportInvalidRequest(RuleViolation.WRONG_NETWORK_ID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,7 +630,7 @@ public class Connection implements MessageListener {
|
||||||
CloseConnectionReason[] values = CloseConnectionReason.values();
|
CloseConnectionReason[] values = CloseConnectionReason.values();
|
||||||
log.info("CloseConnectionMessage received. Reason={}\n\t" +
|
log.info("CloseConnectionMessage received. Reason={}\n\t" +
|
||||||
"connection={}", ((CloseConnectionMessage) message).reason, connection);
|
"connection={}", ((CloseConnectionMessage) message).reason, connection);
|
||||||
stopped = true;
|
stop();
|
||||||
sharedModel.shutDown(CloseConnectionReason.CLOSE_REQUESTED_BY_PEER);
|
sharedModel.shutDown(CloseConnectionReason.CLOSE_REQUESTED_BY_PEER);
|
||||||
} else if (!stopped) {
|
} else if (!stopped) {
|
||||||
// First a seed node gets a message form a peer (PreliminaryDataRequest using
|
// First a seed node gets a message form a peer (PreliminaryDataRequest using
|
||||||
|
@ -655,17 +661,26 @@ public class Connection implements MessageListener {
|
||||||
messageListener.onMessage(message, connection);
|
messageListener.onMessage(message, connection);
|
||||||
}
|
}
|
||||||
} catch (IOException | ClassNotFoundException | NoClassDefFoundError e) {
|
} catch (IOException | ClassNotFoundException | NoClassDefFoundError e) {
|
||||||
stopped = true;
|
reportInvalidRequest(RuleViolation.INVALID_DATA_TYPE);
|
||||||
sharedModel.handleConnectionException(e);
|
return;
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
stop();
|
||||||
|
sharedModel.handleConnectionException(new Exception(t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
stopped = true;
|
stop();
|
||||||
sharedModel.handleConnectionException(new Exception(t));
|
sharedModel.handleConnectionException(new Exception(t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reportInvalidRequest(RuleViolation ruleViolation) {
|
||||||
|
sharedModel.reportInvalidRequest(ruleViolation);
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "InputHandler{" +
|
return "InputHandler{" +
|
||||||
|
|
|
@ -46,12 +46,10 @@ public class LocalhostNetworkNode extends NetworkNode {
|
||||||
|
|
||||||
public LocalhostNetworkNode(int port) {
|
public LocalhostNetworkNode(int port) {
|
||||||
super(port);
|
super(port);
|
||||||
Log.traceCall();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(@Nullable SetupListener setupListener) {
|
public void start(@Nullable SetupListener setupListener) {
|
||||||
Log.traceCall();
|
|
||||||
if (setupListener != null)
|
if (setupListener != null)
|
||||||
addSetupListener(setupListener);
|
addSetupListener(setupListener);
|
||||||
|
|
||||||
|
@ -89,7 +87,6 @@ public class LocalhostNetworkNode extends NetworkNode {
|
||||||
// Called from NetworkNode thread
|
// Called from NetworkNode thread
|
||||||
@Override
|
@Override
|
||||||
protected Socket createSocket(NodeAddress peerNodeAddress) throws IOException {
|
protected Socket createSocket(NodeAddress peerNodeAddress) throws IOException {
|
||||||
Log.traceCall();
|
|
||||||
return new Socket(peerNodeAddress.hostName, peerNodeAddress.port);
|
return new Socket(peerNodeAddress.hostName, peerNodeAddress.port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +96,6 @@ public class LocalhostNetworkNode extends NetworkNode {
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
private void createTorNode(final Consumer<TorNode> resultHandler) {
|
private void createTorNode(final Consumer<TorNode> resultHandler) {
|
||||||
Log.traceCall();
|
|
||||||
ListenableFuture<TorNode<JavaOnionProxyManager, JavaOnionProxyContext>> future = executorService.submit(() -> {
|
ListenableFuture<TorNode<JavaOnionProxyManager, JavaOnionProxyContext>> future = executorService.submit(() -> {
|
||||||
Utilities.setThreadName("NetworkNode:CreateTorNode");
|
Utilities.setThreadName("NetworkNode:CreateTorNode");
|
||||||
long ts = System.currentTimeMillis();
|
long ts = System.currentTimeMillis();
|
||||||
|
@ -129,7 +125,6 @@ public class LocalhostNetworkNode extends NetworkNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createHiddenService(final Consumer<HiddenServiceDescriptor> resultHandler) {
|
private void createHiddenService(final Consumer<HiddenServiceDescriptor> resultHandler) {
|
||||||
Log.traceCall();
|
|
||||||
ListenableFuture<HiddenServiceDescriptor> future = executorService.submit(() -> {
|
ListenableFuture<HiddenServiceDescriptor> future = executorService.submit(() -> {
|
||||||
Utilities.setThreadName("NetworkNode:CreateHiddenService");
|
Utilities.setThreadName("NetworkNode:CreateHiddenService");
|
||||||
long ts = System.currentTimeMillis();
|
long ts = System.currentTimeMillis();
|
||||||
|
|
|
@ -5,9 +5,11 @@ import io.bitsquare.p2p.Message;
|
||||||
|
|
||||||
public final class CloseConnectionMessage implements Message {
|
public final class CloseConnectionMessage implements Message {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
// We dont use the Version.NETWORK_PROTOCOL_VERSION here as we report also compatibility issues and
|
||||||
|
// a changed version would render that message invalid as well, so the peer cannot get notified about the problem.
|
||||||
|
private static final long serialVersionUID = 0;
|
||||||
|
|
||||||
private final int networkId = Version.getNetworkId();
|
private final int messageVersion = Version.getP2PMessageVersion();
|
||||||
public final String reason;
|
public final String reason;
|
||||||
|
|
||||||
public CloseConnectionMessage(String reason) {
|
public CloseConnectionMessage(String reason) {
|
||||||
|
@ -15,15 +17,15 @@ public final class CloseConnectionMessage implements Message {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int networkId() {
|
public int getMessageVersion() {
|
||||||
return networkId;
|
return messageVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "CloseConnectionMessage{" +
|
return "CloseConnectionMessage{" +
|
||||||
|
"messageVersion=" + messageVersion +
|
||||||
", reason=" + reason +
|
", reason=" + reason +
|
||||||
", networkId=" + networkId +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class ReportedPeer implements Serializable {
|
public class ReportedPeer implements Serializable {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
public final NodeAddress nodeAddress;
|
public final NodeAddress nodeAddress;
|
||||||
public Date lastActivityDate;
|
public Date lastActivityDate;
|
||||||
|
|
|
@ -8,8 +8,8 @@ import java.util.HashSet;
|
||||||
|
|
||||||
public final class GetDataResponse implements Message {
|
public final class GetDataResponse implements Message {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
private final int networkId = Version.getNetworkId();
|
private final int messageVersion = Version.getP2PMessageVersion();
|
||||||
|
|
||||||
public final HashSet<ProtectedData> dataSet;
|
public final HashSet<ProtectedData> dataSet;
|
||||||
public final long requestNonce;
|
public final long requestNonce;
|
||||||
|
@ -20,14 +20,14 @@ public final class GetDataResponse implements Message {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int networkId() {
|
public int getMessageVersion() {
|
||||||
return networkId;
|
return messageVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "GetDataResponse{" +
|
return "GetDataResponse{" +
|
||||||
"networkId=" + networkId +
|
"messageVersion=" + messageVersion +
|
||||||
", dataSet.size()=" + dataSet.size() +
|
", dataSet.size()=" + dataSet.size() +
|
||||||
", requestNonce=" + requestNonce +
|
", requestNonce=" + requestNonce +
|
||||||
'}';
|
'}';
|
||||||
|
|
|
@ -6,9 +6,9 @@ import io.bitsquare.p2p.network.messages.SendersNodeAddressMessage;
|
||||||
|
|
||||||
public final class GetUpdatedDataRequest implements SendersNodeAddressMessage, GetDataRequest {
|
public final class GetUpdatedDataRequest implements SendersNodeAddressMessage, GetDataRequest {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
private final int networkId = Version.getNetworkId();
|
private final int messageVersion = Version.getP2PMessageVersion();
|
||||||
private final NodeAddress senderNodeAddress;
|
private final NodeAddress senderNodeAddress;
|
||||||
private final long nonce;
|
private final long nonce;
|
||||||
|
|
||||||
|
@ -28,14 +28,14 @@ public final class GetUpdatedDataRequest implements SendersNodeAddressMessage, G
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int networkId() {
|
public int getMessageVersion() {
|
||||||
return networkId;
|
return messageVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "GetUpdatedDataRequest{" +
|
return "GetUpdatedDataRequest{" +
|
||||||
"networkId=" + networkId +
|
"messageVersion=" + messageVersion +
|
||||||
", senderNodeAddress=" + senderNodeAddress +
|
", senderNodeAddress=" + senderNodeAddress +
|
||||||
", nonce=" + nonce +
|
", nonce=" + nonce +
|
||||||
'}';
|
'}';
|
||||||
|
|
|
@ -5,9 +5,9 @@ import io.bitsquare.p2p.network.messages.AnonymousMessage;
|
||||||
|
|
||||||
public final class PreliminaryGetDataRequest implements AnonymousMessage, GetDataRequest {
|
public final class PreliminaryGetDataRequest implements AnonymousMessage, GetDataRequest {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
private final int networkId = Version.getNetworkId();
|
private final int messageVersion = Version.getP2PMessageVersion();
|
||||||
private final long nonce;
|
private final long nonce;
|
||||||
|
|
||||||
public PreliminaryGetDataRequest(long nonce) {
|
public PreliminaryGetDataRequest(long nonce) {
|
||||||
|
@ -20,14 +20,14 @@ public final class PreliminaryGetDataRequest implements AnonymousMessage, GetDat
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int networkId() {
|
public int getMessageVersion() {
|
||||||
return networkId;
|
return messageVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PreliminaryGetDataRequest{" +
|
return "PreliminaryGetDataRequest{" +
|
||||||
"networkId=" + networkId +
|
"messageVersion=" + messageVersion +
|
||||||
", nonce=" + nonce +
|
", nonce=" + nonce +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.util.HashSet;
|
||||||
|
|
||||||
public final class GetPeersRequest extends PeerExchangeMessage implements SendersNodeAddressMessage {
|
public final class GetPeersRequest extends PeerExchangeMessage implements SendersNodeAddressMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
private final NodeAddress senderNodeAddress;
|
private final NodeAddress senderNodeAddress;
|
||||||
public long nonce;
|
public long nonce;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.util.HashSet;
|
||||||
|
|
||||||
public final class GetPeersResponse extends PeerExchangeMessage {
|
public final class GetPeersResponse extends PeerExchangeMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
public final long requestNonce;
|
public final long requestNonce;
|
||||||
public final HashSet<ReportedPeer> reportedPeers;
|
public final HashSet<ReportedPeer> reportedPeers;
|
||||||
|
|
|
@ -4,17 +4,17 @@ import io.bitsquare.app.Version;
|
||||||
import io.bitsquare.p2p.Message;
|
import io.bitsquare.p2p.Message;
|
||||||
|
|
||||||
public abstract class PeerExchangeMessage implements Message {
|
public abstract class PeerExchangeMessage implements Message {
|
||||||
private final int networkId = Version.getNetworkId();
|
private final int messageVersion = Version.getP2PMessageVersion();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int networkId() {
|
public int getMessageVersion() {
|
||||||
return networkId;
|
return messageVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PeerExchangeMessage{" +
|
return "PeerExchangeMessage{" +
|
||||||
"networkId=" + networkId +
|
"messageVersion=" + messageVersion +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,8 @@ public class SeedNode {
|
||||||
private final String defaultUserDataDir;
|
private final String defaultUserDataDir;
|
||||||
|
|
||||||
public SeedNode(String defaultUserDataDir) {
|
public SeedNode(String defaultUserDataDir) {
|
||||||
|
Log.traceCall("defaultUserDataDir=" + defaultUserDataDir);
|
||||||
this.defaultUserDataDir = defaultUserDataDir;
|
this.defaultUserDataDir = defaultUserDataDir;
|
||||||
Log.traceCall();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,21 +48,23 @@ public class SeedNode {
|
||||||
// or when using localhost: localhost:8001 2 20 true localhost:8002|localhost:8003
|
// or when using localhost: localhost:8001 2 20 true localhost:8002|localhost:8003
|
||||||
// BitcoinNetworkId: The id for the bitcoin network (Mainnet = 0, TestNet = 1, Regtest = 2)
|
// BitcoinNetworkId: The id for the bitcoin network (Mainnet = 0, TestNet = 1, Regtest = 2)
|
||||||
public void processArgs(String[] args) {
|
public void processArgs(String[] args) {
|
||||||
Log.traceCall();
|
|
||||||
try {
|
try {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
String arg0 = args[0];
|
String arg0 = args[0];
|
||||||
checkArgument(arg0.contains(":") && arg0.split(":").length == 2 && arg0.split(":")[1].length() > 3, "Wrong program argument: " + arg0);
|
checkArgument(arg0.contains(":") && arg0.split(":").length == 2 && arg0.split(":")[1].length() > 3, "Wrong program argument: " + arg0);
|
||||||
mySeedNodeAddress = new NodeAddress(arg0);
|
mySeedNodeAddress = new NodeAddress(arg0);
|
||||||
|
log.info("From processArgs: mySeedNodeAddress=" + mySeedNodeAddress);
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
String arg1 = args[1];
|
String arg1 = args[1];
|
||||||
int networkId = Integer.parseInt(arg1);
|
int networkId = Integer.parseInt(arg1);
|
||||||
|
log.info("From processArgs: networkId=" + networkId);
|
||||||
checkArgument(networkId > -1 && networkId < 3,
|
checkArgument(networkId > -1 && networkId < 3,
|
||||||
"networkId out of scope (Mainnet = 0, TestNet = 1, Regtest = 2)");
|
"networkId out of scope (Mainnet = 0, TestNet = 1, Regtest = 2)");
|
||||||
Version.setNetworkId(networkId);
|
Version.setBtcNetworkId(networkId);
|
||||||
if (args.length > 2) {
|
if (args.length > 2) {
|
||||||
String arg2 = args[2];
|
String arg2 = args[2];
|
||||||
int maxConnections = Integer.parseInt(arg2);
|
int maxConnections = Integer.parseInt(arg2);
|
||||||
|
log.info("From processArgs: maxConnections=" + maxConnections);
|
||||||
checkArgument(maxConnections < 1000, "maxConnections seems to be a bit too high...");
|
checkArgument(maxConnections < 1000, "maxConnections seems to be a bit too high...");
|
||||||
PeerManager.setMaxConnections(maxConnections);
|
PeerManager.setMaxConnections(maxConnections);
|
||||||
} else {
|
} else {
|
||||||
|
@ -73,6 +75,7 @@ public class SeedNode {
|
||||||
String arg3 = args[3];
|
String arg3 = args[3];
|
||||||
checkArgument(arg3.equals("true") || arg3.equals("false"));
|
checkArgument(arg3.equals("true") || arg3.equals("false"));
|
||||||
useLocalhost = ("true").equals(arg3);
|
useLocalhost = ("true").equals(arg3);
|
||||||
|
log.info("From processArgs: useLocalhost=" + useLocalhost);
|
||||||
}
|
}
|
||||||
if (args.length > 4) {
|
if (args.length > 4) {
|
||||||
String arg4 = args[4];
|
String arg4 = args[4];
|
||||||
|
@ -85,6 +88,7 @@ public class SeedNode {
|
||||||
"Wrong program argument");
|
"Wrong program argument");
|
||||||
progArgSeedNodes.add(new NodeAddress(e));
|
progArgSeedNodes.add(new NodeAddress(e));
|
||||||
});
|
});
|
||||||
|
log.info("From processArgs: progArgSeedNodes=" + progArgSeedNodes);
|
||||||
progArgSeedNodes.remove(mySeedNodeAddress);
|
progArgSeedNodes.remove(mySeedNodeAddress);
|
||||||
} else if (args.length > 5) {
|
} else if (args.length > 5) {
|
||||||
log.error("Too many program arguments." +
|
log.error("Too many program arguments." +
|
||||||
|
@ -99,7 +103,7 @@ public class SeedNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createAndStartP2PService(boolean useDetailedLogging) {
|
public void createAndStartP2PService(boolean useDetailedLogging) {
|
||||||
createAndStartP2PService(mySeedNodeAddress, useLocalhost, Version.getNetworkId(), useDetailedLogging, progArgSeedNodes, null);
|
createAndStartP2PService(mySeedNodeAddress, useLocalhost, Version.getBtcNetworkId(), useDetailedLogging, progArgSeedNodes, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
@ -109,8 +113,6 @@ public class SeedNode {
|
||||||
boolean useDetailedLogging,
|
boolean useDetailedLogging,
|
||||||
@Nullable Set<NodeAddress> progArgSeedNodes,
|
@Nullable Set<NodeAddress> progArgSeedNodes,
|
||||||
@Nullable P2PServiceListener listener) {
|
@Nullable P2PServiceListener listener) {
|
||||||
Log.traceCall();
|
|
||||||
|
|
||||||
Path appPath = Paths.get(defaultUserDataDir,
|
Path appPath = Paths.get(defaultUserDataDir,
|
||||||
"Bitsquare_seed_node_" + String.valueOf(mySeedNodeAddress.getFullAddress().replace(":", "_")));
|
"Bitsquare_seed_node_" + String.valueOf(mySeedNodeAddress.getFullAddress().replace(":", "_")));
|
||||||
|
|
||||||
|
@ -141,18 +143,14 @@ public class SeedNode {
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public P2PService getSeedNodeP2PService() {
|
public P2PService getSeedNodeP2PService() {
|
||||||
Log.traceCall();
|
|
||||||
return seedNodeP2PService;
|
return seedNodeP2PService;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void shutDown() {
|
private void shutDown() {
|
||||||
Log.traceCall();
|
|
||||||
shutDown(null);
|
shutDown(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutDown(@Nullable Runnable shutDownCompleteHandler) {
|
public void shutDown(@Nullable Runnable shutDownCompleteHandler) {
|
||||||
Log.traceCall();
|
|
||||||
log.debug("Request shutdown seed node");
|
|
||||||
if (!stopped) {
|
if (!stopped) {
|
||||||
stopped = true;
|
stopped = true;
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,6 @@ public class P2PDataStorage implements MessageListener {
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public P2PDataStorage(Broadcaster broadcaster, NetworkNode networkNode, File storageDir) {
|
public P2PDataStorage(Broadcaster broadcaster, NetworkNode networkNode, File storageDir) {
|
||||||
Log.traceCall();
|
|
||||||
this.broadcaster = broadcaster;
|
this.broadcaster = broadcaster;
|
||||||
|
|
||||||
networkNode.addMessageListener(this);
|
networkNode.addMessageListener(this);
|
||||||
|
@ -65,7 +64,6 @@ public class P2PDataStorage implements MessageListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
Log.traceCall();
|
|
||||||
HashMap<ByteArray, Integer> persisted = storage.initAndGetPersisted("SequenceNumberMap");
|
HashMap<ByteArray, Integer> persisted = storage.initAndGetPersisted("SequenceNumberMap");
|
||||||
if (persisted != null)
|
if (persisted != null)
|
||||||
sequenceNumberMap = persisted;
|
sequenceNumberMap = persisted;
|
||||||
|
@ -264,7 +262,6 @@ public class P2PDataStorage implements MessageListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addHashMapChangedListener(HashMapChangedListener hashMapChangedListener) {
|
public void addHashMapChangedListener(HashMapChangedListener hashMapChangedListener) {
|
||||||
Log.traceCall();
|
|
||||||
hashMapChangedListeners.add(hashMapChangedListener);
|
hashMapChangedListeners.add(hashMapChangedListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public final class ExpirableMailboxPayload implements ExpirablePayload {
|
public final class ExpirableMailboxPayload implements ExpirablePayload {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
private static final long TTL = TimeUnit.DAYS.toMillis(10);
|
private static final long TTL = TimeUnit.DAYS.toMillis(10);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import io.bitsquare.p2p.storage.data.ProtectedData;
|
||||||
|
|
||||||
public final class AddDataMessage extends DataBroadcastMessage {
|
public final class AddDataMessage extends DataBroadcastMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
public final ProtectedData data;
|
public final ProtectedData data;
|
||||||
|
|
||||||
|
|
|
@ -4,17 +4,17 @@ import io.bitsquare.app.Version;
|
||||||
import io.bitsquare.p2p.Message;
|
import io.bitsquare.p2p.Message;
|
||||||
|
|
||||||
public abstract class DataBroadcastMessage implements Message {
|
public abstract class DataBroadcastMessage implements Message {
|
||||||
private final int networkId = Version.getNetworkId();
|
private final int messageVersion = Version.getP2PMessageVersion();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int networkId() {
|
public int getMessageVersion() {
|
||||||
return networkId;
|
return messageVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DataBroadcastMessage{" +
|
return "DataBroadcastMessage{" +
|
||||||
"networkId=" + networkId +
|
"messageVersion=" + messageVersion +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,7 +5,7 @@ import io.bitsquare.p2p.storage.data.ProtectedData;
|
||||||
|
|
||||||
public final class RemoveDataMessage extends DataBroadcastMessage {
|
public final class RemoveDataMessage extends DataBroadcastMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
public final ProtectedData data;
|
public final ProtectedData data;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import io.bitsquare.p2p.storage.data.ProtectedMailboxData;
|
||||||
|
|
||||||
public final class RemoveMailboxDataMessage extends DataBroadcastMessage {
|
public final class RemoveMailboxDataMessage extends DataBroadcastMessage {
|
||||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||||
|
|
||||||
public final ProtectedMailboxData data;
|
public final ProtectedMailboxData data;
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class EncryptionServiceTests {
|
||||||
|
|
||||||
final class TestMessage implements MailboxMessage {
|
final class TestMessage implements MailboxMessage {
|
||||||
public String data = "test";
|
public String data = "test";
|
||||||
private final int networkId = Version.getNetworkId();
|
private final int messageVersion = Version.getP2PMessageVersion();
|
||||||
|
|
||||||
public TestMessage(String data) {
|
public TestMessage(String data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
|
@ -95,7 +95,7 @@ final class TestMessage implements MailboxMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int networkId() {
|
public int getMessageVersion() {
|
||||||
return networkId;
|
return messageVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import io.bitsquare.p2p.messaging.MailboxMessage;
|
||||||
import io.bitsquare.p2p.storage.data.ExpirablePayload;
|
import io.bitsquare.p2p.storage.data.ExpirablePayload;
|
||||||
|
|
||||||
public final class MockMailboxMessage implements MailboxMessage, ExpirablePayload {
|
public final class MockMailboxMessage implements MailboxMessage, ExpirablePayload {
|
||||||
private final int networkId = Version.getNetworkId();
|
private final int messageVersion = Version.getP2PMessageVersion();
|
||||||
public final String msg;
|
public final String msg;
|
||||||
public final NodeAddress senderNodeAddress;
|
public final NodeAddress senderNodeAddress;
|
||||||
public long ttl;
|
public long ttl;
|
||||||
|
@ -17,8 +17,8 @@ public final class MockMailboxMessage implements MailboxMessage, ExpirablePayloa
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int networkId() {
|
public int getMessageVersion() {
|
||||||
return networkId;
|
return messageVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,15 +7,15 @@ import io.bitsquare.p2p.storage.data.ExpirablePayload;
|
||||||
public final class MockMessage implements Message, ExpirablePayload {
|
public final class MockMessage implements Message, ExpirablePayload {
|
||||||
public final String msg;
|
public final String msg;
|
||||||
public long ttl;
|
public long ttl;
|
||||||
private final int networkId = Version.getNetworkId();
|
private final int messageVersion = Version.getP2PMessageVersion();
|
||||||
|
|
||||||
public MockMessage(String msg) {
|
public MockMessage(String msg) {
|
||||||
this.msg = msg;
|
this.msg = msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int networkId() {
|
public int getMessageVersion() {
|
||||||
return networkId;
|
return messageVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue