use of io.bitsquare.user.Preferences in project bitsquare by bitsquare.
the class SellerStep3View method onPaymentReceived.
////////////////////////////////////////////////////////////////////////////////////////
// UI Handlers
///////////////////////////////////////////////////////////////////////////////////////////
private void onPaymentReceived() {
log.debug("onPaymentReceived");
if (model.p2PService.isBootstrapped()) {
Preferences preferences = model.dataModel.preferences;
String key = "confirmPaymentReceived";
if (!DevFlags.DEV_MODE && preferences.showAgain(key)) {
PaymentAccountContractData paymentAccountContractData = model.dataModel.getSellersPaymentAccountContractData();
String message = "Have you received the " + CurrencyUtil.getNameByCode(model.dataModel.getCurrencyCode()) + " payment from your trading partner?\n\n";
if (!(paymentAccountContractData instanceof CryptoCurrencyAccountContractData)) {
message += "The trade ID (\"reason for payment\" text) of the transaction is: \"" + trade.getShortId() + "\"\n\n";
Optional<String> optionalHolderName = getOptionalHolderName();
if (optionalHolderName.isPresent()) {
message += "Please also verify that the senders name in your bank statement matches that one from the trade contract:\n" + "Senders name: " + optionalHolderName.get() + "\n\n" + "If the name is not the same as the one displayed here, please don't confirm but open a " + "dispute by entering \"cmd + o\" or \"ctrl + o\".\n\n";
}
}
message += "Please note, that as soon you have confirmed the receipt, the locked trade amount will be released " + "to the BTC buyer and the security deposit will be refunded.";
new Popup().headLine("Confirm that you have received the payment").confirmation(message).width(700).actionButtonText("Yes, I have received the payment").onAction(this::confirmPaymentReceived).closeButtonText("Cancel").show();
} else {
confirmPaymentReceived();
}
} else {
new Popup().information("You need to wait until you are fully connected to the network.\n" + "That might take up to about 2 minutes at startup.").show();
}
}
use of io.bitsquare.user.Preferences in project bitsquare by bitsquare.
the class GUIUtil method openWebPage.
public static void openWebPage(String target) {
String key = "warnOpenURLWhenTorEnabled";
final Preferences preferences = Preferences.INSTANCE;
if (preferences.showAgain(key)) {
new Popup<>().information("You are going to open a web page " + "in your system web browser.\n" + "Do you want to open the web page now?\n\n" + "If you are not using the \"Tor Browser\" as your default system web browser you " + "will connect to the web page in clear net.\n\n" + "URL: \"" + target).actionButtonText("Open the web page and don't ask again").onAction(() -> {
preferences.dontShowAgain(key, true);
doOpenWebPage(target);
}).closeButtonText("Copy URL and cancel").onClose(() -> Utilities.copyToClipboard(target)).show();
} else {
doOpenWebPage(target);
}
}
use of io.bitsquare.user.Preferences in project bitsquare by bitsquare.
the class TakeOfferView method addSubscriptions.
private void addSubscriptions() {
errorPopupDisplayed = new SimpleBooleanProperty();
offerWarningSubscription = EasyBind.subscribe(model.offerWarning, newValue -> {
if (newValue != null) {
if (offerDetailsWindowDisplayed)
offerDetailsWindow.hide();
UserThread.runAfter(() -> new Popup().warning(newValue + "\n\n" + "If you have already paid in funds you can withdraw it in the " + "\"Funds/Available for withdrawal\" screen.").actionButtonText("Go to \"Available for withdrawal\"").onAction(() -> {
errorPopupDisplayed.set(true);
model.resetOfferWarning();
close();
navigation.navigateTo(MainView.class, FundsView.class, WithdrawalView.class);
}).onClose(() -> {
errorPopupDisplayed.set(true);
model.resetOfferWarning();
close();
}).show(), 100, TimeUnit.MILLISECONDS);
}
});
errorMessageSubscription = EasyBind.subscribe(model.errorMessage, newValue -> {
if (newValue != null) {
new Popup().error(BSResources.get("takeOffer.error.message", model.errorMessage.get()) + "Please try to restart you application and check your network connection to see if you can resolve the issue.").onClose(() -> {
errorPopupDisplayed.set(true);
model.resetErrorMessage();
close();
}).show();
}
});
isOfferAvailableSubscription = EasyBind.subscribe(model.isOfferAvailable, isOfferAvailable -> {
if (isOfferAvailable)
offerAvailabilityBusyAnimation.stop();
offerAvailabilityLabel.setVisible(!isOfferAvailable);
offerAvailabilityLabel.setManaged(!isOfferAvailable);
});
isWaitingForFundsSubscription = EasyBind.subscribe(model.isWaitingForFunds, isWaitingForFunds -> {
waitingForFundsBusyAnimation.setIsRunning(isWaitingForFunds);
waitingForFundsLabel.setVisible(isWaitingForFunds);
waitingForFundsLabel.setManaged(isWaitingForFunds);
});
showWarningInvalidBtcDecimalPlacesSubscription = EasyBind.subscribe(model.showWarningInvalidBtcDecimalPlaces, newValue -> {
if (newValue) {
new Popup().warning(BSResources.get("takeOffer.amountPriceBox.warning.invalidBtcDecimalPlaces")).show();
model.showWarningInvalidBtcDecimalPlaces.set(false);
}
});
showTransactionPublishedScreenSubscription = EasyBind.subscribe(model.showTransactionPublishedScreen, newValue -> {
if (newValue && DevFlags.DEV_MODE) {
close();
} else if (newValue && model.getTrade() != null && model.getTrade().errorMessageProperty().get() == null) {
String key = "takeOfferSuccessInfo";
if (preferences.showAgain(key)) {
UserThread.runAfter(() -> new Popup().headLine(BSResources.get("takeOffer.success.headline")).feedback(BSResources.get("takeOffer.success.info")).actionButtonText("Go to \"Open trades\"").dontShowAgainId(key, preferences).onAction(() -> {
UserThread.runAfter(() -> navigation.navigateTo(MainView.class, PortfolioView.class, PendingTradesView.class), 100, TimeUnit.MILLISECONDS);
close();
}).onClose(this::close).show(), 1);
} else {
close();
}
}
});
/* noSufficientFeeBinding = EasyBind.combine(model.dataModel.isWalletFunded, model.dataModel.isMainNet, model.dataModel.isFeeFromFundingTxSufficient,
(isWalletFunded, isMainNet, isFeeSufficient) -> isWalletFunded && isMainNet && !isFeeSufficient);
noSufficientFeeSubscription = noSufficientFeeBinding.subscribe((observable, oldValue, newValue) -> {
if (newValue)
new Popup().warning("The mining fee from your funding transaction is not sufficiently high.\n\n" +
"You need to use at least a mining fee of " +
model.formatter.formatCoinWithCode(FeePolicy.getMinRequiredFeeForFundingTx()) + ".\n\n" +
"The fee used in your funding transaction was only " +
model.formatter.formatCoinWithCode(model.dataModel.feeFromFundingTx) + ".\n\n" +
"The trade transactions might take too much time to be included in " +
"a block if the fee is too low.\n" +
"Please check at your external wallet that you set the required fee and " +
"do a funding again with the correct fee.\n\n" +
"In the \"Funds/Open for withdrawal\" section you can withdraw those funds.")
.closeButtonText("Close")
.onClose(() -> {
close();
navigation.navigateTo(MainView.class, FundsView.class, WithdrawalView.class);
})
.show();
});*/
balanceSubscription = EasyBind.subscribe(model.dataModel.balance, newValue -> balanceTextField.setBalance(newValue));
cancelButton2StyleSubscription = EasyBind.subscribe(takeOfferButton.visibleProperty(), isVisible -> cancelButton2.setId(isVisible ? "cancel-button" : null));
}
use of io.bitsquare.user.Preferences in project bitsquare by bitsquare.
the class MainViewModel method start.
///////////////////////////////////////////////////////////////////////////////////////////
// API
///////////////////////////////////////////////////////////////////////////////////////////
public void start() {
// TODO need more though how to improve privacy without annoying first time users.
/* String key = "showAddBitcoinNodesWindowKey";
if (preferences.showAgain(key))
addBitcoinNodesWindow.dontShowAgainId(key, preferences)
.onClose(() -> {
preferences.dontShowAgain(key, true);
initializeAllServices();
})
.onAction(() -> {
preferences.dontShowAgain(key, true);
initializeAllServices();
})
.show();
else
initializeAllServices();
}
private void initializeAllServices() {*/
Log.traceCall();
UserThread.runAfter(tacWindow::showIfNeeded, 2);
ChangeListener<Boolean> walletInitializedListener = (observable, oldValue, newValue) -> {
if (newValue && !p2pNetWorkReady.get())
showStartupTimeoutPopup();
};
Timer startupTimeout = UserThread.runAfter(() -> {
log.warn("startupTimeout called");
Wallet wallet = walletService.getWallet();
if (wallet != null && wallet.isEncrypted())
walletInitialized.addListener(walletInitializedListener);
else
showStartupTimeoutPopup();
}, 4, TimeUnit.MINUTES);
p2pNetWorkReady = initP2PNetwork();
initBitcoinWallet();
// need to store it to not get garbage collected
allServicesDone = EasyBind.combine(walletInitialized, p2pNetWorkReady, (a, b) -> a && b);
allServicesDone.subscribe((observable, oldValue, newValue) -> {
if (newValue) {
startupTimeout.stop();
walletInitialized.removeListener(walletInitializedListener);
onAllServicesInitialized();
if (startupTimeoutPopup != null)
startupTimeoutPopup.hide();
}
});
}
use of io.bitsquare.user.Preferences in project bitsquare by bitsquare.
the class MainViewModel method onAllServicesInitialized.
private void onAllServicesInitialized() {
Log.traceCall();
clock.start();
// disputeManager
disputeManager.onAllServicesInitialized();
disputeManager.getDisputesAsObservableList().addListener((ListChangeListener<Dispute>) change -> {
change.next();
onDisputesChangeListener(change.getAddedSubList(), change.getRemoved());
});
onDisputesChangeListener(disputeManager.getDisputesAsObservableList(), null);
// tradeManager
tradeManager.onAllServicesInitialized();
tradeManager.getTrades().addListener((ListChangeListener<Trade>) c -> updateBalance());
tradeManager.getTrades().addListener((ListChangeListener<Trade>) change -> onTradesChanged());
onTradesChanged();
// We handle the trade period here as we display a global popup if we reached dispute time
tradesAndUIReady = EasyBind.combine(isSplashScreenRemoved, tradeManager.pendingTradesInitializedProperty(), (a, b) -> a && b);
tradesAndUIReady.subscribe((observable, oldValue, newValue) -> {
if (newValue)
applyTradePeriodState();
});
// walletService
walletService.addBalanceListener(new BalanceListener() {
@Override
public void onBalanceChanged(Coin balance, Transaction tx) {
updateBalance();
}
});
openOfferManager.getOpenOffers().addListener((ListChangeListener<OpenOffer>) c -> updateBalance());
tradeManager.getTrades().addListener((ListChangeListener<Trade>) c -> updateBalance());
openOfferManager.onAllServicesInitialized();
arbitratorManager.onAllServicesInitialized();
alertManager.alertMessageProperty().addListener((observable, oldValue, newValue) -> displayAlertIfPresent(newValue));
privateNotificationManager.privateNotificationProperty().addListener((observable, oldValue, newValue) -> displayPrivateNotification(newValue));
displayAlertIfPresent(alertManager.alertMessageProperty().get());
p2PService.onAllServicesInitialized();
setupBtcNumPeersWatcher();
setupP2PNumPeersWatcher();
updateBalance();
if (DevFlags.DEV_MODE) {
preferences.setShowOwnOffersInOfferBook(true);
if (user.getPaymentAccounts().isEmpty())
setupDevDummyPaymentAccounts();
}
setupMarketPriceFeed();
swapPendingOfferFundingEntries();
fillPriceFeedComboBoxItems();
showAppScreen.set(true);
// We want to test if the client is compiled with the correct crypto provider (BountyCastle)
// and if the unlimited Strength for cryptographic keys is set.
// If users compile themselves they might miss that step and then would get an exception in the trade.
// To avoid that we add here at startup a sample encryption and signing to see if it don't causes an exception.
// See: https://github.com/bitsquare/bitsquare/blob/master/doc/build.md#7-enable-unlimited-strength-for-cryptographic-keys
Thread checkCryptoThread = new Thread() {
@Override
public void run() {
try {
Thread.currentThread().setName("checkCryptoThread");
log.trace("Run crypto test");
// just use any simple dummy msg
io.bitsquare.p2p.peers.keepalive.messages.Ping payload = new Ping(1, 1);
SealedAndSigned sealedAndSigned = Encryption.encryptHybridWithSignature(payload, keyRing.getSignatureKeyPair(), keyRing.getPubKeyRing().getEncryptionPubKey());
DecryptedDataTuple tuple = Encryption.decryptHybridWithSignature(sealedAndSigned, keyRing.getEncryptionKeyPair().getPrivate());
if (tuple.payload instanceof Ping && ((Ping) tuple.payload).nonce == payload.nonce && ((Ping) tuple.payload).lastRoundTripTime == payload.lastRoundTripTime)
log.debug("Crypto test succeeded");
else
throw new CryptoException("Payload not correct after decryption");
} catch (CryptoException e) {
e.printStackTrace();
String msg = "Seems that you use a self compiled binary and have not following the build " + "instructions in https://github.com/bitsquare/bitsquare/blob/master/doc/build.md#7-enable-unlimited-strength-for-cryptographic-keys.\n\n" + "If that is not the case and you use the official Bitsquare binary, " + "please file a bug report to the Github page.\n" + "Error=" + e.getMessage();
log.error(msg);
UserThread.execute(() -> new Popup<>().warning(msg).actionButtonText("Shut down").onAction(BitsquareApp.shutDownHandler::run).closeButtonText("Report bug at Github issues").onClose(() -> GUIUtil.openWebPage("https://github.com/bitsquare/bitsquare/issues")).show());
}
}
};
checkCryptoThread.start();
if (Security.getProvider("BC") == null) {
new Popup<>().warning("There is a problem with the crypto libraries. BountyCastle is not available.").actionButtonText("Shut down").onAction(BitsquareApp.shutDownHandler::run).closeButtonText("Report bug at Github issues").onClose(() -> GUIUtil.openWebPage("https://github.com/bitsquare/bitsquare/issues")).show();
}
String remindPasswordAndBackupKey = "remindPasswordAndBackup";
user.getPaymentAccountsAsObservable().addListener((SetChangeListener<PaymentAccount>) change -> {
if (!walletService.getWallet().isEncrypted() && preferences.showAgain(remindPasswordAndBackupKey) && change.wasAdded()) {
new Popup<>().headLine("Important security recommendation").information("We would like to remind you to consider using password protection for your wallet if you have not already enabled that.\n\n" + "It is also highly recommended to write down the wallet seed words. Those seed words are like a master password for recovering your Bitcoin wallet.\n" + "At the \"Wallet Seed\" section you find more information.\n\n" + "Additionally you can backup the complete application data folder at the \"Backup\" section.\n" + "Please note, that this backup is not encrypted!").dontShowAgainId(remindPasswordAndBackupKey, preferences).show();
}
});
checkIfOpenOffersMatchTradeProtocolVersion();
}
Aggregations