mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Merge remote-tracking branch 'origin/DAO' into disk-protobuffer
Conflicts: common/src/main/java/io/bisq/common/locale/CountryUtil.java common/src/main/java/io/bisq/common/locale/FiatCurrency.java core/src/main/java/io/bisq/core/btc/wallet/TradeWalletService.java core/src/main/java/io/bisq/core/btc/wallet/WalletsSetup.java core/src/main/java/io/bisq/core/payment/AliPayAccount.java core/src/main/java/io/bisq/core/payment/ChaseQuickPayAccount.java core/src/main/java/io/bisq/core/payment/ClearXchangeAccount.java core/src/main/java/io/bisq/core/payment/FasterPaymentsAccount.java core/src/main/java/io/bisq/core/payment/InteracETransferAccount.java core/src/main/java/io/bisq/core/payment/OKPayAccount.java core/src/main/java/io/bisq/core/payment/PerfectMoneyAccount.java core/src/main/java/io/bisq/core/payment/SepaAccount.java core/src/main/java/io/bisq/core/payment/SwishAccount.java core/src/main/java/io/bisq/core/payment/USPostalMoneyOrderAccount.java core/src/main/java/io/bisq/core/trade/protocol/ProcessModel.java core/src/main/java/io/bisq/core/trade/protocol/tasks/taker/TakerCreateTakerFeeTx.java core/src/main/java/io/bisq/core/trade/statistics/TradeStatisticsManager.java core/src/main/java/io/bisq/core/user/BlockChainExplorer.java core/src/main/java/io/bisq/core/user/Preferences.java core/src/main/java/io/bisq/core/user/User.java gui/src/main/java/io/bisq/gui/components/PeerInfoIcon.java gui/src/main/java/io/bisq/gui/components/paymentmethods/CashDepositForm.java gui/src/main/java/io/bisq/gui/components/paymentmethods/OKPayForm.java gui/src/main/java/io/bisq/gui/components/paymentmethods/PaymentMethodForm.java gui/src/main/java/io/bisq/gui/components/paymentmethods/SepaForm.java gui/src/main/java/io/bisq/gui/main/MainViewModel.java gui/src/main/java/io/bisq/gui/main/account/arbitratorregistration/ArbitratorRegistrationView.java gui/src/main/java/io/bisq/gui/main/account/arbitratorregistration/ArbitratorRegistrationViewModel.java gui/src/main/java/io/bisq/gui/main/account/content/password/PasswordView.java gui/src/main/java/io/bisq/gui/main/account/content/seedwords/SeedWordsView.java gui/src/main/java/io/bisq/gui/main/dao/wallet/BalanceUtil.java gui/src/main/java/io/bisq/gui/main/dao/wallet/receive/BsqReceiveView.java gui/src/main/java/io/bisq/gui/main/dao/wallet/send/BsqSendView.java gui/src/main/java/io/bisq/gui/main/market/offerbook/OfferBookChartViewModel.java gui/src/main/java/io/bisq/gui/main/market/trades/TradesChartsViewModel.java gui/src/main/java/io/bisq/gui/main/offer/OfferView.java gui/src/main/java/io/bisq/gui/main/offer/createoffer/CreateOfferDataModel.java gui/src/main/java/io/bisq/gui/main/offer/createoffer/CreateOfferView.java gui/src/main/java/io/bisq/gui/main/offer/createoffer/CreateOfferViewModel.java gui/src/main/java/io/bisq/gui/main/offer/offerbook/OfferBookView.java gui/src/main/java/io/bisq/gui/main/offer/offerbook/OfferBookViewModel.java gui/src/main/java/io/bisq/gui/main/offer/takeoffer/TakeOfferView.java gui/src/main/java/io/bisq/gui/main/offer/takeoffer/TakeOfferViewModel.java gui/src/main/java/io/bisq/gui/main/overlays/Overlay.java gui/src/main/java/io/bisq/gui/main/overlays/editor/PeerInfoWithTagEditor.java gui/src/main/java/io/bisq/gui/main/overlays/notifications/NotificationCenter.java gui/src/main/java/io/bisq/gui/main/overlays/windows/ContractWindow.java gui/src/main/java/io/bisq/gui/main/overlays/windows/OfferDetailsWindow.java gui/src/main/java/io/bisq/gui/main/portfolio/closedtrades/ClosedTradesView.java gui/src/main/java/io/bisq/gui/main/portfolio/openoffer/OpenOffersView.java gui/src/main/java/io/bisq/gui/main/portfolio/pendingtrades/PendingTradesView.java gui/src/main/java/io/bisq/gui/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java gui/src/main/java/io/bisq/gui/main/portfolio/pendingtrades/steps/buyer/BuyerStep4View.java gui/src/main/java/io/bisq/gui/main/portfolio/pendingtrades/steps/seller/SellerStep3View.java gui/src/main/java/io/bisq/gui/main/settings/preferences/PreferencesView.java gui/src/main/java/io/bisq/gui/util/BSFormatter.java gui/src/main/java/io/bisq/gui/util/GUIUtil.java pom.xml statistics/src/main/java/io/bisq/statistics/Statistics.java
This commit is contained in:
parent
3a7d714385
commit
2878db9c0b
18 changed files with 231 additions and 274 deletions
|
@ -22,6 +22,7 @@ import io.bisq.common.Clock;
|
|||
import io.bisq.common.app.AppModule;
|
||||
import io.bisq.common.crypto.KeyRing;
|
||||
import io.bisq.common.crypto.KeyStorage;
|
||||
import io.bisq.common.persistance.ProtobufferResolver;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import io.bisq.core.alert.AlertModule;
|
||||
import io.bisq.core.app.BisqEnvironment;
|
||||
|
@ -36,7 +37,6 @@ import io.bisq.core.user.Preferences;
|
|||
import io.bisq.core.user.User;
|
||||
import io.bisq.network.crypto.EncryptionServiceModule;
|
||||
import io.bisq.network.p2p.P2PModule;
|
||||
import io.bisq.network.p2p.network.ProtobufferResolver;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
|
|
@ -863,8 +863,6 @@ message Preferences {
|
|||
// Persisted fields
|
||||
string user_language = 1;
|
||||
Country user_country = 2;
|
||||
string btc_denomination = 3;
|
||||
bool use_animations = 4;
|
||||
repeated TradeCurrency fiat_currencies = 5;
|
||||
repeated TradeCurrency crypto_currencies = 6;
|
||||
BlockChainExplorer block_chain_explorer_main_net = 7;
|
||||
|
|
34
core/pom.xml
34
core/pom.xml
|
@ -29,7 +29,7 @@
|
|||
<version>5.0.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- We use a local project atm but should be added either as jar or to a https repo.
|
||||
<!-- We use a local project atm but should be added either as jar or to a https repo.
|
||||
Default repo for that project is http only, so it is unsafe to use.-->
|
||||
<dependency>
|
||||
<groupId>com.neemre.btcd-cli4j</groupId>
|
||||
|
@ -49,6 +49,18 @@
|
|||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -60,7 +72,6 @@
|
|||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</exclusion>
|
||||
|
||||
<exclusion>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
|
@ -69,6 +80,18 @@
|
|||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
@ -87,6 +110,13 @@
|
|||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.8.7</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.google.inject.Inject;
|
|||
import com.neemre.btcdcli4j.core.domain.PubKeyScript;
|
||||
import io.bisq.common.UserThread;
|
||||
import io.bisq.common.handlers.ErrorMessageHandler;
|
||||
import io.bisq.common.persistance.ProtobufferResolver;
|
||||
import io.bisq.common.storage.PlainTextWrapper;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import io.bisq.common.util.Utilities;
|
||||
|
@ -50,7 +51,7 @@ public class BsqBlockchainManager {
|
|||
|
||||
//mainnet
|
||||
private static final String GENESIS_TX_ID = "cabbf6073aea8f22ec678e973ac30c6d8fc89321011da6a017f63e67b9f66667";
|
||||
// block 300000 2014-05-10
|
||||
// block 300000 2014-05-10
|
||||
// block 350000 2015-03-30
|
||||
// block 400000 2016-02-25
|
||||
// block 450000 2017-01-25
|
||||
|
@ -58,11 +59,11 @@ public class BsqBlockchainManager {
|
|||
private static final String REG_TEST_GENESIS_TX_ID = "3bc7bc9484e112ec8ddd1a1c984379819245ac463b9ce40fa8b5bf771c0f9236";
|
||||
private static final int REG_TEST_GENESIS_BLOCK_HEIGHT = 102;
|
||||
|
||||
// Modulo of blocks for making snapshots of UTXO.
|
||||
// Modulo of blocks for making snapshots of UTXO.
|
||||
// We stay also the value behind for safety against reorgs.
|
||||
// E.g. for SNAPSHOT_TRIGGER = 30:
|
||||
// If we are block 119 and last snapshot was 60 then we get a new trigger for a snapshot at block 120 and
|
||||
// new snapshot is block 90. We only persist at the new snapshot, so we always re-parse from latest snapshot after
|
||||
// new snapshot is block 90. We only persist at the new snapshot, so we always re-parse from latest snapshot after
|
||||
// a restart.
|
||||
private static final int SNAPSHOT_TRIGGER = 300000;
|
||||
|
||||
|
@ -97,15 +98,16 @@ public class BsqBlockchainManager {
|
|||
BisqEnvironment bisqEnvironment,
|
||||
@Named(Storage.DIR_KEY) File storageDir,
|
||||
Storage<PlainTextWrapper> jsonStorage,
|
||||
@Named(RpcOptionKeys.DUMP_BLOCKCHAIN_DATA) boolean dumpBlockchainData) {
|
||||
@Named(RpcOptionKeys.DUMP_BLOCKCHAIN_DATA) boolean dumpBlockchainData,
|
||||
ProtobufferResolver protobufferResolver) {
|
||||
this.blockchainService = blockchainService;
|
||||
this.storageDir = storageDir;
|
||||
this.jsonStorage = jsonStorage;
|
||||
this.dumpBlockchainData = dumpBlockchainData;
|
||||
this.bitcoinNetwork = bisqEnvironment.getBitcoinNetwork();
|
||||
|
||||
bsqUTXOMap = new BsqUTXOMap(storageDir);
|
||||
bsqTXOMap = new BsqTXOMap(storageDir);
|
||||
bsqUTXOMap = new BsqUTXOMap(storageDir, protobufferResolver);
|
||||
bsqTXOMap = new BsqTXOMap(storageDir, protobufferResolver);
|
||||
|
||||
bsqUTXOMap.addListener(c -> onBsqUTXOChanged());
|
||||
bsqTXOMap.addListener(c -> onBsqTXOChanged());
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package io.bisq.core.dao.blockchain;
|
||||
|
||||
import io.bisq.common.persistance.Persistable;
|
||||
import io.bisq.common.persistance.ProtobufferResolver;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.MapChangeListener;
|
||||
|
@ -33,7 +35,7 @@ import java.util.*;
|
|||
|
||||
// Map of any ever existing TxOutput which was a valid BSQ
|
||||
@Slf4j
|
||||
public class BsqTXOMap implements Serializable {
|
||||
public class BsqTXOMap implements Persistable {
|
||||
// We don't use a Lombok delegate here as we want control the access to our map
|
||||
@Getter
|
||||
private HashMap<TxIdIndexTuple, TxOutput> map = new HashMap<>();
|
||||
|
@ -49,8 +51,8 @@ public class BsqTXOMap implements Serializable {
|
|||
private transient ObservableMap<String, Tx> observableBurnedBSQTxMap;
|
||||
private transient final Storage<BsqTXOMap> storage;
|
||||
|
||||
public BsqTXOMap(File storageDir) {
|
||||
storage = new Storage<>(storageDir);
|
||||
public BsqTXOMap(File storageDir, ProtobufferResolver protobufferResolver) {
|
||||
storage = new Storage<>(storageDir, protobufferResolver);
|
||||
BsqTXOMap persisted = storage.initAndGetPersisted(this, "BsqTXOMap");
|
||||
if (persisted != null) {
|
||||
map.putAll(persisted.getMap());
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package io.bisq.core.dao.blockchain;
|
||||
|
||||
import io.bisq.common.persistance.Persistable;
|
||||
import io.bisq.common.persistance.ProtobufferResolver;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.MapChangeListener;
|
||||
|
@ -32,7 +34,7 @@ import java.io.Serializable;
|
|||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
public class BsqUTXOMap implements Serializable {
|
||||
public class BsqUTXOMap implements Persistable {
|
||||
// We don't use a Lombok delegate here as we want control the access to our map
|
||||
@Getter
|
||||
private HashMap<TxIdIndexTuple, BsqUTXO> map = new HashMap<>();
|
||||
|
@ -45,8 +47,8 @@ public class BsqUTXOMap implements Serializable {
|
|||
private transient ObservableMap<TxIdIndexTuple, BsqUTXO> observableMap;
|
||||
private transient final Storage<BsqUTXOMap> storage;
|
||||
|
||||
public BsqUTXOMap(File storageDir) {
|
||||
storage = new Storage<>(storageDir);
|
||||
public BsqUTXOMap(File storageDir, ProtobufferResolver protobufferResolver) {
|
||||
storage = new Storage<>(storageDir, protobufferResolver);
|
||||
BsqUTXOMap persisted = storage.initAndGetPersisted(this, "BsqUTXOMap");
|
||||
if (persisted != null) {
|
||||
map.putAll(persisted.getMap());
|
||||
|
|
|
@ -911,8 +911,6 @@ public class CoreProtobufferResolver implements ProtobufferResolver {
|
|||
preferences.setUserLanguage(envelope.getPreferences().getUserLanguage());
|
||||
PB.Country userCountry = envelope.getPreferences().getUserCountry();
|
||||
preferences.setUserCountry(new Country(userCountry.getCode(), userCountry.getName(), new Region(userCountry.getRegion().getCode(), userCountry.getRegion().getName())));
|
||||
preferences.setBtcDenomination(envelope.getPreferences().getBtcDenomination());
|
||||
preferences.setUseAnimations(envelope.getPreferences().getUseAnimations());
|
||||
envelope.getPreferences().getFiatCurrenciesList().stream()
|
||||
.forEach(tradeCurrency -> preferences.addFiatCurrency((FiatCurrency) getTradeCurrency(tradeCurrency)));
|
||||
envelope.getPreferences().getCryptoCurrenciesList().stream()
|
||||
|
@ -928,7 +926,6 @@ public class CoreProtobufferResolver implements ProtobufferResolver {
|
|||
preferences.setUseTorForBitcoinJ(envelope.getPreferences().getUseTorForBitcoinJ());
|
||||
preferences.setShowOwnOffersInOfferBook(envelope.getPreferences().getShowOwnOffersInOfferBook());
|
||||
PB.Locale preferredLocale = envelope.getPreferences().getPreferredLocale();
|
||||
preferences.setPreferredLocale(new Locale(preferredLocale.getLanguage(), preferredLocale.getCountry(), preferredLocale.getVariant()));
|
||||
PB.TradeCurrency preferredTradeCurrency = envelope.getPreferences().getPreferredTradeCurrency();
|
||||
preferences.setPreferredTradeCurrency(getTradeCurrency(preferredTradeCurrency));
|
||||
preferences.setWithdrawalTxFeeInBytes(envelope.getPreferences().getWithdrawalTxFeeInBytes());
|
||||
|
|
|
@ -37,7 +37,7 @@ public class TakerPublishTakerFeeTx extends TradeTask {
|
|||
protected void run() {
|
||||
try {
|
||||
runInterceptHook();
|
||||
processModel.getTradeWalletService().broadcastTx(processModel.getTradeWalletService().getWalletTx(Sha256Hash.of(processModel.getTakeOfferFeeTxId())),
|
||||
processModel.getTradeWalletService().broadcastTx(processModel.getTradeWalletService().getWalletTx(processModel.getTakeOfferFeeTx().getHash()),
|
||||
new FutureCallback<Transaction>() {
|
||||
@Override
|
||||
public void onSuccess(Transaction transaction) {
|
||||
|
|
|
@ -20,8 +20,7 @@ package io.bisq.core.user;
|
|||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistance.Persistable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
|
||||
public final class BlockChainExplorer implements Persistable {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
|
|
|
@ -128,8 +128,6 @@ public interface Preferences extends Persistable {
|
|||
|
||||
void setDontShowAgainMap(java.util.Map<String, Boolean> dontShowAgainMap);
|
||||
|
||||
void setPreferredLocale(java.util.Locale preferredLocale);
|
||||
|
||||
void setUseStickyMarketPrice(boolean useStickyMarketPrice);
|
||||
|
||||
void setPeerTagMap(java.util.Map<String, String> peerTagMap);
|
||||
|
@ -190,10 +188,6 @@ public interface Preferences extends Persistable {
|
|||
|
||||
javafx.beans.property.BooleanProperty getUseAnimationsProperty();
|
||||
|
||||
javafx.beans.property.BooleanProperty getUseCustomWithdrawalTxFeeProperty();
|
||||
|
||||
javafx.beans.property.LongProperty getWithdrawalTxFeeInBytesProperty();
|
||||
|
||||
javafx.collections.ObservableList<FiatCurrency> getFiatCurrenciesAsObservable();
|
||||
|
||||
javafx.collections.ObservableList<CryptoCurrency> getCryptoCurrenciesAsObservable();
|
||||
|
@ -202,7 +196,15 @@ public interface Preferences extends Persistable {
|
|||
|
||||
boolean isResyncSPVRequested();
|
||||
|
||||
void setResyncSPVRequested(boolean resyncSPVRequested);
|
||||
|
||||
boolean getPayFeeInBTC();
|
||||
|
||||
BlockChainExplorer getBsqBlockChainExplorer();
|
||||
|
||||
List<String> getBtcDenominations();
|
||||
|
||||
void setUseAnimations(boolean useAnimations);
|
||||
|
||||
void setPayFeeInBTC(boolean payFeeInBTC);
|
||||
}
|
||||
|
|
|
@ -1,23 +1,7 @@
|
|||
/*
|
||||
* This file is part of bisq.
|
||||
*
|
||||
* bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bisq.core.user;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.GlobalSettings;
|
||||
import io.bisq.common.app.DevEnv;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.locale.*;
|
||||
|
@ -28,7 +12,9 @@ import io.bisq.core.btc.BitcoinNetwork;
|
|||
import io.bisq.core.btc.BtcOptionKeys;
|
||||
import io.bisq.core.btc.Restrictions;
|
||||
import io.bisq.core.payment.PaymentAccount;
|
||||
import io.bisq.core.provider.fee.FeeService;
|
||||
import io.bisq.core.user.BlockChainExplorer;
|
||||
import io.bisq.core.user.DontShowAgainLookup;
|
||||
import io.bisq.core.user.Preferences;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import javafx.beans.property.*;
|
||||
import javafx.collections.FXCollections;
|
||||
|
@ -50,25 +36,6 @@ import java.util.stream.Collectors;
|
|||
@Slf4j
|
||||
public final class PreferencesImpl implements Preferences {
|
||||
|
||||
///////////////// START of STATIC ////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
static {
|
||||
Locale locale = Locale.getDefault();
|
||||
PreferencesImpl.defaultLocale = locale;
|
||||
Res.applyLocaleToResourceBundle(getDefaultLocale());
|
||||
|
||||
CountryUtil.setDefaultLocale(locale);
|
||||
CurrencyUtil.setDefaultLocale(locale);
|
||||
LanguageUtil.setDefaultLocale(locale);
|
||||
FiatCurrency.setDefaultLocale(locale);
|
||||
|
||||
FiatCurrency currencyByCountryCode = CurrencyUtil.getCurrencyByCountryCode(CountryUtil.getDefaultCountryCode(locale), locale);
|
||||
PreferencesImpl.defaultTradeCurrency = currencyByCountryCode;
|
||||
CurrencyUtil.setDefaultTradeCurrency(currencyByCountryCode);
|
||||
}
|
||||
|
||||
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
|
@ -76,7 +43,7 @@ public final class PreferencesImpl implements Preferences {
|
|||
@SuppressWarnings("ArraysAsListWithZeroOrOneArgument")
|
||||
private static final List<String> BTC_DENOMINATIONS = Arrays.asList(MonetaryFormat.CODE_BTC/*, MonetaryFormat.CODE_MBTC*/);
|
||||
|
||||
transient static final private ArrayList<BlockChainExplorer> blockChainExplorersTestNet = new ArrayList<>(Arrays.asList(
|
||||
transient static final private ArrayList<BlockChainExplorer> BLOCK_CHAIN_EXPLORERS_TEST_NET = new ArrayList<>(Arrays.asList(
|
||||
new BlockChainExplorer("Blocktrail", "https://www.blocktrail.com/tBTC/tx/", "https://www.blocktrail.com/tBTC/address/"),
|
||||
new BlockChainExplorer("Blockexplorer", "https://blockexplorer.com/testnet/tx/", "https://blockexplorer.com/testnet/address/"),
|
||||
new BlockChainExplorer("Blockr.io", "https://tbtc.blockr.io/tx/info/", "https://tbtc.blockr.io/address/info/"),
|
||||
|
@ -85,7 +52,7 @@ public final class PreferencesImpl implements Preferences {
|
|||
new BlockChainExplorer("SoChain. Wow.", "https://chain.so/tx/BTCTEST/", "https://chain.so/address/BTCTEST/")
|
||||
));
|
||||
|
||||
transient static final private ArrayList<BlockChainExplorer> blockChainExplorersMainNet = new ArrayList<>(Arrays.asList(
|
||||
transient static final private ArrayList<BlockChainExplorer> BLOCK_CHAIN_EXPLORERS_MAIN_NET = new ArrayList<>(Arrays.asList(
|
||||
new BlockChainExplorer("Tradeblock.com", "https://tradeblock.com/bitcoin/tx/", "https://tradeblock.com/bitcoin/address/"),
|
||||
new BlockChainExplorer("Blocktrail", "https://www.blocktrail.com/BTC/tx/", "https://www.blocktrail.com/BTC/address/"),
|
||||
new BlockChainExplorer("Insight", "https://insight.bitpay.com/tx/", "https://insight.bitpay.com/address/"),
|
||||
|
@ -100,46 +67,30 @@ public final class PreferencesImpl implements Preferences {
|
|||
new BlockChainExplorer("Bitaps", "https://bitaps.com/", "https://bitaps.com/")
|
||||
));
|
||||
|
||||
@Getter
|
||||
private static Locale defaultLocale/* = Locale.getDefault()*/;
|
||||
|
||||
@Getter
|
||||
private static TradeCurrency defaultTradeCurrency;
|
||||
private static boolean staticUseAnimations = true;
|
||||
|
||||
transient private final Storage<Preferences> storage;
|
||||
transient private final BisqEnvironment bisqEnvironment;
|
||||
|
||||
public static List<String> getBtcDenominations() {
|
||||
return BTC_DENOMINATIONS;
|
||||
}
|
||||
|
||||
public static boolean useAnimations() {
|
||||
return staticUseAnimations;
|
||||
}
|
||||
|
||||
///////////////// END of STATIC /////////////////////////////////////////////////////////////////
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
transient private BitcoinNetwork bitcoinNetwork;
|
||||
|
||||
// Persisted fields
|
||||
@Getter
|
||||
private String userLanguage = LanguageUtil.getDefaultLanguage(defaultLocale);
|
||||
@Getter
|
||||
private Country userCountry = CountryUtil.getDefaultCountry(defaultLocale);
|
||||
private String btcDenomination = MonetaryFormat.CODE_BTC;
|
||||
private String userLanguage;
|
||||
@Getter
|
||||
private Country userCountry;
|
||||
private String btcDenomination;
|
||||
private boolean useAnimations = DevEnv.STRESS_TEST_MODE ? false : true;
|
||||
@Getter
|
||||
private final List<FiatCurrency> fiatCurrencies;
|
||||
private final ArrayList<FiatCurrency> fiatCurrencies = new ArrayList<>();
|
||||
@Getter
|
||||
private final List<CryptoCurrency> cryptoCurrencies;
|
||||
private final ArrayList<CryptoCurrency> cryptoCurrencies = new ArrayList<>();
|
||||
@Getter
|
||||
private BlockChainExplorer blockChainExplorerMainNet;
|
||||
@Getter
|
||||
private BlockChainExplorer blockChainExplorerTestNet;
|
||||
@Nullable
|
||||
@Getter
|
||||
private BlockChainExplorer bsqBlockChainExplorer = new BlockChainExplorer("bisq", "https://explorer.bisq.io/tx.html?tx=",
|
||||
"https://explorer.bisq.io/Address.html?addr=");
|
||||
@Getter
|
||||
private String backupDirectory;
|
||||
@Getter
|
||||
|
@ -153,29 +104,24 @@ public final class PreferencesImpl implements Preferences {
|
|||
|
||||
@Getter
|
||||
private boolean showOwnOffersInOfferBook = true;
|
||||
@Setter
|
||||
private Locale preferredLocale;
|
||||
@Getter
|
||||
private TradeCurrency preferredTradeCurrency;
|
||||
@Getter
|
||||
private long withdrawalTxFeeInBytes = 100;
|
||||
@Getter
|
||||
private boolean useCustomWithdrawalTxFee = false;
|
||||
|
||||
@Getter
|
||||
private double maxPriceDistanceInPercent;
|
||||
private double maxPriceDistanceInPercent = 0.1;
|
||||
@Getter
|
||||
private String offerBookChartScreenCurrencyCode = getDefaultTradeCurrency().getCode();
|
||||
private String offerBookChartScreenCurrencyCode;
|
||||
@Getter
|
||||
private String tradeChartsScreenCurrencyCode = getDefaultTradeCurrency().getCode();
|
||||
private String tradeChartsScreenCurrencyCode;
|
||||
|
||||
@Getter
|
||||
private String buyScreenCurrencyCode = getDefaultTradeCurrency().getCode();
|
||||
private String buyScreenCurrencyCode;
|
||||
@Getter
|
||||
private String sellScreenCurrencyCode = getDefaultTradeCurrency().getCode();
|
||||
private String sellScreenCurrencyCode;
|
||||
@Getter
|
||||
private int tradeStatisticsTickUnitIndex = 3;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean useStickyMarketPrice = false;
|
||||
|
@ -193,26 +139,25 @@ public final class PreferencesImpl implements Preferences {
|
|||
private List<String> ignoreTradersList = new ArrayList<>();
|
||||
@Getter
|
||||
private String directoryChooserPath;
|
||||
@Getter
|
||||
private long buyerSecurityDepositAsLong = Restrictions.DEFAULT_BUYER_SECURITY_DEPOSIT.value;
|
||||
@Nullable
|
||||
@Getter
|
||||
private PaymentAccount selectedPaymentAccountForCreateOffer;
|
||||
private boolean payFeeInBTC = true;
|
||||
@Getter
|
||||
private boolean resyncSPVRequested;
|
||||
|
||||
// Observable wrappers
|
||||
@Getter
|
||||
transient private final StringProperty btcDenominationProperty = new SimpleStringProperty(btcDenomination);
|
||||
transient private final StringProperty btcDenominationProperty = new SimpleStringProperty();
|
||||
@Getter
|
||||
transient private final BooleanProperty useAnimationsProperty = new SimpleBooleanProperty(useAnimations);
|
||||
transient private final BooleanProperty useAnimationsProperty = new SimpleBooleanProperty();
|
||||
@Getter
|
||||
transient private final BooleanProperty useCustomWithdrawalTxFeeProperty = new SimpleBooleanProperty(useCustomWithdrawalTxFee);
|
||||
@Getter
|
||||
transient private final LongProperty withdrawalTxFeeInBytesProperty = new SimpleLongProperty(withdrawalTxFeeInBytes);
|
||||
@Getter
|
||||
|
||||
transient private final ObservableList<FiatCurrency> fiatCurrenciesAsObservable = FXCollections.observableArrayList();
|
||||
@Getter
|
||||
transient private final ObservableList<CryptoCurrency> cryptoCurrenciesAsObservable = FXCollections.observableArrayList();
|
||||
@Getter
|
||||
transient private final ObservableList<TradeCurrency> tradeCurrenciesAsObservable = FXCollections.observableArrayList();
|
||||
|
||||
|
||||
|
@ -220,41 +165,29 @@ public final class PreferencesImpl implements Preferences {
|
|||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
@Inject
|
||||
public PreferencesImpl(Storage<Preferences> storage, BisqEnvironment bisqEnvironment,
|
||||
FeeService feeService,
|
||||
@Named(BtcOptionKeys.BTC_NODES) String btcNodesFromOptions,
|
||||
@Named(BtcOptionKeys.USE_TOR_FOR_BTC) String useTorFlagFromOptions) {
|
||||
public PreferencesImpl(Storage<Preferences> storage,
|
||||
BisqEnvironment bisqEnvironment,
|
||||
@Named(BtcOptionKeys.BTC_NODES) String btcNodesFromOptions,
|
||||
@Named(BtcOptionKeys.USE_TOR_FOR_BTC) String useTorFlagFromOptions) {
|
||||
|
||||
this.storage = storage;
|
||||
this.bisqEnvironment = bisqEnvironment;
|
||||
bitcoinNetwork = bisqEnvironment.getBitcoinNetwork();
|
||||
|
||||
// setup
|
||||
/*
|
||||
Res.applyLocaleToResourceBundle(defaultLocale);
|
||||
CountryUtil.setDefaultLocale(defaultLocale);
|
||||
CurrencyUtil.setDefaultLocale(defaultLocale);
|
||||
LanguageUtil.setDefaultLocale(defaultLocale);
|
||||
FiatCurrency.setDefaultLocale(defaultLocale);
|
||||
|
||||
FiatCurrency currencyByCountryCode = CurrencyUtil.getCurrencyByCountryCode(CountryUtil.getDefaultCountryCode(defaultLocale), defaultLocale);
|
||||
defaultTradeCurrency = currencyByCountryCode;
|
||||
CurrencyUtil.setDefaultTradeCurrency(currencyByCountryCode);
|
||||
*/
|
||||
// end setup
|
||||
|
||||
directoryChooserPath = Utilities.getSystemHomeDirectory();
|
||||
|
||||
fiatCurrencies = new ArrayList<>(fiatCurrenciesAsObservable);
|
||||
cryptoCurrencies = new ArrayList<>(cryptoCurrenciesAsObservable);
|
||||
// We don't want to pass Preferences to all popups where the dont show again checkbox is used, so we use
|
||||
// that static lookup class to avoid static access to the Preferences directly.
|
||||
DontShowAgainLookup.setPreferences(this);
|
||||
|
||||
btcDenominationProperty.addListener((ov) -> {
|
||||
btcDenomination = btcDenominationProperty.get();
|
||||
GlobalSettings.setBtcDenomination(btcDenomination);
|
||||
storage.queueUpForSave();
|
||||
});
|
||||
useAnimationsProperty.addListener((ov) -> {
|
||||
useAnimations = useAnimationsProperty.get();
|
||||
staticUseAnimations = useAnimations;
|
||||
GlobalSettings.setUseAnimations(useAnimations);
|
||||
storage.queueUpForSave();
|
||||
});
|
||||
fiatCurrenciesAsObservable.addListener((javafx.beans.Observable ov) -> {
|
||||
|
@ -280,8 +213,16 @@ public final class PreferencesImpl implements Preferences {
|
|||
storage.queueUpForSave();
|
||||
});
|
||||
|
||||
TradeCurrency defaultTradeCurrency;
|
||||
Preferences persisted = storage.initAndGetPersisted(this);
|
||||
if (persisted != null) {
|
||||
userLanguage = persisted.getUserLanguage();
|
||||
userCountry = persisted.getUserCountry();
|
||||
GlobalSettings.setLocale(new Locale(userLanguage, userCountry.code));
|
||||
GlobalSettings.setUseAnimations(persisted.getUseAnimations());
|
||||
preferredTradeCurrency = persisted.getPreferredTradeCurrency();
|
||||
defaultTradeCurrency = preferredTradeCurrency;
|
||||
|
||||
setBtcDenomination(persisted.getBtcDenomination());
|
||||
setUseAnimations(persisted.getUseAnimations());
|
||||
|
||||
|
@ -290,80 +231,59 @@ public final class PreferencesImpl implements Preferences {
|
|||
|
||||
setBlockChainExplorerTestNet(persisted.getBlockChainExplorerTestNet());
|
||||
setBlockChainExplorerMainNet(persisted.getBlockChainExplorerMainNet());
|
||||
setBsqBlockChainExplorer(persisted.getBsqBlockChainExplorer());
|
||||
|
||||
setUseCustomWithdrawalTxFee(persisted.getUseCustomWithdrawalTxFee());
|
||||
setWithdrawalTxFeeInBytes(persisted.getWithdrawalTxFeeInBytes());
|
||||
|
||||
// In case of an older version without that data we set it to defaults
|
||||
if (blockChainExplorerTestNet == null)
|
||||
setBlockChainExplorerTestNet(blockChainExplorersTestNet.get(0));
|
||||
if (blockChainExplorerMainNet == null)
|
||||
setBlockChainExplorerTestNet(blockChainExplorersMainNet.get(0));
|
||||
|
||||
backupDirectory = persisted.getBackupDirectory();
|
||||
autoSelectArbitrators = persisted.isAutoSelectArbitrators();
|
||||
dontShowAgainMap = persisted.getDontShowAgainMap();
|
||||
tacAccepted = persisted.isTacAccepted();
|
||||
|
||||
userLanguage = persisted.getUserLanguage();
|
||||
if (userLanguage == null)
|
||||
userLanguage = LanguageUtil.getDefaultLanguage(defaultLocale);
|
||||
userCountry = persisted.getUserCountry();
|
||||
if (userCountry == null)
|
||||
userCountry = CountryUtil.getDefaultCountry(defaultLocale);
|
||||
updateDefaultLocale();
|
||||
preferredTradeCurrency = persisted.getPreferredTradeCurrency();
|
||||
defaultTradeCurrency = preferredTradeCurrency;
|
||||
useTorForBitcoinJ = persisted.getUseTorForBitcoinJ();
|
||||
|
||||
useStickyMarketPrice = persisted.isUseStickyMarketPrice();
|
||||
sortMarketCurrenciesNumerically = persisted.isSortMarketCurrenciesNumerically();
|
||||
|
||||
usePercentageBasedPrice = persisted.isUsePercentageBasedPrice();
|
||||
showOwnOffersInOfferBook = persisted.isShowOwnOffersInOfferBook();
|
||||
maxPriceDistanceInPercent = persisted.getMaxPriceDistanceInPercent();
|
||||
|
||||
bitcoinNodes = persisted.getBitcoinNodes();
|
||||
if (bitcoinNodes == null)
|
||||
bitcoinNodes = "";
|
||||
|
||||
if (persisted.getPeerTagMap() != null)
|
||||
peerTagMap = persisted.getPeerTagMap();
|
||||
|
||||
peerTagMap = persisted.getPeerTagMap();
|
||||
offerBookChartScreenCurrencyCode = persisted.getOfferBookChartScreenCurrencyCode();
|
||||
buyScreenCurrencyCode = persisted.getBuyScreenCurrencyCode();
|
||||
sellScreenCurrencyCode = persisted.getSellScreenCurrencyCode();
|
||||
tradeChartsScreenCurrencyCode = persisted.getTradeChartsScreenCurrencyCode();
|
||||
tradeStatisticsTickUnitIndex = persisted.getTradeStatisticsTickUnitIndex();
|
||||
|
||||
if (persisted.getIgnoreTradersList() != null)
|
||||
ignoreTradersList = persisted.getIgnoreTradersList();
|
||||
|
||||
if (persisted.getDirectoryChooserPath() != null)
|
||||
directoryChooserPath = persisted.getDirectoryChooserPath();
|
||||
|
||||
buyerSecurityDepositAsLong = Math.min(Restrictions.MAX_BUYER_SECURITY_DEPOSIT.value,
|
||||
Math.max(Restrictions.MIN_BUYER_SECURITY_DEPOSIT.value,
|
||||
persisted.getBuyerSecurityDepositAsLong())
|
||||
);
|
||||
|
||||
ignoreTradersList = persisted.getIgnoreTradersList();
|
||||
directoryChooserPath = persisted.getDirectoryChooserPath();
|
||||
selectedPaymentAccountForCreateOffer = persisted.getSelectedPaymentAccountForCreateOffer();
|
||||
payFeeInBTC = persisted.getPayFeeInBTC();
|
||||
setBuyerSecurityDepositAsLong(persisted.getBuyerSecurityDepositAsLong());
|
||||
resyncSPVRequested = persisted.isResyncSPVRequested();
|
||||
} else {
|
||||
setFiatCurrencies(CurrencyUtil.getAllMainFiatCurrencies(defaultLocale, getDefaultTradeCurrency()));
|
||||
userLanguage = GlobalSettings.getLocale().getLanguage();
|
||||
userCountry = CountryUtil.getDefaultCountry();
|
||||
GlobalSettings.setLocale(new Locale(userLanguage, userCountry.code));
|
||||
defaultTradeCurrency = CurrencyUtil.getCurrencyByCountryCode(userCountry.code);
|
||||
preferredTradeCurrency = defaultTradeCurrency;
|
||||
|
||||
setFiatCurrencies(CurrencyUtil.getMainFiatCurrencies());
|
||||
setCryptoCurrencies(CurrencyUtil.getMainCryptoCurrencies());
|
||||
|
||||
setBlockChainExplorerTestNet(blockChainExplorersTestNet.get(0));
|
||||
setBlockChainExplorerMainNet(blockChainExplorersMainNet.get(0));
|
||||
|
||||
setBlockChainExplorerTestNet(BLOCK_CHAIN_EXPLORERS_TEST_NET.get(0));
|
||||
setBlockChainExplorerMainNet(BLOCK_CHAIN_EXPLORERS_MAIN_NET.get(0));
|
||||
directoryChooserPath = Utilities.getSystemHomeDirectory();
|
||||
dontShowAgainMap = new HashMap<>();
|
||||
preferredLocale = defaultLocale;
|
||||
preferredTradeCurrency = getDefaultTradeCurrency();
|
||||
maxPriceDistanceInPercent = 0.1;
|
||||
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
GlobalSettings.setDefaultTradeCurrency(defaultTradeCurrency);
|
||||
offerBookChartScreenCurrencyCode = defaultTradeCurrency.getCode();
|
||||
tradeChartsScreenCurrencyCode = defaultTradeCurrency.getCode();
|
||||
buyScreenCurrencyCode = defaultTradeCurrency.getCode();
|
||||
sellScreenCurrencyCode = defaultTradeCurrency.getCode();
|
||||
btcDenomination = MonetaryFormat.CODE_BTC;
|
||||
|
||||
this.bitcoinNetwork = bisqEnvironment.getBitcoinNetwork();
|
||||
btcDenominationProperty.set(btcDenomination);
|
||||
useAnimationsProperty.set(useAnimations);
|
||||
|
||||
fiatCurrenciesAsObservable.addListener(this::updateTradeCurrencies);
|
||||
cryptoCurrenciesAsObservable.addListener(this::updateTradeCurrencies);
|
||||
|
@ -382,13 +302,11 @@ public final class PreferencesImpl implements Preferences {
|
|||
setBitcoinNodes(btcNodesFromOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dontShowAgain(String key, boolean dontShowAgain) {
|
||||
dontShowAgainMap.put(key, dontShowAgain);
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetDontShowAgain() {
|
||||
dontShowAgainMap.clear();
|
||||
storage.queueUpForSave();
|
||||
|
@ -399,33 +317,19 @@ public final class PreferencesImpl implements Preferences {
|
|||
// Setter
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void setBtcDenomination(String btcDenomination) {
|
||||
this.btcDenominationProperty.set(btcDenomination);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseAnimations(boolean useAnimations) {
|
||||
this.useAnimationsProperty.set(useAnimations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBitcoinNetwork(BitcoinNetwork bitcoinNetwork) {
|
||||
if (this.bitcoinNetwork != bitcoinNetwork)
|
||||
bisqEnvironment.saveBitcoinNetwork(bitcoinNetwork);
|
||||
|
||||
this.bitcoinNetwork = bitcoinNetwork;
|
||||
|
||||
// We don't store the bitcoinNetwork locally as BitcoinNetwork is not serializable!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFiatCurrency(FiatCurrency tradeCurrency) {
|
||||
if (!fiatCurrenciesAsObservable.contains(tradeCurrency))
|
||||
fiatCurrenciesAsObservable.add(tradeCurrency);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFiatCurrency(FiatCurrency tradeCurrency) {
|
||||
if (tradeCurrenciesAsObservable.size() > 1) {
|
||||
if (fiatCurrenciesAsObservable.contains(tradeCurrency))
|
||||
|
@ -438,13 +342,11 @@ public final class PreferencesImpl implements Preferences {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCryptoCurrency(CryptoCurrency tradeCurrency) {
|
||||
if (!cryptoCurrenciesAsObservable.contains(tradeCurrency))
|
||||
cryptoCurrenciesAsObservable.add(tradeCurrency);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCryptoCurrency(CryptoCurrency tradeCurrency) {
|
||||
if (tradeCurrenciesAsObservable.size() > 1) {
|
||||
if (cryptoCurrenciesAsObservable.contains(tradeCurrency))
|
||||
|
@ -457,7 +359,6 @@ public final class PreferencesImpl implements Preferences {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockChainExplorer(BlockChainExplorer blockChainExplorer) {
|
||||
if (bitcoinNetwork == BitcoinNetwork.MAINNET)
|
||||
setBlockChainExplorerMainNet(blockChainExplorer);
|
||||
|
@ -465,180 +366,198 @@ public final class PreferencesImpl implements Preferences {
|
|||
setBlockChainExplorerTestNet(blockChainExplorer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTacAccepted(boolean tacAccepted) {
|
||||
this.tacAccepted = tacAccepted;
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserLanguage(@NotNull String userLanguageCode) {
|
||||
this.userLanguage = userLanguageCode;
|
||||
updateDefaultLocale();
|
||||
GlobalSettings.setLocale(new Locale(userLanguage, userCountry.code));
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserCountry(@NotNull Country userCountry) {
|
||||
this.userCountry = userCountry;
|
||||
updateDefaultLocale();
|
||||
GlobalSettings.setLocale(new Locale(userLanguage, userCountry.code));
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPreferredTradeCurrency(TradeCurrency preferredTradeCurrency) {
|
||||
if (preferredTradeCurrency != null) {
|
||||
this.preferredTradeCurrency = preferredTradeCurrency;
|
||||
defaultTradeCurrency = preferredTradeCurrency;
|
||||
GlobalSettings.setDefaultTradeCurrency(preferredTradeCurrency);
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseTorForBitcoinJ(boolean useTorForBitcoinJ) {
|
||||
this.useTorForBitcoinJ = useTorForBitcoinJ;
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShowOwnOffersInOfferBook(boolean showOwnOffersInOfferBook) {
|
||||
this.showOwnOffersInOfferBook = showOwnOffersInOfferBook;
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxPriceDistanceInPercent(double maxPriceDistanceInPercent) {
|
||||
this.maxPriceDistanceInPercent = maxPriceDistanceInPercent;
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackupDirectory(String backupDirectory) {
|
||||
this.backupDirectory = backupDirectory;
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoSelectArbitrators(boolean autoSelectArbitrators) {
|
||||
this.autoSelectArbitrators = autoSelectArbitrators;
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUsePercentageBasedPrice(boolean usePercentageBasedPrice) {
|
||||
this.usePercentageBasedPrice = usePercentageBasedPrice;
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTagForPeer(String hostName, String tag) {
|
||||
peerTagMap.put(hostName, tag);
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOfferBookChartScreenCurrencyCode(String offerBookChartScreenCurrencyCode) {
|
||||
this.offerBookChartScreenCurrencyCode = offerBookChartScreenCurrencyCode;
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuyScreenCurrencyCode(String buyScreenCurrencyCode) {
|
||||
this.buyScreenCurrencyCode = buyScreenCurrencyCode;
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSellScreenCurrencyCode(String sellScreenCurrencyCode) {
|
||||
this.sellScreenCurrencyCode = sellScreenCurrencyCode;
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIgnoreTradersList(List<String> ignoreTradersList) {
|
||||
this.ignoreTradersList = ignoreTradersList;
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirectoryChooserPath(String directoryChooserPath) {
|
||||
this.directoryChooserPath = directoryChooserPath;
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTradeChartsScreenCurrencyCode(String tradeChartsScreenCurrencyCode) {
|
||||
this.tradeChartsScreenCurrencyCode = tradeChartsScreenCurrencyCode;
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTradeStatisticsTickUnitIndex(int tradeStatisticsTickUnitIndex) {
|
||||
this.tradeStatisticsTickUnitIndex = tradeStatisticsTickUnitIndex;
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSortMarketCurrenciesNumerically(boolean sortMarketCurrenciesNumerically) {
|
||||
this.sortMarketCurrenciesNumerically = sortMarketCurrenciesNumerically;
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBitcoinNodes(String bitcoinNodes) {
|
||||
this.bitcoinNodes = bitcoinNodes;
|
||||
storage.queueUpForSave(50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseCustomWithdrawalTxFee(boolean useCustomWithdrawalTxFee) {
|
||||
useCustomWithdrawalTxFeeProperty.set(useCustomWithdrawalTxFee);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWithdrawalTxFeeInBytes(long withdrawalTxFeeInBytes) {
|
||||
withdrawalTxFeeInBytesProperty.set(withdrawalTxFeeInBytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuyerSecurityDepositAsLong(long buyerSecurityDepositAsLong) {
|
||||
this.buyerSecurityDepositAsLong = buyerSecurityDepositAsLong;
|
||||
this.buyerSecurityDepositAsLong = Math.min(Restrictions.MAX_BUYER_SECURITY_DEPOSIT.value,
|
||||
Math.max(Restrictions.MIN_BUYER_SECURITY_DEPOSIT.value,
|
||||
buyerSecurityDepositAsLong));
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelectedPaymentAccountForCreateOffer(PaymentAccount paymentAccount) {
|
||||
public void setSelectedPaymentAccountForCreateOffer(@Nullable PaymentAccount paymentAccount) {
|
||||
this.selectedPaymentAccountForCreateOffer = paymentAccount;
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBsqBlockChainExplorer(BlockChainExplorer bsqBlockChainExplorer) {
|
||||
this.bsqBlockChainExplorer = bsqBlockChainExplorer;
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
public void setPayFeeInBTC(boolean payFeeInBTC) {
|
||||
this.payFeeInBTC = payFeeInBTC;
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
private void setFiatCurrencies(List<FiatCurrency> currencies) {
|
||||
fiatCurrenciesAsObservable.setAll(currencies);
|
||||
}
|
||||
|
||||
private void setCryptoCurrencies(List<CryptoCurrency> currencies) {
|
||||
cryptoCurrenciesAsObservable.setAll(currencies);
|
||||
}
|
||||
|
||||
public void setBlockChainExplorerTestNet(BlockChainExplorer blockChainExplorerTestNet) {
|
||||
this.blockChainExplorerTestNet = blockChainExplorerTestNet;
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockChainExplorerMainNet(BlockChainExplorer blockChainExplorerMainNet) {
|
||||
this.blockChainExplorerMainNet = blockChainExplorerMainNet;
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
public void setResyncSPVRequested(boolean resyncSPVRequested) {
|
||||
this.resyncSPVRequested = resyncSPVRequested;
|
||||
// We call that before shutdown so we dont want a delay here
|
||||
storage.queueUpForSave(1);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getter
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getBtcDenomination() {
|
||||
return btcDenominationProperty.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringProperty btcDenominationProperty() {
|
||||
return btcDenominationProperty;
|
||||
}
|
||||
|
||||
public boolean getUseAnimations() {
|
||||
return useAnimationsProperty.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanProperty useAnimationsProperty() {
|
||||
return useAnimationsProperty;
|
||||
}
|
||||
|
||||
public ObservableList<FiatCurrency> getFiatCurrenciesAsObservable() {
|
||||
return fiatCurrenciesAsObservable;
|
||||
}
|
||||
|
||||
public ObservableList<CryptoCurrency> getCryptoCurrenciesAsObservable() {
|
||||
return cryptoCurrenciesAsObservable;
|
||||
}
|
||||
|
||||
public ObservableList<TradeCurrency> getTradeCurrenciesAsObservable() {
|
||||
return tradeCurrenciesAsObservable;
|
||||
}
|
||||
|
||||
public BlockChainExplorer getBlockChainExplorer() {
|
||||
if (bitcoinNetwork == BitcoinNetwork.MAINNET)
|
||||
return blockChainExplorerMainNet;
|
||||
|
@ -646,45 +565,65 @@ public final class PreferencesImpl implements Preferences {
|
|||
return blockChainExplorerTestNet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<BlockChainExplorer> getBlockChainExplorers() {
|
||||
if (bitcoinNetwork == BitcoinNetwork.MAINNET)
|
||||
return blockChainExplorersMainNet;
|
||||
return BLOCK_CHAIN_EXPLORERS_MAIN_NET;
|
||||
else
|
||||
return blockChainExplorersTestNet;
|
||||
return BLOCK_CHAIN_EXPLORERS_TEST_NET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showAgain(String key) {
|
||||
return !dontShowAgainMap.containsKey(key) || !dontShowAgainMap.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUseTorForBitcoinJ() {
|
||||
// We override the useTorForBitcoinJ and set to false if we have bitcoinNodes set
|
||||
// Atm we don't support onion addresses there
|
||||
// This check includes localhost, so we also override useTorForBitcoinJ
|
||||
if (bitcoinNodes != null && !bitcoinNodes.isEmpty())
|
||||
if (bitcoinNodes != null && !bitcoinNodes.isEmpty() || bitcoinNetwork == BitcoinNetwork.REGTEST)
|
||||
return false;
|
||||
else
|
||||
return useTorForBitcoinJ;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public boolean getUseCustomWithdrawalTxFee() {
|
||||
return useCustomWithdrawalTxFeeProperty.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanProperty useCustomWithdrawalTxFeeProperty() {
|
||||
return useCustomWithdrawalTxFeeProperty;
|
||||
}
|
||||
|
||||
public LongProperty withdrawalTxFeeInBytesProperty() {
|
||||
return withdrawalTxFeeInBytesProperty;
|
||||
}
|
||||
|
||||
public long getWithdrawalTxFeeInBytes() {
|
||||
return withdrawalTxFeeInBytesProperty.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBuyerSecurityDepositAsLong() {
|
||||
return buyerSecurityDepositAsLong;
|
||||
}
|
||||
|
||||
public Coin getBuyerSecurityDepositAsCoin() {
|
||||
return Coin.valueOf(buyerSecurityDepositAsLong);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PaymentAccount getSelectedPaymentAccountForCreateOffer() {
|
||||
return selectedPaymentAccountForCreateOffer;
|
||||
}
|
||||
|
||||
public boolean getPayFeeInBTC() {
|
||||
return payFeeInBTC;
|
||||
}
|
||||
|
||||
public List<String> getBtcDenominations() {
|
||||
return BTC_DENOMINATIONS;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Private
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -697,27 +636,15 @@ public final class PreferencesImpl implements Preferences {
|
|||
tradeCurrenciesAsObservable.remove(change.getRemoved().get(0));
|
||||
}
|
||||
|
||||
private void setFiatCurrencies(List<FiatCurrency> currencies) {
|
||||
fiatCurrenciesAsObservable.setAll(currencies);
|
||||
}
|
||||
|
||||
private void setCryptoCurrencies(List<CryptoCurrency> currencies) {
|
||||
cryptoCurrenciesAsObservable.setAll(currencies);
|
||||
}
|
||||
|
||||
|
||||
private void updateDefaultLocale() {
|
||||
defaultLocale = new Locale(userLanguage, userCountry.code);
|
||||
Res.applyLocaleToResourceBundle(defaultLocale);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Message toProtobuf() {
|
||||
PB.Preferences.Builder builder = PB.Preferences.newBuilder()
|
||||
.setUserLanguage(userLanguage)
|
||||
.setUserCountry((PB.Country) userCountry.toProtobuf())
|
||||
.setBtcDenomination(btcDenomination)
|
||||
.setUseAnimations(useAnimations)
|
||||
.addAllFiatCurrencies(fiatCurrencies.stream().map(fiatCurrency -> ((PB.TradeCurrency) fiatCurrency.toProtobuf())).collect(Collectors.toList()))
|
||||
.addAllCryptoCurrencies(cryptoCurrencies.stream().map(cryptoCurrency -> ((PB.TradeCurrency) cryptoCurrency.toProtobuf())).collect(Collectors.toList()))
|
||||
.setBlockChainExplorerMainNet((PB.BlockChainExplorer) blockChainExplorerMainNet.toProtobuf())
|
||||
|
@ -741,7 +668,7 @@ public final class PreferencesImpl implements Preferences {
|
|||
.setDirectoryChooserPath(directoryChooserPath)
|
||||
.setBuyerSecurityDepositAsLong(buyerSecurityDepositAsLong);
|
||||
Optional.ofNullable(backupDirectory).ifPresent(backupDir -> builder.setBackupDirectory(backupDir));
|
||||
Optional.ofNullable(preferredLocale).ifPresent(locale -> builder.setPreferredLocale(PB.Locale.newBuilder().setCountry(preferredLocale.getCountry()).setLanguage(preferredLocale.getLanguage()).setVariant(preferredLocale.getVariant())));
|
||||
//Optional.ofNullable(preferredLocale).ifPresent(locale -> builder.setPreferredLocale(PB.Locale.newBuilder().setCountry(preferredLocale.getCountry()).setLanguage(preferredLocale.getLanguage()).setVariant(preferredLocale.getVariant())));
|
||||
|
||||
return PB.DiskEnvelope.newBuilder().setPreferences(builder).build();
|
||||
}
|
||||
|
|
|
@ -72,8 +72,8 @@ public class BsqBlockchainServiceTest {
|
|||
final URL resource = this.getClass().getClassLoader().getResource("");
|
||||
final String path = resource != null ? resource.getFile() : "";
|
||||
log.info("path for BsqUTXOMap=" + path);
|
||||
bsqUTXOMap = new BsqUTXOMap(new File(path));
|
||||
bsqTXOMap = new BsqTXOMap(new File(path));
|
||||
bsqUTXOMap = new BsqUTXOMap(new File(path), null);
|
||||
bsqTXOMap = new BsqTXOMap(new File(path), null);
|
||||
service = new MockBsqBlockchainService();
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ public class BsqBlockchainServiceTest {
|
|||
// Output 0: ADDRESS_GEN_1 ADDRESS_GEN_1_VALUE
|
||||
// Output 1: ADDRESS_GEN_2 ADDRESS_GEN_2_VALUE
|
||||
|
||||
// UTXO:
|
||||
// UTXO:
|
||||
// GENESIS_TX_ID:0
|
||||
// GENESIS_TX_ID:1
|
||||
|
||||
|
@ -119,7 +119,7 @@ public class BsqBlockchainServiceTest {
|
|||
// Input 0: Output 1 from GENESIS_TX
|
||||
// Output 0: ADDRESS_TX_1 ADDRESS_TX_1_VALUE (=ADDRESS_GEN_2_VALUE)
|
||||
|
||||
// UTXO:
|
||||
// UTXO:
|
||||
// GENESIS_TX_ID:0
|
||||
// TX1_ID:0
|
||||
|
||||
|
@ -161,7 +161,7 @@ public class BsqBlockchainServiceTest {
|
|||
// Input 0: Output 0 from TX1
|
||||
// Output 0: ADDRESS_TX_2 ADDRESS_TX_2_VALUE (=ADDRESS_TX_1_VALUE)
|
||||
|
||||
// UTXO:
|
||||
// UTXO:
|
||||
// GENESIS_TX_ID:0
|
||||
// TX2_ID:0
|
||||
|
||||
|
@ -213,7 +213,7 @@ public class BsqBlockchainServiceTest {
|
|||
// Input 0: Output 0 from TX1
|
||||
// Output 0: ADDRESS_TX_2 ADDRESS_TX_2_VALUE (=ADDRESS_TX_1_VALUE)
|
||||
|
||||
// UTXO:
|
||||
// UTXO:
|
||||
// GENESIS_TX_ID:0
|
||||
// TX2_ID:0
|
||||
|
||||
|
@ -264,9 +264,9 @@ public class BsqBlockchainServiceTest {
|
|||
// TX2 (block 1):
|
||||
// Input 0: Output 0 from TX1
|
||||
// Input 1: Output 0 from GENESIS_TX
|
||||
// Output 0: ADDRESS_TX_2 ADDRESS_TX_1_VALUE + ADDRESS_GEN_1_VALUE
|
||||
// Output 0: ADDRESS_TX_2 ADDRESS_TX_1_VALUE + ADDRESS_GEN_1_VALUE
|
||||
|
||||
// UTXO:
|
||||
// UTXO:
|
||||
// TX2_ID:0
|
||||
|
||||
buildGenesisBlock();
|
||||
|
|
|
@ -21,8 +21,6 @@ import ch.qos.logback.classic.Level;
|
|||
import ch.qos.logback.classic.Logger;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.grapher.graphviz.GraphvizGrapher;
|
||||
import com.google.inject.grapher.graphviz.GraphvizModule;
|
||||
import io.bisq.common.CommonOptionKeys;
|
||||
import io.bisq.common.UserThread;
|
||||
import io.bisq.common.app.DevEnv;
|
||||
|
|
|
@ -148,7 +148,7 @@ public class BsqTxView extends ActivatableView<GridPane, Void> {
|
|||
.map(t -> t.getHashAsString()).collect(Collectors.toSet());
|
||||
String key = "invalidBsqTransactionsWarning_" + txIds;
|
||||
if (DontShowAgainLookup.showAgain(key))
|
||||
new Popup().warning("We detected invalid Bsq transactions.\n" +
|
||||
new Popup(preferences).warning("We detected invalid Bsq transactions.\n" +
|
||||
"This must not happen if you used the bisq application only to send or receive BSQ.\n\n" +
|
||||
"invalidBsqTransactionIds=" + txIds.toString())
|
||||
.width(800)
|
||||
|
@ -334,12 +334,12 @@ public class BsqTxView extends ActivatableView<GridPane, Void> {
|
|||
|
||||
private void openTxInBlockExplorer(BsqTxListItem item) {
|
||||
if (item.getTxId() != null)
|
||||
GUIUtil.openWebPage(preferences.getBsqBlockChainExplorer().txUrl + item.getTxId());
|
||||
GUIUtil.openWebPage(preferences.getBsqBlockChainExplorer().txUrl + item.getTxId(), preferences);
|
||||
}
|
||||
|
||||
private void openAddressInBlockExplorer(BsqTxListItem item) {
|
||||
if (item.getAddress() != null) {
|
||||
GUIUtil.openWebPage(preferences.getBsqBlockChainExplorer().addressUrl + item.getAddress());
|
||||
GUIUtil.openWebPage(preferences.getBsqBlockChainExplorer().addressUrl + item.getAddress(), preferences);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
|||
if (tradeCurrencyOptional.isPresent())
|
||||
tradeCurrency = tradeCurrencyOptional.get();
|
||||
else {
|
||||
tradeCurrency = PreferencesImpl.getDefaultTradeCurrency();
|
||||
tradeCurrency = GlobalSettings.getDefaultTradeCurrency();
|
||||
}
|
||||
|
||||
root.getSelectionModel().selectedItemProperty().addListener(tabChangeListener);
|
||||
|
|
|
@ -164,7 +164,7 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
|
|||
|
||||
reSyncSPVChainButton.setOnAction(event -> {
|
||||
if (walletsSetup.reSyncSPVChain()) {
|
||||
new Popup<>().feedback(Res.get("settings.net.reSyncSPVSuccess"))
|
||||
new Popup<>(preferences).feedback(Res.get("settings.net.reSyncSPVSuccess"))
|
||||
.useShutDownButton()
|
||||
.actionButtonText(Res.get("shared.shutDown"))
|
||||
.onAction(() -> {
|
||||
|
@ -174,7 +174,7 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
|
|||
.hideCloseButton()
|
||||
.show();
|
||||
} else {
|
||||
new Popup<>().error(Res.get("settings.net.reSyncSPVFailed")).show();
|
||||
new Popup<>(preferences).error(Res.get("settings.net.reSyncSPVFailed")).show();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Activatab
|
|||
private ComboBox<CryptoCurrency> cryptoCurrenciesComboBox;
|
||||
private Button resetDontShowAgainButton;
|
||||
// private ListChangeListener<TradeCurrency> displayCurrenciesListChangeListener;
|
||||
final ObservableList<String> btcDenominations = FXCollections.observableArrayList(PreferencesImpl.getBtcDenominations());
|
||||
final ObservableList<String> btcDenominations = FXCollections.observableArrayList();
|
||||
final ObservableList<BlockChainExplorer> blockExplorers;
|
||||
final ObservableList<String> languageCodes;
|
||||
final ObservableList<Country> countries;
|
||||
|
|
|
@ -22,6 +22,7 @@ import io.bisq.common.Clock;
|
|||
import io.bisq.common.app.AppModule;
|
||||
import io.bisq.common.crypto.KeyRing;
|
||||
import io.bisq.common.crypto.KeyStorage;
|
||||
import io.bisq.common.persistance.ProtobufferResolver;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import io.bisq.core.alert.AlertModule;
|
||||
import io.bisq.core.app.BisqEnvironment;
|
||||
|
@ -36,7 +37,6 @@ import io.bisq.core.user.PreferencesImpl;
|
|||
import io.bisq.core.user.User;
|
||||
import io.bisq.network.crypto.EncryptionServiceModule;
|
||||
import io.bisq.network.p2p.P2PModule;
|
||||
import io.bisq.common.persistance.ProtobufferResolver;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
|
Loading…
Add table
Reference in a new issue