diff --git a/common/src/main/java/io/bitsquare/common/crypto/Encryption.java b/common/src/main/java/io/bitsquare/common/crypto/Encryption.java index a8e7ce1d1d..8ab4f05089 100644 --- a/common/src/main/java/io/bitsquare/common/crypto/Encryption.java +++ b/common/src/main/java/io/bitsquare/common/crypto/Encryption.java @@ -22,7 +22,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.spongycastle.util.encoders.Hex; -import javax.crypto.*; +import javax.crypto.Cipher; +import javax.crypto.KeyGenerator; +import javax.crypto.Mac; +import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -51,7 +54,7 @@ public class Encryption { KeyPair keyPair = keyPairGenerator.genKeyPair(); log.trace("Generate msgEncryptionKeyPair needed {} ms", System.currentTimeMillis() - ts); return keyPair; - } catch (NoSuchAlgorithmException | NoSuchProviderException e) { + } catch (Throwable e) { e.printStackTrace(); throw new RuntimeException("Could not create key."); } @@ -67,8 +70,7 @@ public class Encryption { Cipher cipher = Cipher.getInstance(SYM_CIPHER, "BC"); cipher.init(Cipher.ENCRYPT_MODE, secretKey); return cipher.doFinal(payload); - } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException - | BadPaddingException | IllegalBlockSizeException | NoSuchProviderException e) { + } catch (Throwable e) { e.printStackTrace(); throw new CryptoException(e); } @@ -79,8 +81,7 @@ public class Encryption { Cipher cipher = Cipher.getInstance(SYM_CIPHER, "BC"); cipher.init(Cipher.DECRYPT_MODE, secretKey); return cipher.doFinal(encryptedPayload); - } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException - | BadPaddingException | IllegalBlockSizeException | NoSuchProviderException e) { + } catch (Throwable e) { throw new CryptoException(e); } } @@ -113,7 +114,7 @@ public class Encryption { } } } - } catch (NoSuchAlgorithmException | InvalidKeyException e) { + } catch (Throwable e) { e.printStackTrace(); throw new RuntimeException("Could not create hmac"); } @@ -125,7 +126,7 @@ public class Encryption { try { byte[] hmacTest = getHmac(message, secretKey); return Arrays.equals(hmacTest, hmac); - } catch (NoSuchAlgorithmException | InvalidKeyException | NoSuchProviderException e) { + } catch (Throwable e) { e.printStackTrace(); throw new RuntimeException("Could not create cipher"); } @@ -176,8 +177,7 @@ public class Encryption { Cipher cipher = Cipher.getInstance(ASYM_CIPHER, "BC"); cipher.init(Cipher.ENCRYPT_MODE, publicKey); return cipher.doFinal(payload); - } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException - | BadPaddingException | IllegalBlockSizeException | NoSuchProviderException e) { + } catch (Throwable e) { e.printStackTrace(); throw new CryptoException("Couldn't encrypt payload"); } @@ -188,8 +188,7 @@ public class Encryption { Cipher cipher = Cipher.getInstance(ASYM_CIPHER, "BC"); cipher.init(Cipher.DECRYPT_MODE, privateKey); return cipher.doFinal(encryptedPayload); - } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException - | BadPaddingException | IllegalBlockSizeException | NoSuchProviderException e) { + } catch (Throwable e) { // errors when trying to decrypt foreign messages are normal throw new CryptoException(e); } @@ -259,7 +258,7 @@ public class Encryption { KeyGenerator keyPairGenerator = KeyGenerator.getInstance(SYM_CIPHER, "BC"); keyPairGenerator.init(256); return keyPairGenerator.generateKey(); - } catch (NoSuchAlgorithmException | NoSuchProviderException e) { + } catch (Throwable e) { e.printStackTrace(); throw new RuntimeException("Couldn't generate key"); } diff --git a/core/src/main/java/io/bitsquare/btc/TradeWalletService.java b/core/src/main/java/io/bitsquare/btc/TradeWalletService.java index 9663ea169e..214c861f3c 100644 --- a/core/src/main/java/io/bitsquare/btc/TradeWalletService.java +++ b/core/src/main/java/io/bitsquare/btc/TradeWalletService.java @@ -472,9 +472,10 @@ public class TradeWalletService { // Check if OP_RETURN output with contract hash matches the one from the offerer TransactionOutput contractHashOutput = new TransactionOutput(params, offerersDepositTx, Coin.ZERO, ScriptBuilder.createOpReturnScript(contractHash).getProgram()); - + log.debug("contractHashOutput " + contractHashOutput); TransactionOutput offerersContractHashOutput = offerersDepositTx.getOutputs().get(1); - if (!offerersContractHashOutput.equals(contractHashOutput)) + log.debug("offerersContractHashOutput " + offerersContractHashOutput); + if (!offerersContractHashOutput.getScriptPubKey().equals(contractHashOutput.getScriptPubKey())) throw new TransactionVerificationException("Offerers transaction output for the contract hash is not matching takers version."); // Add all outputs from offerersDepositTx to depositTx diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/tasks/buyer/SignAndPublishDepositTxAsBuyer.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/tasks/buyer/SignAndPublishDepositTxAsBuyer.java index 4ea7c80d15..33fb81637e 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/tasks/buyer/SignAndPublishDepositTxAsBuyer.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/tasks/buyer/SignAndPublishDepositTxAsBuyer.java @@ -41,6 +41,11 @@ public class SignAndPublishDepositTxAsBuyer extends TradeTask { try { runInterceptHook(); + log.debug("getContractAsJson"); + log.debug("----------"); + log.debug(trade.getContractAsJson()); + log.debug("----------"); + byte[] contractHash = Hash.getHash(trade.getContractAsJson()); trade.setContractHash(contractHash); processModel.getTradeWalletService().takerSignsAndPublishesDepositTx( diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/tasks/seller/SignAndPublishDepositTxAsSeller.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/tasks/seller/SignAndPublishDepositTxAsSeller.java index 018182abe3..6b7ffaf24c 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/tasks/seller/SignAndPublishDepositTxAsSeller.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/tasks/seller/SignAndPublishDepositTxAsSeller.java @@ -44,6 +44,7 @@ public class SignAndPublishDepositTxAsSeller extends TradeTask { log.debug("----------"); log.debug(trade.getContractAsJson()); log.debug("----------"); + byte[] contractHash = Hash.getHash(trade.getContractAsJson()); trade.setContractHash(contractHash); processModel.getTradeWalletService().takerSignsAndPublishesDepositTx( diff --git a/core/src/main/java/io/bitsquare/user/Preferences.java b/core/src/main/java/io/bitsquare/user/Preferences.java index 7f8ffd48ee..f4234fd998 100644 --- a/core/src/main/java/io/bitsquare/user/Preferences.java +++ b/core/src/main/java/io/bitsquare/user/Preferences.java @@ -348,7 +348,13 @@ public class Preferences implements Serializable { } public boolean showAgain(String key) { - return getShowAgainMap().containsKey(key) && getShowAgainMap().get(key); + // if we add new and those are not in our stored map we display by default the new popup + if (!getShowAgainMap().containsKey(key)) { + showAgainMap.put(key, true); + storage.queueUpForSave(); + } + + return showAgainMap.get(key); } public boolean getTacAccepted() { diff --git a/gui/src/main/java/io/bitsquare/gui/main/offer/createoffer/CreateOfferDataModel.java b/gui/src/main/java/io/bitsquare/gui/main/offer/createoffer/CreateOfferDataModel.java index c7e8f92ac8..f35875e322 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/offer/createoffer/CreateOfferDataModel.java +++ b/gui/src/main/java/io/bitsquare/gui/main/offer/createoffer/CreateOfferDataModel.java @@ -354,4 +354,8 @@ class CreateOfferDataModel extends ActivatableDataModel { public boolean getShowPlaceOfferConfirmation() { return preferences.getShowPlaceOfferConfirmation(); } + + public Preferences getPreferences() { + return preferences; + } } diff --git a/gui/src/main/java/io/bitsquare/gui/main/offer/createoffer/CreateOfferView.java b/gui/src/main/java/io/bitsquare/gui/main/offer/createoffer/CreateOfferView.java index c1cd7f5036..c6f32a8193 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/offer/createoffer/CreateOfferView.java +++ b/gui/src/main/java/io/bitsquare/gui/main/offer/createoffer/CreateOfferView.java @@ -20,6 +20,7 @@ package io.bitsquare.gui.main.offer.createoffer; import de.jensd.fx.fontawesome.AwesomeDude; import de.jensd.fx.fontawesome.AwesomeIcon; import io.bitsquare.app.BitsquareApp; +import io.bitsquare.common.UserThread; import io.bitsquare.common.util.Tuple2; import io.bitsquare.common.util.Tuple3; import io.bitsquare.gui.Navigation; @@ -36,6 +37,7 @@ import io.bitsquare.gui.main.account.settings.AccountSettingsView; import io.bitsquare.gui.main.offer.OfferView; import io.bitsquare.gui.main.portfolio.PortfolioView; import io.bitsquare.gui.main.portfolio.openoffer.OpenOffersView; +import io.bitsquare.gui.main.portfolio.pendingtrades.PendingTradesView; import io.bitsquare.gui.popups.OfferDetailsPopup; import io.bitsquare.gui.popups.Popup; import io.bitsquare.gui.util.BSFormatter; @@ -59,6 +61,7 @@ import javafx.util.StringConverter; import org.controlsfx.control.PopOver; import javax.inject.Inject; +import java.util.concurrent.TimeUnit; import static io.bitsquare.gui.util.FormBuilder.*; import static javafx.beans.binding.Bindings.createStringBinding; @@ -428,11 +431,17 @@ public class CreateOfferView extends ActivatableViewAndModel close()) - .show(); + if (newValue) { + UserThread.runAfter(() -> { + new Popup().headLine(BSResources.get("createOffer.success.headline")) + .message(BSResources.get("createOffer.success.info")) + .onClose(() -> { + navigation.navigateTo(MainView.class, PortfolioView.class, PendingTradesView.class); + close(); + }) + .show(); + }, 300, TimeUnit.MILLISECONDS); + } }; } diff --git a/gui/src/main/java/io/bitsquare/gui/main/offer/takeoffer/TakeOfferDataModel.java b/gui/src/main/java/io/bitsquare/gui/main/offer/takeoffer/TakeOfferDataModel.java index 3373913a8a..8873c339c8 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/offer/takeoffer/TakeOfferDataModel.java +++ b/gui/src/main/java/io/bitsquare/gui/main/offer/takeoffer/TakeOfferDataModel.java @@ -318,4 +318,8 @@ class TakeOfferDataModel extends ActivatableDataModel { public List getArbitrators() { return user.getAcceptedArbitrators(); } + + public Preferences getPreferences() { + return preferences; + } } diff --git a/gui/src/main/java/io/bitsquare/gui/main/offer/takeoffer/TakeOfferView.java b/gui/src/main/java/io/bitsquare/gui/main/offer/takeoffer/TakeOfferView.java index cdf317ed11..17c7eff4cb 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/offer/takeoffer/TakeOfferView.java +++ b/gui/src/main/java/io/bitsquare/gui/main/offer/takeoffer/TakeOfferView.java @@ -20,6 +20,7 @@ package io.bitsquare.gui.main.offer.takeoffer; import de.jensd.fx.fontawesome.AwesomeDude; import de.jensd.fx.fontawesome.AwesomeIcon; import io.bitsquare.app.BitsquareApp; +import io.bitsquare.common.UserThread; import io.bitsquare.common.util.Tuple2; import io.bitsquare.common.util.Tuple3; import io.bitsquare.gui.Navigation; @@ -63,6 +64,7 @@ import org.fxmisc.easybind.Subscription; import javax.inject.Inject; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.TimeUnit; import static io.bitsquare.gui.util.FormBuilder.*; import static javafx.beans.binding.Bindings.createStringBinding; @@ -220,13 +222,16 @@ public class TakeOfferView extends ActivatableViewAndModel { - navigation.navigateTo(MainView.class, PortfolioView.class, PendingTradesView.class); - close(); - }) - .show(); + if (newValue && model.getTrade() != null && model.getTrade().errorMessageProperty().get() == null) { + UserThread.runAfter(() -> { + new Popup().information(BSResources.get("takeOffer.success.info")) + .onClose(() -> { + navigation.navigateTo(MainView.class, PortfolioView.class, PendingTradesView.class); + close(); + }) + .show(); + }, 300, TimeUnit.MILLISECONDS); + } }); if (model.getPossiblePaymentAccounts().size() > 1) { @@ -318,8 +323,7 @@ public class TakeOfferView extends ActivatableViewAndModel model.onTakeOffer()).show(offer); - } - else { + } else { if (model.hasAcceptedArbitrators()) { model.onTakeOffer(); } else { diff --git a/gui/src/main/java/io/bitsquare/gui/main/portfolio/pendingtrades/steps/StartPaymentView.java b/gui/src/main/java/io/bitsquare/gui/main/portfolio/pendingtrades/steps/StartPaymentView.java index c72ded76c6..ec37b44e67 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/portfolio/pendingtrades/steps/StartPaymentView.java +++ b/gui/src/main/java/io/bitsquare/gui/main/portfolio/pendingtrades/steps/StartPaymentView.java @@ -73,8 +73,8 @@ public class StartPaymentView extends TradeStepDetailsView { if (preferences.showAgain(key) && !BitsquareApp.DEV_MODE) { new Popup().information("You need to transfer now the agreed amount to your trading partner.\n" + "Please take care that you use the exact data presented here, including the reference text\n" + - "Please do not click the \"Payment started\" button if you have before you have completed the transfer.\n" + - "Take care that you make the transfer soon to not miss the exceed trading period.") + "Please do not click the \"Payment started\" button before you have completed the transfer.\n" + + "Take care that you make the transfer soon to not exceed the trading period.") .onClose(() -> preferences.dontShowAgain(key)) .show(); } diff --git a/gui/src/main/java/io/bitsquare/gui/popups/OfferDetailsPopup.java b/gui/src/main/java/io/bitsquare/gui/popups/OfferDetailsPopup.java index 353621ef22..886e32711c 100644 --- a/gui/src/main/java/io/bitsquare/gui/popups/OfferDetailsPopup.java +++ b/gui/src/main/java/io/bitsquare/gui/popups/OfferDetailsPopup.java @@ -193,7 +193,7 @@ public class OfferDetailsPopup extends Popup { }); CheckBox checkBox = addCheckBox(gridPane, ++rowIndex, "Don't show again", 5); - checkBox.setPadding(new Insets(10, 0, 15, 0)); + checkBox.setPadding(new Insets(20, 0, 25, 0)); checkBox.setSelected(!preferences.getShowTakeOfferConfirmation()); checkBox.setOnAction(e -> preferences.setShowTakeOfferConfirmation(!checkBox.isSelected())); } else { diff --git a/gui/src/main/java/io/bitsquare/gui/popups/WebViewPopup.java b/gui/src/main/java/io/bitsquare/gui/popups/WebViewPopup.java index 9060df5b53..0579a922ae 100644 --- a/gui/src/main/java/io/bitsquare/gui/popups/WebViewPopup.java +++ b/gui/src/main/java/io/bitsquare/gui/popups/WebViewPopup.java @@ -52,7 +52,7 @@ public class WebViewPopup extends Popup { webView.getEngine().documentProperty().addListener((observable, oldValue, newValue) -> { String heightInPx = webView.getEngine() .executeScript("window.getComputedStyle(document.body, null).getPropertyValue('height')").toString(); - double height = Double.valueOf(heightInPx.replace("px", "")); + double height = Double.valueOf(heightInPx.replace("px", "")) * 1.2; webView.setPrefHeight(height); stage.setMinHeight(height + gridPane.getHeight()); centerPopup(); diff --git a/gui/src/main/resources/html/base.css b/gui/src/main/resources/html/base.css index 622231d36d..38b3a259f4 100644 --- a/gui/src/main/resources/html/base.css +++ b/gui/src/main/resources/html/base.css @@ -19,7 +19,7 @@ body { font-family: sans-serif; color: #333; font-size: 14px; - line-height: 2; + line-height: 1.5; } a { diff --git a/gui/src/main/resources/i18n/displayStrings.properties b/gui/src/main/resources/i18n/displayStrings.properties index 80ca8475ab..ee2fe86035 100644 --- a/gui/src/main/resources/i18n/displayStrings.properties +++ b/gui/src/main/resources/i18n/displayStrings.properties @@ -76,7 +76,7 @@ createOffer.advancedBox.county=Payments account country: createOffer.advancedBox.info=Your trading partners must fulfill your offer restrictions. You can edit the accepted countries, languages and arbitrators in the settings. The payments account details are used from your current selected payments account (if you have multiple payments accounts). createOffer.success.headline=Your offer has been published to the offerbook. -createOffer.success.info=In the portfolio screen you can manage your open offers. +createOffer.success.info=You can manage your open offers in the \"Portfolio\" screen under \"Open offers\". createOffer.error.message=An error occurred when placing the offer.\n\n{0} @@ -136,8 +136,8 @@ takeOffer.advancedBox.info=These are the offer restrictions your trading partner takeOffer.success.headline=Your have successfully published the deposit. takeOffer.success.info=You need to wait now for the Bitcoin buyer to transfer the money to you. \nYou will get a \ - notification when he has started the EUR payment. You can see the status of your trade in the screen \ - under open trades. + notification when he has started the EUR payment. You can see the status of your trade in the \"Portfolio\" screen \ + under \"Open trades\". takeOffer.error.message=An error occurred when taking the offer.\n\n{0} # Payment methods