added dash as base currency

This commit is contained in:
Mike Rosseel 2017-07-14 20:20:19 +02:00
parent 1d5965e296
commit b2f6d7435c
14 changed files with 134 additions and 20 deletions

View File

@ -81,7 +81,7 @@ public class CurrencyUtil {
return allSortedCryptoCurrencies;
}
// Don't make a PR for adding a coin but follow the steps described here:
// Don't make a PR for adding a coin but follow the steps described here:
// https://forum.bisq.io/t/how-to-add-your-favorite-altcoin/
public static List<CryptoCurrency> createAllSortedCryptoCurrenciesList() {
final List<CryptoCurrency> result = new ArrayList<>();
@ -121,7 +121,8 @@ public class CurrencyUtil {
result.add(new CryptoCurrency("CBX", "Crypto Bullion"));
result.add(new CryptoCurrency("DNET", "DarkNet"));
result.add(new CryptoCurrency("DIBC", "DIBCOIN"));
result.add(new CryptoCurrency("DASH", "Dash"));
if (!baseCurrencyCode.equals("DASH"))
result.add(new CryptoCurrency("DASH", "Dash"));
result.add(new CryptoCurrency("DCR", "Decred"));
result.add(new CryptoCurrency("DGB", "Digibyte"));
result.add(new CryptoCurrency("DRS", "Digital Rupees"));
@ -223,7 +224,7 @@ public class CurrencyUtil {
result.sort(TradeCurrency::compareTo);
// Util for printing all altcoins for adding to FAQ page
/*
/*
StringBuilder sb = new StringBuilder();
result.stream().forEach(e -> sb.append("<li>\"")
.append(e.getCode())
@ -241,7 +242,8 @@ public class CurrencyUtil {
// result.add(new CryptoCurrency("BSQ", "Bisq Token"));
if (!baseCurrencyCode.equals("BTC"))
result.add(new CryptoCurrency("BTC", "Bitcoin"));
result.add(new CryptoCurrency("DASH", "Dash"));
if (!baseCurrencyCode.equals("DASH"))
result.add(new CryptoCurrency("DASH", "Dash"));
result.add(new CryptoCurrency("DCR", "Decred"));
if (!baseCurrencyCode.equals("DOGE"))
result.add(new CryptoCurrency("DOGE", "Dogecoin"));

View File

@ -1390,6 +1390,12 @@ DOGE_TESTNET=Dogecoin Testnet
# suppress inspection "UnusedProperty"
DOGE_REGTEST=Dogecoin Regtest
# suppress inspection "UnusedProperty"
DASH_MAINNET=DASH Mainnet
# suppress inspection "UnusedProperty"
DASH_TESTNET=DASH Testnet
# suppress inspection "UnusedProperty"
DASH_REGTEST=DASH Regtest
time.year=Year
time.month=Month

View File

@ -18,6 +18,7 @@
package io.bisq.core.btc;
import io.bisq.core.app.BisqEnvironment;
import io.bisq.core.provider.fee.FeeService;
import lombok.Getter;
import org.bitcoinj.core.Coin;
import org.bitcoinj.core.NetworkParameters;
@ -37,7 +38,11 @@ public enum BaseCurrencyNetwork {
DOGE_MAINNET(DogecoinMainNetParams.get(), "DOGE", "MAINNET", "Dogecoin"),
DOGE_TESTNET(DogecoinTestNet3Params.get(), "DOGE", "TESTNET", "Dogecoin"),
DOGE_REGTEST(DogecoinRegTestParams.get(), "DOGE", "REGTEST", "Dogecoin");
DOGE_REGTEST(DogecoinRegTestParams.get(), "DOGE", "REGTEST", "Dogecoin"),
DASH_MAINNET(DashMainNetParams.get(), "DASH", "MAINNET", "Dash"),
DASH_TESTNET(DashTestNet3Params.get(), "DASH", "TESTNET", "Dash"),
DASH_REGTEST(DashRegTestParams.get(), "DASH", "REGTEST", "Dash");
@Getter
private final NetworkParameters parameters;
@ -76,7 +81,11 @@ public enum BaseCurrencyNetwork {
case "BTC":
return org.bitcoinj.core.Transaction.REFERENCE_DEFAULT_MIN_TX_FEE;
case "LTC":
return Coin.valueOf(FeeService.LTC_DEFAULT_TX_FEE);
case "DOGE":
return Coin.valueOf(FeeService.DOGE_DEFAULT_TX_FEE);
case "DASH":
return Coin.valueOf(FeeService.DASH_DEFAULT_TX_FEE);
default:
// TODO check what is the right fee at DOGE
return Coin.valueOf(100000);

View File

@ -49,13 +49,15 @@ public class Restrictions {
if (MIN_TRADE_AMOUNT == null)
switch (BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode()) {
case "BTC":
MIN_TRADE_AMOUNT = Coin.valueOf(10_000); // 0.25 EUR @ 2500 EUR/BTC
MIN_TRADE_AMOUNT = Coin.valueOf(10_000); // 0.25 EUR @ 2500 EUR/BTC
break;
case "LTC":
MIN_TRADE_AMOUNT = Coin.valueOf(100_000); // 0.04 EUR @ 40 EUR/LTC
MIN_TRADE_AMOUNT = Coin.valueOf(100_000); // 0.04 EUR @ 40 EUR/LTC
break;
case "DOGE":
MIN_TRADE_AMOUNT = Coin.valueOf(1_000_000_000L); // 0.03 EUR at DOGE price 0.003 EUR;
case "DASH":
MIN_TRADE_AMOUNT = Coin.valueOf(20_000L); // 0.03 EUR at DOGE price 0.003 EUR;
break;
}
return MIN_TRADE_AMOUNT;
@ -65,14 +67,17 @@ public class Restrictions {
if (MAX_BUYER_SECURITY_DEPOSIT == null)
switch (BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode()) {
case "BTC":
MAX_BUYER_SECURITY_DEPOSIT = Coin.valueOf(20_000_000); // 500 EUR @ 2500 EUR/BTC
MAX_BUYER_SECURITY_DEPOSIT = Coin.valueOf(20_000_000); // 500 EUR @ 2500 EUR/BTC
break;
case "LTC":
MAX_BUYER_SECURITY_DEPOSIT = Coin.valueOf(1_200_000_000); // 500 EUR @ 40 EUR/LTC
MAX_BUYER_SECURITY_DEPOSIT = Coin.valueOf(1_200_000_000); // 500 EUR @ 40 EUR/LTC
break;
case "DOGE":
MAX_BUYER_SECURITY_DEPOSIT = Coin.valueOf(20_000_000_000_000L); // 500 EUR @ 0.0025 EUR/DOGE;
break;
case "DASH":
MAX_BUYER_SECURITY_DEPOSIT = Coin.valueOf(333_333_333L); // 500 EUR @ 0.0025 EUR/DOGE;
break;
}
return MAX_BUYER_SECURITY_DEPOSIT;
@ -82,14 +87,17 @@ public class Restrictions {
if (MIN_BUYER_SECURITY_DEPOSIT == null)
switch (BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode()) {
case "BTC":
MIN_BUYER_SECURITY_DEPOSIT = Coin.valueOf(100_000); // 2.5 EUR @ 2500 EUR/BTC
MIN_BUYER_SECURITY_DEPOSIT = Coin.valueOf(100_000); // 2.5 EUR @ 2500 EUR/BTC
break;
case "LTC":
MIN_BUYER_SECURITY_DEPOSIT = Coin.valueOf(6_000_000); // 2.5 EUR @ 40 EUR/LTC
MIN_BUYER_SECURITY_DEPOSIT = Coin.valueOf(6_000_000); // 2.5 EUR @ 40 EUR/LTC
break;
case "DOGE":
MIN_BUYER_SECURITY_DEPOSIT = Coin.valueOf(100_000_000_000L); // 2.5 EUR @ 0.0025 EUR/DOGE;
break;
case "DASH":
MIN_BUYER_SECURITY_DEPOSIT = Coin.valueOf(1_666_666L); // 2.5 EUR @ 0.0025 EUR/DOGE;
break;
}
return MIN_BUYER_SECURITY_DEPOSIT;
}
@ -98,14 +106,17 @@ public class Restrictions {
if (DEFAULT_BUYER_SECURITY_DEPOSIT == null)
switch (BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode()) {
case "BTC":
DEFAULT_BUYER_SECURITY_DEPOSIT = Coin.valueOf(3_000_000); // 75 EUR @ 2500 EUR/BTC
DEFAULT_BUYER_SECURITY_DEPOSIT = Coin.valueOf(3_000_000); // 75 EUR @ 2500 EUR/BTC
break;
case "LTC":
DEFAULT_BUYER_SECURITY_DEPOSIT = Coin.valueOf(200_000_000); // 75 EUR @ 40 EUR/LTC
DEFAULT_BUYER_SECURITY_DEPOSIT = Coin.valueOf(200_000_000); // 75 EUR @ 40 EUR/LTC
break;
case "DOGE":
DEFAULT_BUYER_SECURITY_DEPOSIT = Coin.valueOf(3_000_000_000_000L); // 75 EUR @ 0.0025 EUR/DOGE;
break;
case "DASH":
DEFAULT_BUYER_SECURITY_DEPOSIT = Coin.valueOf(50_000_000L); // 75 EUR @ 150 EUR/DASH;
break;
}
return DEFAULT_BUYER_SECURITY_DEPOSIT;
}
@ -114,14 +125,17 @@ public class Restrictions {
if (SELLER_SECURITY_DEPOSIT == null)
switch (BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode()) {
case "BTC":
SELLER_SECURITY_DEPOSIT = Coin.valueOf(1_000_000); // 25 EUR @ 2500 EUR/BTC
SELLER_SECURITY_DEPOSIT = Coin.valueOf(1_000_000); // 25 EUR @ 2500 EUR/BTC
break;
case "LTC":
SELLER_SECURITY_DEPOSIT = Coin.valueOf(60_000_000); // 25 EUR @ 40 EUR/LTC
SELLER_SECURITY_DEPOSIT = Coin.valueOf(60_000_000); // 25 EUR @ 40 EUR/LTC
break;
case "DOGE":
SELLER_SECURITY_DEPOSIT = Coin.valueOf(1_000_000_000_000L); // 25 EUR @ 0.0025 EUR/DOGE;
break;
case "DASH":
SELLER_SECURITY_DEPOSIT = Coin.valueOf(16_666_666L); // 25 EUR @ 150 EUR/DASH;
break;
}
return SELLER_SECURITY_DEPOSIT;
}

View File

@ -137,6 +137,11 @@ public final class PaymentMethod implements PersistablePayload, Comparable {
maxTradeLimitMidRisk = Coin.parseCoin("250000");
maxTradeLimitLowRisk = Coin.parseCoin("500000");
break;
case "DASH":
// av. price June 2017: 150 EUR/DASH
maxTradeLimitMidRisk = Coin.parseCoin("8");
maxTradeLimitLowRisk = Coin.parseCoin("16");
break;
default:
log.error("Unsupported BaseCurrency. " + BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode());

View File

@ -53,10 +53,12 @@ public class FeeProvider extends HttpClientProvider {
Long btcTxFee = dataMap.get("btcTxFee").longValue();
Long ltcTxFee = dataMap.get("ltcTxFee").longValue();
Long dogeTxFee = dataMap.get("dogeTxFee").longValue();
Long dashTxFee = dataMap.get("dashTxFee").longValue();
map.put("BTC", btcTxFee);
map.put("LTC", ltcTxFee);
map.put("DOGE", dogeTxFee);
map.put("DASH", dashTxFee);
} catch (Throwable t) {
log.error(t.toString());
t.printStackTrace();

View File

@ -47,6 +47,7 @@ public class FeeService {
public static final long LTC_DEFAULT_TX_FEE = 500; // min fee is 0.001 LTC 200 bytes with 500 -> 100000
public static final long BTC_DEFAULT_TX_FEE = 200;
public static final long DOGE_DEFAULT_TX_FEE = 500000; // min tx size is about 200 bytes -> 1 DOGE
public static final long DASH_DEFAULT_TX_FEE = 10000; // 10000 now, 1000 in sept 2017
// Dust limit for LTC is 100 000 sat
// https://litecoin.info/Transaction_fees
@ -83,6 +84,10 @@ public class FeeService {
this.feeProvider = feeProvider;
baseCurrencyCode = BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode();
/* How to calculate:
def nr_satoshi(price_per_one, target_price):
return target_price*100000000/price_per_one
*/
switch (baseCurrencyCode) {
case "BTC":
MIN_MAKER_FEE_IN_BASE_CUR = 20_000; // 0.5 USD at BTC price 2500 USD for 1 BTC
@ -105,6 +110,13 @@ public class FeeService {
DEFAULT_TAKER_FEE_IN_BASE_CUR = 480_000; // 7.5 USD at DOGE price 0.003 USD 1_200_000_000_000L
txFeePerByte = DOGE_DEFAULT_TX_FEE;
break;
case "DASH":
MIN_MAKER_FEE_IN_BASE_CUR = 333_333; // 0.5 USD at DASH price 150 USD
MIN_TAKER_FEE_IN_BASE_CUR = 333_333;
DEFAULT_MAKER_FEE_IN_BASE_CUR = 3_333_333; // 5 USD at DOGE price 0.003 USD
DEFAULT_TAKER_FEE_IN_BASE_CUR = 5_000_000; // 7.5 USD at DOGE price 0.003 USD
txFeePerByte = DASH_DEFAULT_TX_FEE;
break;
default:
throw new RuntimeException("baseCurrencyCode not defined. baseCurrencyCode=" + baseCurrencyCode);
}

View File

@ -231,6 +231,7 @@ public class PriceFeedService {
cache.putAll(priceMap);
break;
case "LTC":
case "DASH":
case "DOGE":
// apply conversion of btc based price to baseCurrencyCode based with btc/baseCurrencyCode price
MarketPrice baseCurrencyPrice = priceMap.get(baseCurrencyCode);

View File

@ -75,6 +75,13 @@ public final class Preferences implements PersistedDataHost {
new BlockChainExplorer("SoChain", "https://chain.so/tx/DOGETEST/", "https://chain.so/address/DOGETEST/")
));
private static final ArrayList<BlockChainExplorer> DASH_MAIN_NET_EXPLORERS = new ArrayList<>(Arrays.asList(
new BlockChainExplorer("SoChain", "https://chain.so/tx/dash/", "https://chain.so/address/dash/")
));
private static final ArrayList<BlockChainExplorer> DASH_TEST_NET_EXPLORERS = new ArrayList<>(Arrays.asList(
new BlockChainExplorer("SoChain", "https://chain.so/tx/DASHTEST/", "https://chain.so/address/DASHTEST/")
));
// payload is initialized so the default values are available for Property initialization.
@Setter
@ -188,6 +195,10 @@ public final class Preferences implements PersistedDataHost {
setBlockChainExplorerMainNet(DOGE_MAIN_NET_EXPLORERS.get(0));
setBlockChainExplorerTestNet(DOGE_TEST_NET_EXPLORERS.get(0));
break;
case "DASH":
setBlockChainExplorerMainNet(DASH_MAIN_NET_EXPLORERS.get(0));
setBlockChainExplorerTestNet(DASH_TEST_NET_EXPLORERS.get(0));
break;
default:
throw new RuntimeException("BaseCurrencyNetwork not defined. BaseCurrencyNetwork=" + baseCurrencyNetwork);
}
@ -513,6 +524,11 @@ public final class Preferences implements PersistedDataHost {
case DOGE_TESTNET:
case DOGE_REGTEST:
return DOGE_TEST_NET_EXPLORERS;
case DASH_MAINNET:
return DASH_MAIN_NET_EXPLORERS;
case DASH_REGTEST:
case DASH_TESTNET:
return DASH_TEST_NET_EXPLORERS;
default:
throw new RuntimeException("BaseCurrencyNetwork not defined. BaseCurrencyNetwork=" + baseCurrencyNetwork);
}

View File

@ -207,6 +207,10 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
amount.set("800000");
price.set("0.003");
break;
case "DASH":
amount.set("2");
price.set("0.07");
break;
}
minAmount.set(amount.get());

View File

@ -49,6 +49,10 @@ public class BsqFormatter extends BSFormatter {
// BSQ for DOGE not used/supported
coinFormat = new MonetaryFormat().shift(3).code(3, "???").minDecimals(5);
break;
case "DASH":
// BSQ for DASH not used/supported
coinFormat = new MonetaryFormat().shift(3).code(3, "???").minDecimals(5);
break;
default:
throw new RuntimeException("baseCurrencyCode not defined. baseCurrencyCode=" + baseCurrencyCode);
}

View File

@ -57,8 +57,8 @@ public final class AltCoinAddressValidator extends InputValidator {
return validationResult;
} else {
// Validation:
// 1: With a regex checking the correct structure of an address
// Validation:
// 1: With a regex checking the correct structure of an address
// 2: If the address contains a checksum, verify the checksum
ValidationResult wrongChecksum = new ValidationResult(false,
@ -85,6 +85,9 @@ public final class AltCoinAddressValidator extends InputValidator {
case DOGE_MAINNET:
case DOGE_TESTNET:
case DOGE_REGTEST:
case DASH_MAINNET:
case DASH_TESTNET:
case DASH_REGTEST:
Address.fromBase58(BtcMainNetParams.get(), input);
return new ValidationResult(true);
}
@ -101,6 +104,9 @@ public final class AltCoinAddressValidator extends InputValidator {
case DOGE_MAINNET:
case DOGE_TESTNET:
case DOGE_REGTEST:
case DASH_MAINNET:
case DASH_TESTNET:
case DASH_REGTEST:
case LTC_MAINNET:
Address.fromBase58(LitecoinMainNetParams.get(), input);
break;
@ -124,6 +130,9 @@ public final class AltCoinAddressValidator extends InputValidator {
case LTC_MAINNET:
case LTC_TESTNET:
case LTC_REGTEST:
case DASH_MAINNET:
case DASH_TESTNET:
case DASH_REGTEST:
case DOGE_MAINNET:
Address.fromBase58(DogecoinMainNetParams.get(), input);
break;
@ -138,6 +147,32 @@ public final class AltCoinAddressValidator extends InputValidator {
} catch (AddressFormatException e) {
return new ValidationResult(false, getErrorMessage(e));
}
case "DASH":
try {
switch (BisqEnvironment.getBaseCurrencyNetwork()) {
case BTC_MAINNET:
case BTC_TESTNET:
case BTC_REGTEST:
case LTC_MAINNET:
case LTC_TESTNET:
case LTC_REGTEST:
case DOGE_MAINNET:
case DOGE_TESTNET:
case DOGE_REGTEST:
case DASH_MAINNET:
Address.fromBase58(DashMainNetParams.get(), input);
break;
case DASH_REGTEST:
Address.fromBase58(DashRegTestParams.get(), input);
break;
case DASH_TESTNET:
Address.fromBase58(DashTestNet3Params.get(), input);
break;
}
return new ValidationResult(true);
} catch (AddressFormatException e) {
return new ValidationResult(false, getErrorMessage(e));
}
case "ETH":
// https://github.com/ethereum/web3.js/blob/master/lib/utils/utils.js#L403
if (!input.matches("^(0x)?[0-9a-fA-F]{40}$"))

View File

@ -87,7 +87,10 @@ public class SeedNodesRepository {
new NodeAddress("localhost:2005"),
// DOGE regtest
new NodeAddress("localhost:2008")
new NodeAddress("localhost:2008"),
// DASH regtest
new NodeAddress("localhost:2011")
);
private NodeAddress nodeAddressToExclude;

View File

@ -35,7 +35,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class FeeRequestService {
private static final Logger log = LoggerFactory.getLogger(FeeRequestService.class);
private static final long INTERVAL_BTC_FEES_MS = 600_000; // 10 min
private static final long INTERVAL_BTC_FEES_MS = 600_000; // 10 min
public static final long BTC_MIN_TX_FEE = 40; // satoshi/byte
public static final long BTC_MAX_TX_FEE = 2000;
@ -50,10 +50,11 @@ public class FeeRequestService {
public FeeRequestService() throws IOException {
btcFeesProvider = new BtcFeesProvider();
// For now we don't need a fee estimation for LTC so we set it fixed, but we keep it in the provider to
// For now we don't need a fee estimation for LTC so we set it fixed, but we keep it in the provider to
// be flexible if fee pressure grows on LTC
dataMap.put("ltcTxFee", FeeService.LTC_DEFAULT_TX_FEE);
dataMap.put("dogeTxFee", FeeService.DOGE_DEFAULT_TX_FEE);
dataMap.put("dashTxFee", FeeService.DASH_DEFAULT_TX_FEE);
writeToJson();
startRequests();