From b807ee17a6dfdf2fb841c4ecd74b47b0db9e17a4 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Tue, 24 Mar 2015 18:18:16 +0100 Subject: [PATCH] Refactor persistence (arbitrator) --- .../io/bitsquare/arbitration/Arbitrator.java | 231 +++++++++++------- .../io/bitsquare/gui/main/MainViewModel.java | 49 +--- .../browser/ArbitratorBrowserView.java | 1 - .../ArbitratorRegistrationView.java | 64 ++--- .../content/fiat/FiatAccountDataModel.java | 12 - .../content/irc/IrcAccountDataModel.java | 5 - .../restrictions/RestrictionsDataModel.java | 11 - .../io/bitsquare/persistence/Storage.java | 23 +- .../java/io/bitsquare/trade/Contract.java | 4 +- .../io/bitsquare/user/AccountSettings.java | 5 +- .../main/java/io/bitsquare/util/FileUtil.java | 20 +- .../java/io/bitsquare/util/Utilities.java | 2 +- .../placeoffer/PlaceOfferProtocolTest.java | 16 +- 13 files changed, 210 insertions(+), 233 deletions(-) diff --git a/core/src/main/java/io/bitsquare/arbitration/Arbitrator.java b/core/src/main/java/io/bitsquare/arbitration/Arbitrator.java index 7417207612..ce65addf92 100644 --- a/core/src/main/java/io/bitsquare/arbitration/Arbitrator.java +++ b/core/src/main/java/io/bitsquare/arbitration/Arbitrator.java @@ -17,78 +17,126 @@ package io.bitsquare.arbitration; +import io.bitsquare.locale.LanguageUtil; +import io.bitsquare.persistence.Storage; +import io.bitsquare.user.User; + import org.bitcoinj.core.Coin; +import org.bitcoinj.core.ECKey; import java.io.Serializable; +import java.security.PublicKey; + +import java.util.Arrays; import java.util.List; import java.util.Locale; import java.util.Objects; -public class Arbitrator implements Serializable { - private static final long serialVersionUID = -2625059604136756635L; +import javax.inject.Inject; +public class Arbitrator implements Serializable { + private static final long serialVersionUID = 1L; + + + /////////////////////////////////////////////////////////////////////////////////////////// + // Enums + /////////////////////////////////////////////////////////////////////////////////////////// + + public enum ID_TYPE { + REAL_LIFE_ID, + NICKNAME, + COMPANY + } + + public enum METHOD { + TLS_NOTARY, + SKYPE_SCREEN_SHARING, + SMART_PHONE_VIDEO_CHAT, + REQUIRE_REAL_ID, + BANK_STATEMENT, + OTHER + } + + public enum ID_VERIFICATION { + PASSPORT, + GOV_ID, + UTILITY_BILLS, + FACEBOOK, + GOOGLE_PLUS, + TWITTER, + PGP, + BTC_OTC, + OTHER + } + + + transient private Storage storage; + transient private boolean saveOnEveryUpdate; + + // Persisted fields private String id; - private String pubKeyAsHex; private byte[] pubKey; - private String p2pSigPubKeyAsHex; + private PublicKey p2pSigPubKey; private String name; + private Reputation reputation; + + // editable private ID_TYPE idType; private List languages; - private Reputation reputation; private Coin fee; private List arbitrationMethods; private List idVerifications; - private String webUrl; - private String description; - public Arbitrator() { + + @Inject + public Arbitrator(Storage storage, User user) { + this.storage = storage; + + Arbitrator persisted = storage.getPersisted(this); + if (persisted != null) { + //TODO for mock arbitrator + id = persisted.getName(); + + this.pubKey = persisted.getPubKey(); + this.p2pSigPubKey = persisted.getP2pSigPubKey(); + this.name = persisted.getName(); + this.idType = persisted.getIdType(); + this.languages = persisted.getLanguages(); + this.reputation = persisted.getReputation(); + this.fee = persisted.getFee(); + this.arbitrationMethods = persisted.getArbitrationMethods(); + this.idVerifications = persisted.getIdVerifications(); + this.webUrl = persisted.getWebUrl(); + this.description = persisted.getDescription(); + } + else { + // Mock + id = "Manfred Karrer"; + this.pubKey = new ECKey().getPubKey(); + this.p2pSigPubKey = user.getP2PSigPubKey(); + this.name = "Manfred Karrer"; + this.idType = Arbitrator.ID_TYPE.REAL_LIFE_ID; + this.languages = Arrays.asList(LanguageUtil.getDefaultLanguageLocale()); + this.reputation = new Reputation(); + this.fee = Coin.parseCoin("0.1"); + this.arbitrationMethods = Arrays.asList(Arbitrator.METHOD.TLS_NOTARY); + this.idVerifications = Arrays.asList(ID_VERIFICATION.PASSPORT); + this.webUrl = "https://bitsquare.io"; + this.description = "Bla bla..."; + doSave(); + } } - public Arbitrator(byte[] pubKey, - String p2pSigPubKeyAsHex, - String name, - ID_TYPE idType, - List languages, - Reputation reputation, - Coin fee, - List arbitrationMethods, - List idVerifications, - String webUrl, - String description) { - this.pubKey = pubKey; - this.p2pSigPubKeyAsHex = p2pSigPubKeyAsHex; - this.name = name; - this.idType = idType; - this.languages = languages; - this.reputation = reputation; - this.fee = fee; - this.arbitrationMethods = arbitrationMethods; - this.idVerifications = idVerifications; - this.webUrl = webUrl; - this.description = description; - - //TODO for mock arbitrator - id = name; + public void save() { + if (saveOnEveryUpdate) + doSave(); } - public void applyPersistedArbitrator(Arbitrator persistedArbitrator) { - this.pubKeyAsHex = persistedArbitrator.getPubKeyAsHex(); - this.p2pSigPubKeyAsHex = persistedArbitrator.getPubKeyAsHex(); - this.name = persistedArbitrator.getName(); - this.idType = persistedArbitrator.getIdType(); - this.languages = persistedArbitrator.getLanguages(); - this.reputation = persistedArbitrator.getReputation(); - this.fee = persistedArbitrator.getFee(); - this.arbitrationMethods = persistedArbitrator.getArbitrationMethods(); - this.idVerifications = persistedArbitrator.getIdVerifications(); - this.webUrl = persistedArbitrator.getWebUrl(); - this.description = persistedArbitrator.getDescription(); - - //TODO for mock arbitrator - id = name; + private void doSave() { + storage.save(); } @Override @@ -114,20 +162,48 @@ public class Arbitrator implements Serializable { return id != null && id.equals(other.getId()); } - public String getId() { - return id; + + /////////////////////////////////////////////////////////////////////////////////////////// + // Setters + /////////////////////////////////////////////////////////////////////////////////////////// + + public void setSaveOnEveryUpdate(boolean saveOnEveryUpdate) { + this.saveOnEveryUpdate = saveOnEveryUpdate; } - public String getPubKeyAsHex() { - return pubKeyAsHex; + public void setDescription(String description) { + this.description = description; + doSave(); } - public byte[] getPubKey() { - return pubKey; + public void setIdType(ID_TYPE idType) { + this.idType = idType; + doSave(); } - public String getP2pSigPubKeyAsHex() { - return p2pSigPubKeyAsHex; + public void setLanguages(List languages) { + this.languages = languages; + doSave(); + } + + public void setFee(Coin fee) { + this.fee = fee; + doSave(); + } + + public void setArbitrationMethods(List arbitrationMethods) { + this.arbitrationMethods = arbitrationMethods; + doSave(); + } + + public void setIdVerifications(List idVerifications) { + this.idVerifications = idVerifications; + doSave(); + } + + public void setWebUrl(String webUrl) { + this.webUrl = webUrl; + doSave(); } @@ -135,6 +211,17 @@ public class Arbitrator implements Serializable { // Getters /////////////////////////////////////////////////////////////////////////////////////////// + public String getId() { + return id; + } + + public byte[] getPubKey() { + return pubKey; + } + + public PublicKey getP2pSigPubKey() { + return p2pSigPubKey; + } public String getName() { return name; @@ -171,36 +258,4 @@ public class Arbitrator implements Serializable { public String getDescription() { return description; } - - - /////////////////////////////////////////////////////////////////////////////////////////// - // Enums - /////////////////////////////////////////////////////////////////////////////////////////// - - public enum ID_TYPE { - REAL_LIFE_ID, - NICKNAME, - COMPANY - } - - public enum METHOD { - TLS_NOTARY, - SKYPE_SCREEN_SHARING, - SMART_PHONE_VIDEO_CHAT, - REQUIRE_REAL_ID, - BANK_STATEMENT, - OTHER - } - - public enum ID_VERIFICATION { - PASSPORT, - GOV_ID, - UTILITY_BILLS, - FACEBOOK, - GOOGLE_PLUS, - TWITTER, - PGP, - BTC_OTC, - OTHER - } } diff --git a/core/src/main/java/io/bitsquare/gui/main/MainViewModel.java b/core/src/main/java/io/bitsquare/gui/main/MainViewModel.java index ba3c3e81b0..7653926f9b 100644 --- a/core/src/main/java/io/bitsquare/gui/main/MainViewModel.java +++ b/core/src/main/java/io/bitsquare/gui/main/MainViewModel.java @@ -18,9 +18,7 @@ package io.bitsquare.gui.main; import io.bitsquare.app.UpdateProcess; -import io.bitsquare.arbitration.Arbitrator; import io.bitsquare.arbitration.ArbitratorService; -import io.bitsquare.arbitration.Reputation; import io.bitsquare.btc.BitcoinNetwork; import io.bitsquare.btc.WalletService; import io.bitsquare.common.viewfx.model.ViewModel; @@ -28,27 +26,18 @@ import io.bitsquare.fiat.FiatAccount; import io.bitsquare.fiat.FiatAccountType; import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.locale.CountryUtil; -import io.bitsquare.locale.LanguageUtil; import io.bitsquare.p2p.BaseP2PService; import io.bitsquare.p2p.BootstrapState; import io.bitsquare.p2p.ClientNode; -import io.bitsquare.p2p.MessageService; import io.bitsquare.persistence.Persistence; import io.bitsquare.trade.Trade; import io.bitsquare.trade.TradeManager; import io.bitsquare.user.AccountSettings; import io.bitsquare.user.User; -import io.bitsquare.util.Utilities; - -import org.bitcoinj.core.Coin; -import org.bitcoinj.core.ECKey; import com.google.inject.Inject; -import java.util.ArrayList; import java.util.Currency; -import java.util.List; -import java.util.Locale; import java.util.concurrent.TimeoutException; import javafx.application.Platform; @@ -110,8 +99,8 @@ class MainViewModel implements ViewModel { private AccountSettings accountSettings; @Inject - public MainViewModel(User user, WalletService walletService, ClientNode clientNode, MessageService messageService, - ArbitratorService arbitratorService, + public MainViewModel(User user, WalletService walletService, ClientNode clientNode, + ArbitratorService arbitratorService, TradeManager tradeManager, BitcoinNetwork bitcoinNetwork, UpdateProcess updateProcess, BSFormatter formatter, Persistence persistence, AccountSettings accountSettings) { this.user = user; @@ -129,7 +118,6 @@ class MainViewModel implements ViewModel { updateProcess.state.addListener((observableValue, oldValue, newValue) -> applyUpdateState(newValue)); applyUpdateState(updateProcess.state.get()); - user.currentFiatAccountProperty().addListener((observable, oldValue, newValue) -> persistence.write(user)); currentBankAccount.bind(user.currentFiatAccountProperty()); user.fiatAccountsObservableList().addListener((ListChangeListener) change -> { bankAccountsComboBoxDisable.set(change.getList().isEmpty()); @@ -211,11 +199,6 @@ class MainViewModel implements ViewModel { updateNumPendingTrades(); showAppScreen.set(true); - // For alpha version - // uses messageService, so don't call it before backend is ready - if (accountSettings.getAcceptedArbitrators().isEmpty()) - accountSettings.addAcceptedArbitrator(getMockArbitrator()); - // For alpha version if (!user.isRegistered()) { FiatAccount fiatAccount = new FiatAccount(FiatAccountType.IRC, @@ -226,8 +209,6 @@ class MainViewModel implements ViewModel { "Demo (E.g. IBAN) ", "Demo (E.g. BIC) "); user.addFiatAccount(fiatAccount); - persistence.write(user); - user.setAccountID(walletService.getRegistrationAddressEntry().toString()); } @@ -351,30 +332,4 @@ class MainViewModel implements ViewModel { } } - private Arbitrator getMockArbitrator() { - byte[] pubKey = new ECKey().getPubKey(); - String p2pSigPubKeyAsHex = Utilities.getHexStringFromPublicKey(user.getP2PSigPubKey()); - List languages = new ArrayList<>(); - languages.add(LanguageUtil.getDefaultLanguageLocale()); - List arbitrationMethods = new ArrayList<>(); - arbitrationMethods.add(Arbitrator.METHOD.TLS_NOTARY); - List idVerifications = new ArrayList<>(); - idVerifications.add(Arbitrator.ID_VERIFICATION.PASSPORT); - idVerifications.add(Arbitrator.ID_VERIFICATION.GOV_ID); - - Arbitrator arbitrator = new Arbitrator(pubKey, - p2pSigPubKeyAsHex, - "Manfred Karrer", - Arbitrator.ID_TYPE.REAL_LIFE_ID, - languages, - new Reputation(), - Coin.parseCoin("0.1"), - arbitrationMethods, - idVerifications, - "https://bitsquare.io", - "Bla bla..."); - - arbitratorService.addArbitrator(arbitrator); - return arbitrator; - } } diff --git a/core/src/main/java/io/bitsquare/gui/main/account/arbitrator/browser/ArbitratorBrowserView.java b/core/src/main/java/io/bitsquare/gui/main/account/arbitrator/browser/ArbitratorBrowserView.java index 87b0c95668..c9350194bf 100644 --- a/core/src/main/java/io/bitsquare/gui/main/account/arbitrator/browser/ArbitratorBrowserView.java +++ b/core/src/main/java/io/bitsquare/gui/main/account/arbitrator/browser/ArbitratorBrowserView.java @@ -122,7 +122,6 @@ public class ArbitratorBrowserView extends ActivatableView implement @FXML public void onSelect() { accountSettings.addAcceptedArbitrator(currentArbitrator); - persistence.write(accountSettings); } @FXML diff --git a/core/src/main/java/io/bitsquare/gui/main/account/arbitrator/registration/ArbitratorRegistrationView.java b/core/src/main/java/io/bitsquare/gui/main/account/arbitrator/registration/ArbitratorRegistrationView.java index fcae9d2e89..52bfdd3b74 100644 --- a/core/src/main/java/io/bitsquare/gui/main/account/arbitrator/registration/ArbitratorRegistrationView.java +++ b/core/src/main/java/io/bitsquare/gui/main/account/arbitrator/registration/ArbitratorRegistrationView.java @@ -19,7 +19,6 @@ package io.bitsquare.gui.main.account.arbitrator.registration; import io.bitsquare.arbitration.Arbitrator; import io.bitsquare.arbitration.ArbitratorService; -import io.bitsquare.arbitration.Reputation; import io.bitsquare.btc.WalletService; import io.bitsquare.common.viewfx.view.ActivatableView; import io.bitsquare.common.viewfx.view.FxmlView; @@ -27,7 +26,6 @@ import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator; import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.locale.BSResources; import io.bitsquare.locale.LanguageUtil; -import io.bitsquare.persistence.Persistence; import io.bitsquare.user.User; import io.bitsquare.util.Utilities; @@ -79,18 +77,17 @@ public class ArbitratorRegistrationView extends ActivatableView languageList = new ArrayList<>(); private List methodList = new ArrayList<>(); private List idVerificationList = new ArrayList<>(); - private Arbitrator arbitrator = new Arbitrator(); - private final Persistence persistence; + private final Arbitrator arbitrator; private final WalletService walletService; private final ArbitratorService messageService; private final User user; private final BSFormatter formatter; @Inject - private ArbitratorRegistrationView(Persistence persistence, WalletService walletService, + private ArbitratorRegistrationView(Arbitrator arbitrator, WalletService walletService, ArbitratorService messageService, User user, BSFormatter formatter) { - this.persistence = persistence; + this.arbitrator = arbitrator; this.walletService = walletService; this.messageService = messageService; this.user = user; @@ -101,15 +98,7 @@ public class ArbitratorRegistrationView extends ActivatableView() { @@ -255,17 +244,23 @@ public class ArbitratorRegistrationView extends ActivatableView getAllCountriesFor(Region selectedRegion) { @@ -90,14 +89,12 @@ class RestrictionsDataModel implements Activatable, DataModel { void removeLanguage(Locale locale) { languageList.remove(locale); accountSettings.removeAcceptedLanguageLocale(locale); - saveSettings(); } void addCountry(Country country) { if (!countryList.contains(country) && country != null) { countryList.add(country); accountSettings.addAcceptedCountry(country); - saveSettings(); } } @@ -106,24 +103,16 @@ class RestrictionsDataModel implements Activatable, DataModel { // In addAcceptedCountry there is a check to no add duplicates, so it works correctly for now CountryUtil.getAllEuroCountries().stream().forEach(accountSettings::addAcceptedCountry); countryList.setAll(accountSettings.getAcceptedCountries()); - saveSettings(); return countryList; } void removeCountry(Country country) { countryList.remove(country); accountSettings.removeAcceptedCountry(country); - saveSettings(); } void removeArbitrator(Arbitrator arbitrator) { arbitratorList.remove(arbitrator); accountSettings.removeAcceptedArbitrator(arbitrator); - saveSettings(); - } - - - private void saveSettings() { - persistence.write(accountSettings); } } diff --git a/core/src/main/java/io/bitsquare/persistence/Storage.java b/core/src/main/java/io/bitsquare/persistence/Storage.java index e7dc6c24b9..6709691949 100644 --- a/core/src/main/java/io/bitsquare/persistence/Storage.java +++ b/core/src/main/java/io/bitsquare/persistence/Storage.java @@ -23,8 +23,11 @@ import io.bitsquare.util.FileUtil; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InvalidClassException; import java.io.Serializable; +import java.nio.file.Paths; + import javax.inject.Inject; import javax.inject.Named; @@ -65,12 +68,28 @@ public class Storage { public T getPersisted(T serializable) { this.serializable = serializable; storageFile = new File(dir, serializable.getClass().getSimpleName() + ".ser"); - + if (storageFile == null) throw new RuntimeException("storageFile = null. Call init before using read/write."); try { - return (T) FileUtil.read(storageFile); + T persistedObject = (T) FileUtil.read(storageFile); + + // If we did not get any exception we can be sure the data are consistent so we make a backup + FileUtil.backupFile(storageFile, new File(Paths.get(dir.getAbsolutePath(), "backups").toString()), + serializable.getClass().getSimpleName() + ".ser"); + return persistedObject; + } catch (InvalidClassException e) { + log.error("Version of persisted class has changed. We cannot read the persisted data anymore. We make a backup and remove the inconsistent file."); + try { + // In case the persisted data have been critical (keys) we keep a backup which might be used for recovery + FileUtil.removeAndBackupFile(storageFile, new File(Paths.get(dir.getAbsolutePath(), "inconsistent").toString()), + serializable.getClass().getSimpleName() + ".ser"); + } catch (IOException e1) { + e1.printStackTrace(); + log.error(e1.getMessage()); + // We swallow Exception if backup fails + } } catch (FileNotFoundException e) { log.info("File not available. That is OK for the first run."); } catch (IOException | ClassNotFoundException e) { diff --git a/core/src/main/java/io/bitsquare/trade/Contract.java b/core/src/main/java/io/bitsquare/trade/Contract.java index 2a67513413..5da5822c3e 100644 --- a/core/src/main/java/io/bitsquare/trade/Contract.java +++ b/core/src/main/java/io/bitsquare/trade/Contract.java @@ -59,8 +59,8 @@ public class Contract implements Serializable { this.takerAccountID = takerAccountID; this.offererFiatAccount = offererFiatAccount; this.takerFiatAccount = takerFiatAccount; - this.offererP2PSigPubKeyAsString = Utilities.getHexStringFromPublicKey(offererP2PSigPubKey); - this.takerP2PSigPubKeyAsString = Utilities.getHexStringFromPublicKey(takerP2PSigPubKey); + this.offererP2PSigPubKeyAsString = Utilities.getHexFromPubKey(offererP2PSigPubKey); + this.takerP2PSigPubKeyAsString = Utilities.getHexFromPubKey(takerP2PSigPubKey); } diff --git a/core/src/main/java/io/bitsquare/user/AccountSettings.java b/core/src/main/java/io/bitsquare/user/AccountSettings.java index 4c29df9741..c0e8cdcaad 100644 --- a/core/src/main/java/io/bitsquare/user/AccountSettings.java +++ b/core/src/main/java/io/bitsquare/user/AccountSettings.java @@ -45,13 +45,12 @@ public class AccountSettings implements Serializable { private List acceptedCountryLocales = new ArrayList<>(); private List acceptedArbitrators = new ArrayList<>(); - /////////////////////////////////////////////////////////////////////////////////////////// // Constructor /////////////////////////////////////////////////////////////////////////////////////////// @Inject - public AccountSettings(Storage storage) { + public AccountSettings(Storage storage, Arbitrator defaultArbitrator) { this.storage = storage; AccountSettings persisted = storage.getPersisted(this); @@ -63,7 +62,7 @@ public class AccountSettings implements Serializable { else { acceptedLanguageLocales = Arrays.asList(LanguageUtil.getDefaultLanguageLocale(), LanguageUtil.getEnglishLanguageLocale()); acceptedCountryLocales = Arrays.asList(CountryUtil.getDefaultCountry()); - acceptedArbitrators = new ArrayList<>(); + acceptedArbitrators = Arrays.asList(defaultArbitrator); } } diff --git a/core/src/main/java/io/bitsquare/util/FileUtil.java b/core/src/main/java/io/bitsquare/util/FileUtil.java index 2771db064b..39a770fbf4 100644 --- a/core/src/main/java/io/bitsquare/util/FileUtil.java +++ b/core/src/main/java/io/bitsquare/util/FileUtil.java @@ -20,6 +20,8 @@ package io.bitsquare.util; import org.bitcoinj.core.Utils; import org.bitcoinj.utils.Threading; +import com.google.common.io.Files; + import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -43,9 +45,9 @@ public class FileUtil { FileOutputStream fileOutputStream = null; ObjectOutputStream objectOutputStream = null; try { - if (!dir.exists()) + if (!dir.exists()) dir.mkdir(); - + tempFile = File.createTempFile("temp", null, dir); // Don't use auto closeable resources in try() as we would need too many try/catch clauses (for tempFile) @@ -117,4 +119,18 @@ public class FileUtil { lock.unlock(); } } + + public static void removeAndBackupFile(File storageFile, File dir, String name) throws IOException { + if (!dir.exists()) + dir.mkdir(); + + writeTempFileToFile(storageFile, new File(dir, name)); + } + + public static void backupFile(File storageFile, File dir, String name) throws IOException { + if (!dir.exists()) + dir.mkdir(); + + Files.copy(storageFile, new File(dir, name)); + } } diff --git a/core/src/main/java/io/bitsquare/util/Utilities.java b/core/src/main/java/io/bitsquare/util/Utilities.java index ab9b31e3cf..24bf63f0a4 100644 --- a/core/src/main/java/io/bitsquare/util/Utilities.java +++ b/core/src/main/java/io/bitsquare/util/Utilities.java @@ -295,7 +295,7 @@ public class Utilities { return animationTimer; } - public static String getHexStringFromPublicKey(PublicKey publicKey) { + public static String getHexFromPubKey(PublicKey publicKey) { final X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(publicKey.getEncoded()); return Utils.HEX.encode(x509EncodedKeySpec.getEncoded()); } diff --git a/core/src/test/java/io/bitsquare/trade/protocol/placeoffer/PlaceOfferProtocolTest.java b/core/src/test/java/io/bitsquare/trade/protocol/placeoffer/PlaceOfferProtocolTest.java index 50ce2f5472..d680f5f008 100644 --- a/core/src/test/java/io/bitsquare/trade/protocol/placeoffer/PlaceOfferProtocolTest.java +++ b/core/src/test/java/io/bitsquare/trade/protocol/placeoffer/PlaceOfferProtocolTest.java @@ -17,17 +17,10 @@ package io.bitsquare.trade.protocol.placeoffer; -import io.bitsquare.arbitration.Arbitrator; import io.bitsquare.btc.BitcoinNetwork; import io.bitsquare.btc.FeePolicy; import io.bitsquare.btc.UserAgent; import io.bitsquare.btc.WalletService; -import io.bitsquare.crypto.EncryptionService; -import io.bitsquare.fiat.FiatAccountType; -import io.bitsquare.locale.CountryUtil; -import io.bitsquare.locale.LanguageUtil; -import io.bitsquare.offer.Direction; -import io.bitsquare.offer.Offer; import io.bitsquare.offer.OfferBookService; import io.bitsquare.offer.tomp2p.TomP2POfferBookService; import io.bitsquare.p2p.BootstrapState; @@ -40,16 +33,11 @@ import io.bitsquare.persistence.Persistence; import io.bitsquare.user.User; import org.bitcoinj.core.Address; -import org.bitcoinj.core.Coin; import org.bitcoinj.utils.Threading; import java.io.File; import java.io.IOException; -import java.security.NoSuchAlgorithmException; - -import java.util.Arrays; -import java.util.Currency; import java.util.concurrent.CountDownLatch; import org.junit.After; @@ -301,7 +289,7 @@ public class PlaceOfferProtocolTest { faultHandler); }*/ - private Offer getOffer() throws NoSuchAlgorithmException { +/* private Offer getOffer() throws NoSuchAlgorithmException { return new Offer(OFFER_ID, new EncryptionService().getGeneratedDSAKeyPair().getPublic(), Direction.BUY, @@ -317,5 +305,5 @@ public class PlaceOfferProtocolTest { Arrays.asList(CountryUtil.getDefaultCountry()), Arrays.asList(LanguageUtil.getDefaultLanguageLocale()) ); - } + }*/ }