Skip to content

Commit

Permalink
Remove libdohj dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarguindzberg committed Feb 4, 2019
1 parent 68a6de2 commit f08e174
Show file tree
Hide file tree
Showing 35 changed files with 43 additions and 528 deletions.
13 changes: 10 additions & 3 deletions assets/src/main/java/bisq/asset/coins/Dash.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@

import bisq.asset.Base58BitcoinAddressValidator;
import bisq.asset.Coin;

import org.libdohj.params.DashMainNetParams;
import bisq.asset.NetworkParametersAdapter;

public class Dash extends Coin {
public Dash() {
super("Dash", "DASH", new Base58BitcoinAddressValidator(DashMainNetParams.get()), Network.MAINNET);
super("Dash", "DASH", new Base58BitcoinAddressValidator(new DashMainNetParams()), Network.MAINNET);
}

public static class DashMainNetParams extends NetworkParametersAdapter {
public DashMainNetParams() {
this.addressHeader = 76;
this.p2shHeader = 16;
this.acceptableAddressCodes = new int[]{this.addressHeader, this.p2shHeader};
}
}
}
2 changes: 0 additions & 2 deletions assets/src/main/java/bisq/asset/coins/DeepOnion.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;

import org.libdohj.params.DashMainNetParams;

public class DeepOnion extends Coin {
public DeepOnion() {
super("DeepOnion", "ONION", new DeepOnionAddressValidator());
Expand Down
13 changes: 10 additions & 3 deletions assets/src/main/java/bisq/asset/coins/Dogecoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@

import bisq.asset.Base58BitcoinAddressValidator;
import bisq.asset.Coin;

import org.libdohj.params.DogecoinMainNetParams;
import bisq.asset.NetworkParametersAdapter;

public class Dogecoin extends Coin {

public Dogecoin() {
super("Dogecoin", "DOGE", new Base58BitcoinAddressValidator(DogecoinMainNetParams.get()));
super("Dogecoin", "DOGE", new Base58BitcoinAddressValidator(new DogecoinMainNetParams()), Network.MAINNET);
}

public static class DogecoinMainNetParams extends NetworkParametersAdapter {
public DogecoinMainNetParams() {
this.addressHeader = 30;
this.p2shHeader = 22;
this.acceptableAddressCodes = new int[]{this.addressHeader, this.p2shHeader};
}
}
}
13 changes: 10 additions & 3 deletions assets/src/main/java/bisq/asset/coins/Litecoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@

import bisq.asset.Base58BitcoinAddressValidator;
import bisq.asset.Coin;

import org.libdohj.params.LitecoinMainNetParams;
import bisq.asset.NetworkParametersAdapter;

public class Litecoin extends Coin {
public Litecoin() {
super("Litecoin", "LTC", new Base58BitcoinAddressValidator(LitecoinMainNetParams.get()), Network.MAINNET);
super("Litecoin", "LTC", new Base58BitcoinAddressValidator(new LitecoinMainNetParams()), Network.MAINNET);
}

public static class LitecoinMainNetParams extends NetworkParametersAdapter {
public LitecoinMainNetParams() {
this.addressHeader = 48;
this.p2shHeader = 5;
this.acceptableAddressCodes = new int[]{this.addressHeader, this.p2shHeader};
}
}
}
10 changes: 0 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ configure(subprojects) {
jmockitVersion = '1.42'
joptVersion = '5.0.3'
langVersion = '3.4'
libdohjVersion = '7be803fa'
bitcoinjVersion = 'cd30ad5b'
logbackVersion = '1.1.10'
lombokVersion = '1.18.2'
Expand Down Expand Up @@ -132,10 +131,6 @@ configure([project(':desktop'),

configure(project(':assets')) {
dependencies {
compile("network.bisq.libdohj:libdohj-core:$libdohjVersion") {
exclude(module: 'protobuf-java')
exclude(module: 'bitcoinj-core')
}
compile("com.github.bisq-network.bitcoinj:bitcoinj-core:$bitcoinjVersion") {
exclude(module: 'protobuf-java')
}
Expand Down Expand Up @@ -174,11 +169,6 @@ configure(project(':common')) {
compile('com.google.inject:guice:4.1.0') {
exclude(module: 'guava')
}
compile("network.bisq.libdohj:libdohj-core:$libdohjVersion") {
exclude(module: 'slf4j-api')
exclude(module: 'protobuf-java')
exclude(module: 'bitcoinj-core')
}
compile("com.github.bisq-network.bitcoinj:bitcoinj-core:$bitcoinjVersion") {
exclude(module: 'jsr305')
exclude(module: 'slf4j-api')
Expand Down
6 changes: 2 additions & 4 deletions core/src/main/java/bisq/core/app/WalletAppSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import bisq.core.user.Preferences;
import bisq.core.util.BSFormatter;

import org.libdohj.Version;

import org.bitcoinj.core.VersionMessage;
import org.bitcoinj.store.BlockStoreException;
import org.bitcoinj.store.ChainFileLockedException;
Expand Down Expand Up @@ -90,8 +88,8 @@ void init(@Nullable Consumer<String> chainFileLockedExceptionHandler,
Runnable walletPasswordHandler,
Runnable downloadCompleteHandler,
Runnable walletInitializedHandler) {
log.info("Initialize WalletAppSetup with BitcoinJ version {} and LibDohJ version {} with hash of BitcoinJ commit {}",
VersionMessage.BITCOINJ_VERSION, Version.VERSION, Version.BITCOINJ_VERSION);
log.info("Initialize WalletAppSetup with BitcoinJ version and hash of BitcoinJ commit {}",
VersionMessage.BITCOINJ_VERSION, "cd30ad5b");

ObjectProperty<Throwable> walletServiceException = new SimpleObjectProperty<>();
btcInfoBinding = EasyBind.combine(walletsSetup.downloadPercentageProperty(),
Expand Down
25 changes: 1 addition & 24 deletions core/src/main/java/bisq/core/btc/BaseCurrencyNetwork.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@

package bisq.core.btc;

import org.libdohj.params.DashMainNetParams;
import org.libdohj.params.DashRegTestParams;
import org.libdohj.params.DashTestNet3Params;
import org.libdohj.params.LitecoinMainNetParams;
import org.libdohj.params.LitecoinRegTestParams;
import org.libdohj.params.LitecoinTestNet3Params;

import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.params.MainNetParams;
import org.bitcoinj.params.RegTestParams;
Expand All @@ -34,15 +27,7 @@
public enum BaseCurrencyNetwork {
BTC_MAINNET(MainNetParams.get(), "BTC", "MAINNET", "Bitcoin"),
BTC_TESTNET(TestNet3Params.get(), "BTC", "TESTNET", "Bitcoin"),
BTC_REGTEST(RegTestParams.get(), "BTC", "REGTEST", "Bitcoin"),

LTC_MAINNET(LitecoinMainNetParams.get(), "LTC", "MAINNET", "Litecoin"),
LTC_TESTNET(LitecoinTestNet3Params.get(), "LTC", "TESTNET", "Litecoin"),
LTC_REGTEST(LitecoinRegTestParams.get(), "LTC", "REGTEST", "Litecoin"),

DASH_MAINNET(DashMainNetParams.get(), "DASH", "MAINNET", "Dash"),
DASH_TESTNET(DashTestNet3Params.get(), "DASH", "TESTNET", "Dash"),
DASH_REGTEST(DashRegTestParams.get(), "DASH", "REGTEST", "Dash");
BTC_REGTEST(RegTestParams.get(), "BTC", "REGTEST", "Bitcoin");

@Getter
private final NetworkParameters parameters;
Expand Down Expand Up @@ -76,14 +61,6 @@ public boolean isBitcoin() {
return "BTC".equals(currencyCode);
}

public boolean isLitecoin() {
return "LTC".equals(currencyCode);
}

public boolean isDash() {
return "DASH".equals(currencyCode);
}

public long getDefaultMinFeePerByte() {
return 1;
}
Expand Down
61 changes: 5 additions & 56 deletions core/src/main/java/bisq/core/btc/wallet/Restrictions.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,83 +48,32 @@ public static boolean isDust(Coin amount) {

public static Coin getMinTradeAmount() {
if (MIN_TRADE_AMOUNT == null)
switch (BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode()) {
case "BTC":
MIN_TRADE_AMOUNT = Coin.valueOf(10_000); // 2 USD @ 20000 USD/BTC
break;
case "LTC":
MIN_TRADE_AMOUNT = Coin.valueOf(100_000); // 0.04 EUR @ 40 EUR/LTC
break;
case "DASH":
MIN_TRADE_AMOUNT = Coin.valueOf(20_000L); // 0.03 EUR at @ 150 EUR/DASH;
break;
}
MIN_TRADE_AMOUNT = Coin.valueOf(10_000); // 2 USD @ 20000 USD/BTC
return MIN_TRADE_AMOUNT;
}

// Can be reduced but not increased. Otherwise would break existing offers!
public static Coin getMaxBuyerSecurityDeposit() {
if (MAX_BUYER_SECURITY_DEPOSIT == null)
switch (BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode()) {
case "BTC":
MAX_BUYER_SECURITY_DEPOSIT = Coin.valueOf(5_000_000); // 1000 USD @ 20000 USD/BTC
break;
case "LTC":
MAX_BUYER_SECURITY_DEPOSIT = Coin.valueOf(1_200_000_000); // 500 EUR @ 40 EUR/LTC
break;
case "DASH":
MAX_BUYER_SECURITY_DEPOSIT = Coin.valueOf(300_000_000L); // 450 EUR @ 150 EUR/DASH;
break;
}

MAX_BUYER_SECURITY_DEPOSIT = Coin.valueOf(5_000_000); // 1000 USD @ 20000 USD/BTC
return MAX_BUYER_SECURITY_DEPOSIT;
}

public static Coin getMinBuyerSecurityDeposit() {
if (MIN_BUYER_SECURITY_DEPOSIT == null)
switch (BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode()) {
case "BTC":
MIN_BUYER_SECURITY_DEPOSIT = Coin.valueOf(50_000); // 10 USD @ 20000 USD/BTC
break;
case "LTC":
MIN_BUYER_SECURITY_DEPOSIT = Coin.valueOf(6_000_000); // 2.4 EUR @ 40 EUR/LTC
break;
case "DASH":
MIN_BUYER_SECURITY_DEPOSIT = Coin.valueOf(1_500_000L); // 2.5 EUR @ 150 EUR/DASH;
break;
}
MIN_BUYER_SECURITY_DEPOSIT = Coin.valueOf(50_000); // 10 USD @ 20000 USD/BTC
return MIN_BUYER_SECURITY_DEPOSIT;
}

public static Coin getDefaultBuyerSecurityDeposit() {
if (DEFAULT_BUYER_SECURITY_DEPOSIT == null)
switch (BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode()) {
case "BTC":
DEFAULT_BUYER_SECURITY_DEPOSIT = Coin.valueOf(1_000_000); // 200 EUR @ 20000 USD/BTC
break;
case "LTC":
DEFAULT_BUYER_SECURITY_DEPOSIT = Coin.valueOf(200_000_000); // 75 EUR @ 40 EUR/LTC
break;
case "DASH":
DEFAULT_BUYER_SECURITY_DEPOSIT = Coin.valueOf(50_000_000L); // 75 EUR @ 150 EUR/DASH;
break;
}
DEFAULT_BUYER_SECURITY_DEPOSIT = Coin.valueOf(1_000_000); // 200 EUR @ 20000 USD/BTC
return DEFAULT_BUYER_SECURITY_DEPOSIT;
}

public static Coin getSellerSecurityDeposit() {
if (SELLER_SECURITY_DEPOSIT == null)
switch (BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode()) {
case "BTC":
SELLER_SECURITY_DEPOSIT = Coin.valueOf(300_000); // 60 USD @ 20000 USD/BTC
break;
case "LTC":
SELLER_SECURITY_DEPOSIT = Coin.valueOf(60_000_000); // 25 EUR @ 40 EUR/LTC
break;
case "DASH":
SELLER_SECURITY_DEPOSIT = Coin.valueOf(15_000_000L); // 25 EUR @ 150 EUR/DASH;
break;
}
SELLER_SECURITY_DEPOSIT = Coin.valueOf(300_000); // 60 USD @ 20000 USD/BTC
return SELLER_SECURITY_DEPOSIT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,8 @@ class DefaultSeedNodeAddresses {

// regtest
new NodeAddress("localhost:2002"),
new NodeAddress("localhost:3002"),
new NodeAddress("localhost:3002")
/* new NodeAddress("localhost:4002"),*/

// LTC
// mainnet
new NodeAddress("localhost:2003"),

// regtest
new NodeAddress("localhost:2005"),

// DOGE regtest
new NodeAddress("localhost:2008"),

// DASH regtest
new NodeAddress("localhost:2011")
);

// Addresses are used if their port match the network id:
Expand Down Expand Up @@ -93,15 +80,8 @@ class DefaultSeedNodeAddresses {
// 4. Rename the directory with your local onion address
// 5. Edit here your found onion address (new NodeAddress("YOUR_ONION.onion:8002")
new NodeAddress("rxdkppp3vicnbgqt.onion:8002"),
new NodeAddress("4ie52dse64kaarxw.onion:8002"),

// LTC mainnet
new NodeAddress("acyvotgewx46pebw.onion:8003"),
new NodeAddress("pklgy3vdfn3obkur.onion:8003"),
new NodeAddress("4ie52dse64kaarxw.onion:8002")

// DASH mainnet
new NodeAddress("toeu5ikb27ydscxt.onion:8006"),
new NodeAddress("ae4yvaivhnekkhqf.onion:8006")
);

private DefaultSeedNodeAddresses() {
Expand Down
13 changes: 0 additions & 13 deletions core/src/main/java/bisq/core/payment/payload/PaymentMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,6 @@ public static List<PaymentMethod> getAllValues() {
maxTradeLimitLowRisk = Coin.parseCoin("0.5");
maxTradeLimitVeryLowRisk = Coin.parseCoin("1");
break;
case "LTC":
maxTradeLimitHighRisk = Coin.parseCoin("12.5");
maxTradeLimitMidRisk = Coin.parseCoin("25");
maxTradeLimitLowRisk = Coin.parseCoin("50");
maxTradeLimitVeryLowRisk = Coin.parseCoin("100");
break;
case "DASH":
maxTradeLimitHighRisk = Coin.parseCoin("5");
maxTradeLimitMidRisk = Coin.parseCoin("10");
maxTradeLimitLowRisk = Coin.parseCoin("20");
maxTradeLimitVeryLowRisk = Coin.parseCoin("40");
break;

default:
log.error("Unsupported BaseCurrency. " + BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode());
throw new RuntimeException("Unsupported BaseCurrency. " + BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode());
Expand Down
4 changes: 0 additions & 4 deletions core/src/main/java/bisq/core/provider/fee/FeeProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,8 @@ public Tuple2<Map<String, Long>, Map<String, Long>> getFees() throws IOException
//noinspection unchecked
LinkedTreeMap<String, Double> dataMap = (LinkedTreeMap<String, Double>) linkedTreeMap.get("dataMap");
Long btcTxFee = dataMap.get("btcTxFee").longValue();
Long ltcTxFee = dataMap.get("ltcTxFee").longValue();
Long dashTxFee = dataMap.get("dashTxFee").longValue();

map.put("BTC", btcTxFee);
map.put("LTC", ltcTxFee);
map.put("DASH", dashTxFee);
} catch (Throwable t) {
log.error(t.toString());
t.printStackTrace();
Expand Down
38 changes: 0 additions & 38 deletions core/src/main/java/bisq/core/user/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,26 +105,6 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
public static final BlockChainExplorer BSQ_TEST_NET_EXPLORER = new BlockChainExplorer("BSQ", "https://explorer.bisq.network/testnet/tx.html?tx=",
"https://explorer.bisq.network/testnet/Address.html?addr=");

private static final ArrayList<BlockChainExplorer> LTC_MAIN_NET_EXPLORERS = new ArrayList<>(Arrays.asList(
new BlockChainExplorer("Blockcypher", "https://live.blockcypher.com/ltc/tx/", "https://live.blockcypher.com/ltc/address/"),
new BlockChainExplorer("CryptoID", "https://chainz.cryptoid.info/ltc/tx.dws?", "https://chainz.cryptoid.info/ltc/address.dws?"),
new BlockChainExplorer("Abe Search", "http://explorer.litecoin.net/tx/", "http://explorer.litecoin.net/address/"),
new BlockChainExplorer("SoChain", "https://chain.so/tx/LTC/", "https://chain.so/address/LTC/"),
new BlockChainExplorer("Blockr.io", "http://ltc.blockr.io/tx/info/", "http://ltc.blockr.io/address/info/")
));

private static final ArrayList<BlockChainExplorer> LTC_TEST_NET_EXPLORERS = new ArrayList<>(Arrays.asList(
new BlockChainExplorer("SoChain", "https://chain.so/tx/LTCTEST/", "https://chain.so/address/LTCTEST/")
));

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
@Delegate(excludes = ExcludesDelegateMethods.class)
Expand Down Expand Up @@ -243,14 +223,6 @@ public void readPersisted() {
setBlockChainExplorerMainNet(BTC_MAIN_NET_EXPLORERS.get(0));
setBlockChainExplorerTestNet(BTC_TEST_NET_EXPLORERS.get(0));
break;
case "LTC":
setBlockChainExplorerMainNet(LTC_MAIN_NET_EXPLORERS.get(0));
setBlockChainExplorerTestNet(LTC_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);
}
Expand Down Expand Up @@ -672,16 +644,6 @@ public ArrayList<BlockChainExplorer> getBlockChainExplorers() {
case BTC_TESTNET:
case BTC_REGTEST:
return BTC_TEST_NET_EXPLORERS;
case LTC_MAINNET:
return LTC_MAIN_NET_EXPLORERS;
case LTC_TESTNET:
case LTC_REGTEST:
return LTC_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);
}
Expand Down
Loading

0 comments on commit f08e174

Please sign in to comment.