diff --git a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java index d2451f4..297017a 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java +++ b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java @@ -637,7 +637,7 @@ public abstract class GrapheneApiGenerator { CrystalDatabase db = CrystalDatabase.getAppDatabase(context); final CryptoCurrencyDao cryptoCurrencyDao = db.cryptoCurrencyDao(); final BitsharesAssetDao bitsharesAssetDao = db.bitsharesAssetDao(); - CryptoCurrency baseCurrency = cryptoCurrencyDao.getByName(baseAssetName); + CryptoCurrency baseCurrency = cryptoCurrencyDao.getByName(baseAssetName,CryptoNet.BITSHARES.name()); BitsharesAssetInfo info = null; if(baseCurrency != null){ info = db.bitsharesAssetDao().getBitsharesAssetInfo(baseCurrency.getId()); diff --git a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/InsightApiGenerator.java b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/InsightApiGenerator.java index d6229c9..1e647a9 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/InsightApiGenerator.java +++ b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/InsightApiGenerator.java @@ -14,6 +14,8 @@ public class InsightApiGenerator { private static HashMap transactionGetters = new HashMap(); private static HashMap transactionFollowers = new HashMap(); + private static final String PATH = "api"; + /** * Fecth all the transaciton for a giving address * @param cryptoCoin the crypto net of the address @@ -22,13 +24,13 @@ public class InsightApiGenerator { */ public static void getTransactionFromAddress(CryptoCoin cryptoCoin, String address, boolean subscribe){ if(!transactionGetters.containsKey(cryptoCoin)){ - transactionGetters.put(cryptoCoin,new GetTransactionByAddress(cryptoCoin,CryptoNetManager.getURL(cryptoCoin.getCryptoNet()))); + transactionGetters.put(cryptoCoin,new GetTransactionByAddress(cryptoCoin,CryptoNetManager.getURL(cryptoCoin.getCryptoNet()),PATH)); } transactionGetters.get(cryptoCoin).addAddress(address); transactionGetters.get(cryptoCoin).start(); if(subscribe){ if(!transactionFollowers.containsKey(cryptoCoin)){ - transactionFollowers.put(cryptoCoin,new AddressesActivityWatcher(CryptoNetManager.getURL(cryptoCoin.getCryptoNet()),cryptoCoin)); + transactionFollowers.put(cryptoCoin,new AddressesActivityWatcher(CryptoNetManager.getURL(cryptoCoin.getCryptoNet()),PATH,cryptoCoin)); } transactionFollowers.get(cryptoCoin).addAddress(address); transactionFollowers.get(cryptoCoin).connect(); @@ -42,7 +44,7 @@ public class InsightApiGenerator { */ public static void broadcastTransaction(CryptoCoin cryptoCoin, String rawtx, final ApiRequest request){ BroadcastTransaction bTransaction = new BroadcastTransaction(rawtx, - CryptoNetManager.getURL(cryptoCoin.getCryptoNet()), "api", new BroadcastTransaction.BroadCastTransactionListener() { + CryptoNetManager.getURL(cryptoCoin.getCryptoNet()), PATH, new BroadcastTransaction.BroadCastTransactionListener() { @Override public void onSuccess() { request.getListener().success(true,request.getId()); diff --git a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/AddressesActivityWatcher.java b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/AddressesActivityWatcher.java index 719c412..df5aedc 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/AddressesActivityWatcher.java +++ b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/AddressesActivityWatcher.java @@ -38,6 +38,7 @@ public class AddressesActivityWatcher { private Socket mSocket; private final String mServerUrl; + private final String mPath; /** * Handles the address/transaction notification. @@ -49,7 +50,7 @@ public class AddressesActivityWatcher { try { System.out.println("Receive accountActivtyWatcher " + os[0].toString() ); String txid = ((JSONObject) os[0]).getString(InsightApiConstants.sTxTag); - new GetTransactionData(txid, mServerUrl, cryptoCoin).start(); + new GetTransactionData(txid, mServerUrl, mPath, cryptoCoin).start(); } catch (JSONException ex) { Logger.getLogger(AddressesActivityWatcher.class.getName()).log(Level.SEVERE, null, ex); } @@ -106,7 +107,8 @@ public class AddressesActivityWatcher { * Basic constructor * */ - public AddressesActivityWatcher(String serverUrl, CryptoCoin cryptoCoin) { + public AddressesActivityWatcher(String serverUrl, String path, CryptoCoin cryptoCoin) { + this.mPath = path; this.mServerUrl = serverUrl; this.cryptoCoin = cryptoCoin; try { diff --git a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/GetEstimateFee.java b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/GetEstimateFee.java index 520594c..dccb4dd 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/GetEstimateFee.java +++ b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/GetEstimateFee.java @@ -20,6 +20,8 @@ import retrofit2.Response; public abstract class GetEstimateFee { + private static String PATH = "api"; + /** * The funciton to get the rate for the transaction be included in the next 2 blocks * @param serverUrl The url of the insight server @@ -29,12 +31,11 @@ public abstract class GetEstimateFee { try { InsightApiServiceGenerator serviceGenerator = new InsightApiServiceGenerator(serverUrl); InsightApiService service = serviceGenerator.getService(InsightApiService.class); - Call call = service.estimateFee(serverUrl); - final JsonObject answer = new JsonObject(); + Call call = service.estimateFee(PATH); call.enqueue(new Callback() { @Override public void onResponse(Call call, Response response) { - listener.estimateFee((long) (answer.get("answer").getAsDouble())); + listener.estimateFee((long) (response.body().get("2").getAsDouble())); } diff --git a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/GetGenesisBlock.java b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/GetGenesisBlock.java new file mode 100644 index 0000000..68e9ff5 --- /dev/null +++ b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/GetGenesisBlock.java @@ -0,0 +1,43 @@ +package cy.agorise.crystalwallet.apigenerator.insightapi; + +import com.google.gson.JsonObject; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; + +public class GetGenesisBlock { + + private static String PATH = "api"; + + public GetGenesisBlock(String serverUrl, final genesisBlockListener listener) { + try { + InsightApiServiceGenerator serviceGenerator = new InsightApiServiceGenerator(serverUrl); + InsightApiService service = serviceGenerator.getService(InsightApiService.class); + Call call = service.genesisBlock(PATH); + call.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + try { + listener.genesisBlock(response.body().get("blockHash").getAsString()); + }catch(Exception e){ + e.printStackTrace(); + listener.fail(); + } + } + + @Override + public void onFailure(Call call, Throwable t) { + listener.fail(); + } + }); + }catch(Exception e){ + listener.fail(); + } + } + + public interface genesisBlockListener{ + void genesisBlock(String value); + void fail(); + } +} diff --git a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/GetTransactionByAddress.java b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/GetTransactionByAddress.java index 5ca3894..f14c392 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/GetTransactionByAddress.java +++ b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/GetTransactionByAddress.java @@ -1,27 +1,14 @@ package cy.agorise.crystalwallet.apigenerator.insightapi; -import android.content.Context; import android.util.Log; -import com.idescout.sql.SqlScoutServer; - import java.util.ArrayList; -import java.util.Date; import java.util.List; -import cy.agorise.crystalwallet.apigenerator.InsightApiGenerator; import cy.agorise.crystalwallet.apigenerator.insightapi.models.AddressTxi; import cy.agorise.crystalwallet.apigenerator.insightapi.models.Txi; -import cy.agorise.crystalwallet.apigenerator.insightapi.models.Vin; -import cy.agorise.crystalwallet.apigenerator.insightapi.models.Vout; import cy.agorise.crystalwallet.enums.CryptoCoin; -import cy.agorise.crystalwallet.enums.CryptoNet; import cy.agorise.crystalwallet.manager.GeneralAccountManager; -import cy.agorise.crystalwallet.models.CryptoCurrency; -import cy.agorise.crystalwallet.models.GTxIO; -import cy.agorise.crystalwallet.models.GeneralCoinAccount; -import cy.agorise.crystalwallet.models.GeneralCoinAddress; -import cy.agorise.crystalwallet.models.GeneralTransaction; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; @@ -41,7 +28,9 @@ public class GetTransactionByAddress extends Thread implements Callback addressTxiCall = service.getTransactionByAddress(this.serverUrl,addressToQuery.toString()); + Call addressTxiCall = service.getTransactionByAddress(this.mPath,addressToQuery.toString()); addressTxiCall.enqueue(this); } } diff --git a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/GetTransactionData.java b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/GetTransactionData.java index 2286c0b..9d3ba60 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/GetTransactionData.java +++ b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/GetTransactionData.java @@ -32,6 +32,8 @@ public class GetTransactionData extends Thread implements Callback { private InsightApiServiceGenerator mServiceGenerator; private String mServerUrl; + + private String mPath; /** * If has to wait for another confirmation */ @@ -43,8 +45,8 @@ public class GetTransactionData extends Thread implements Callback { * Constructor used to query for a transaction with unknown confirmations * @param txid The txid of the transaciton to be query */ - public GetTransactionData(String txid, String serverUrl, CryptoCoin cryptoCoin) { - this(txid, serverUrl, cryptoCoin, false); + public GetTransactionData(String txid, String serverUrl, String path, CryptoCoin cryptoCoin) { + this(txid, serverUrl, path, cryptoCoin, false); } @@ -53,7 +55,8 @@ public class GetTransactionData extends Thread implements Callback { * @param txid The txid of the transaciton to be query * @param mustWait If there is less confirmation that needed */ - public GetTransactionData(String txid, String serverUrl, CryptoCoin cryptoCoin, boolean mustWait) { + public GetTransactionData(String txid, String serverUrl, String path, CryptoCoin cryptoCoin, boolean mustWait) { + this.mPath = path; this.mServerUrl = serverUrl; this.mTxId= txid; this.mServiceGenerator = new InsightApiServiceGenerator(serverUrl); @@ -76,7 +79,7 @@ public class GetTransactionData extends Thread implements Callback { } InsightApiService service = this.mServiceGenerator.getService(InsightApiService.class); - Call txiCall = service.getTransaction(this.mServerUrl,this.mTxId); + Call txiCall = service.getTransaction(this.mPath,this.mTxId); txiCall.enqueue(this); } @@ -88,7 +91,7 @@ public class GetTransactionData extends Thread implements Callback { GeneralAccountManager.getAccountManager(this.cryptoCoin).processTxi(txi); if (txi.confirmations < this.cryptoCoin.getCryptoNet().getConfirmationsNeeded()) { //If transaction weren't confirmed, add the transaction to watch for change on the confirmations - new GetTransactionData(this.mTxId, this.mServerUrl, this.cryptoCoin, true).start(); + new GetTransactionData(this.mTxId, this.mServerUrl, this.mPath, this.cryptoCoin, true).start(); } } } diff --git a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/InsightApiService.java b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/InsightApiService.java index 5e36ca1..884c11d 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/InsightApiService.java +++ b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/InsightApiService.java @@ -49,4 +49,7 @@ interface InsightApiService { @GET("{path}/utils/estimatefee?nbBlocks=2") Call estimateFee(@Path(value = "path", encoded = true) String path); + @GET("{path}/block-index/0") + Call genesisBlock(@Path(value = "path", encoded = true) String path); + } diff --git a/app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java b/app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java index 9854491..67fc2b4 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java +++ b/app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java @@ -17,6 +17,7 @@ import cy.agorise.crystalwallet.dao.CrystalDatabase; import cy.agorise.crystalwallet.enums.CryptoNet; import cy.agorise.crystalwallet.models.BitsharesAsset; import cy.agorise.crystalwallet.models.BitsharesAssetInfo; +import cy.agorise.crystalwallet.models.CryptoCurrency; import cy.agorise.crystalwallet.models.CryptoCurrencyEquivalence; import cy.agorise.crystalwallet.models.GeneralSetting; import cy.agorise.crystalwallet.network.CryptoNetManager; @@ -49,6 +50,13 @@ public class CrystalApplication extends Application { //This is for testing the equivalent values on the testnet TODO remove public static BitsharesAsset bitEURAsset = new BitsharesAsset("EUR",4,"1.3.120",BitsharesAsset.Type.SMART_COIN); + + public static final String BITCOIN_SERVER_URLS[] ={ + "https://insight.bitpay.com/" + }; + + public static final CryptoCurrency BITCOIN_CURRENCY = new CryptoCurrency("BTC",CryptoNet.BITCOIN,8); + @Override public void onCreate() { super.onCreate(); @@ -62,10 +70,10 @@ public class CrystalApplication extends Application { //This is for testing the equivalent values on the testnet TODO remove if(db.bitsharesAssetDao().getBitsharesAssetInfoById(bitEURAsset.getBitsharesId())== null){ - if(db.cryptoCurrencyDao().getByName(bitEURAsset.getName())== null){ + if(db.cryptoCurrencyDao().getByName(bitEURAsset.getName(),bitEURAsset.getCryptoNet().name())== null){ db.cryptoCurrencyDao().insertCryptoCurrency(bitEURAsset); } - long idCurrency = db.cryptoCurrencyDao().getByName(bitEURAsset.getName()).getId(); + long idCurrency = db.cryptoCurrencyDao().getByName(bitEURAsset.getName(),bitEURAsset.getCryptoNet().name()).getId(); BitsharesAssetInfo info = new BitsharesAssetInfo(bitEURAsset); info.setCryptoCurrencyId(idCurrency); db.bitsharesAssetDao().insertBitsharesAssetInfo(info); @@ -74,10 +82,10 @@ public class CrystalApplication extends Application { //This is for testing the equivalent values on the testnet TODO remove if(db.bitsharesAssetDao().getBitsharesAssetInfoById(bitUSDAsset.getBitsharesId())== null){ - if(db.cryptoCurrencyDao().getByName(bitUSDAsset.getName())== null){ + if(db.cryptoCurrencyDao().getByName(bitUSDAsset.getName(),bitUSDAsset.getCryptoNet().name())== null){ db.cryptoCurrencyDao().insertCryptoCurrency(bitUSDAsset); } - long idCurrency = db.cryptoCurrencyDao().getByName(bitUSDAsset.getName()).getId(); + long idCurrency = db.cryptoCurrencyDao().getByName(bitUSDAsset.getName(),bitUSDAsset.getCryptoNet().name()).getId(); BitsharesAssetInfo info = new BitsharesAssetInfo(bitUSDAsset); info.setCryptoCurrencyId(idCurrency); db.bitsharesAssetDao().insertBitsharesAssetInfo(info); @@ -93,6 +101,14 @@ public class CrystalApplication extends Application { // TODO and hoop over the urls if no connection can be established CryptoNetManager.addCryptoNetURL(CryptoNet.BITSHARES,BITSHARES_URL); + //Adding Bitcoin info + CryptoNetManager.addCryptoNetURL(CryptoNet.BITCOIN,BITCOIN_SERVER_URLS); + + if(db.cryptoCurrencyDao().getByName(BITCOIN_CURRENCY.getName(),BITCOIN_CURRENCY.getCryptoNet().name())== null){ + db.cryptoCurrencyDao().insertCryptoCurrency(BITCOIN_CURRENCY); + } + + GeneralSetting generalSettingPreferredLanguage = db.generalSettingDao().getSettingByName(GeneralSetting.SETTING_NAME_PREFERRED_LANGUAGE); if (generalSettingPreferredLanguage != null) { diff --git a/app/src/main/java/cy/agorise/crystalwallet/application/constant/BitsharesConstant.java b/app/src/main/java/cy/agorise/crystalwallet/application/constant/BitsharesConstant.java index 6783404..f6af35d 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/application/constant/BitsharesConstant.java +++ b/app/src/main/java/cy/agorise/crystalwallet/application/constant/BitsharesConstant.java @@ -74,10 +74,10 @@ public abstract class BitsharesConstant { public static void addSmartCoins(Context context){ CrystalDatabase db = CrystalDatabase.getAppDatabase(context); for(BitsharesAsset smartcoin : SMARTCOINS){ - if(db.cryptoCurrencyDao().getByName(smartcoin.getName())== null){ + if(db.cryptoCurrencyDao().getByName(smartcoin.getName(),CryptoNet.BITSHARES.name())== null){ db.cryptoCurrencyDao().insertCryptoCurrency(smartcoin); } - long idCurrency = db.cryptoCurrencyDao().getByName(smartcoin.getName()).getId(); + long idCurrency = db.cryptoCurrencyDao().getByName(smartcoin.getName(),CryptoNet.BITSHARES.name()).getId(); BitsharesAssetInfo info = new BitsharesAssetInfo(smartcoin); info.setCryptoCurrencyId(idCurrency); db.bitsharesAssetDao().insertBitsharesAssetInfo(info); diff --git a/app/src/main/java/cy/agorise/crystalwallet/dao/CryptoCurrencyDao.java b/app/src/main/java/cy/agorise/crystalwallet/dao/CryptoCurrencyDao.java index 47888aa..08823d2 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/dao/CryptoCurrencyDao.java +++ b/app/src/main/java/cy/agorise/crystalwallet/dao/CryptoCurrencyDao.java @@ -35,8 +35,8 @@ public interface CryptoCurrencyDao { @Query("SELECT * FROM crypto_currency WHERE name = :name") LiveData getLiveDataByName(String name); - @Query("SELECT * FROM crypto_currency WHERE name = :name") - CryptoCurrency getByName(String name); + @Query("SELECT * FROM crypto_currency WHERE name = :name and crypto_net = :cryptoNet") + CryptoCurrency getByName(String name, String cryptoNet); @Insert(onConflict = OnConflictStrategy.IGNORE) public long[] insertCryptoCurrency(CryptoCurrency... currencies); diff --git a/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java b/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java index 32ae22e..eee12bf 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java +++ b/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java @@ -130,7 +130,7 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI long[] idAccount = db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount); grapheneAccount.setId(idAccount[0]); db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(grapheneAccount)); - //subscribeBitsharesAccount(grapheneAccount.getId(),grapheneAccount.getAccountId(),context); + subscribeBitsharesAccount(grapheneAccount.getId(),grapheneAccount.getAccountId(),context); } @Override @@ -148,7 +148,7 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI CrystalDatabase db = CrystalDatabase.getAppDatabase(context); db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount); db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(grapheneAccount)); - //subscribeBitsharesAccount(grapheneAccount.getId(),grapheneAccount.getAccountId(),context); + subscribeBitsharesAccount(grapheneAccount.getId(),grapheneAccount.getAccountId(),context); } @Override @@ -160,7 +160,7 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI CrystalDatabase db = CrystalDatabase.getAppDatabase(context); db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount); db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(grapheneAccount)); - //subscribeBitsharesAccount(grapheneAccount.getId(), grapheneAccount.getAccountId(), context); + subscribeBitsharesAccount(grapheneAccount.getId(), grapheneAccount.getAccountId(), context); } } } diff --git a/app/src/main/java/cy/agorise/crystalwallet/models/CryptoCurrency.java b/app/src/main/java/cy/agorise/crystalwallet/models/CryptoCurrency.java index 3c732d9..eaf72ee 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/models/CryptoCurrency.java +++ b/app/src/main/java/cy/agorise/crystalwallet/models/CryptoCurrency.java @@ -45,6 +45,15 @@ public class CryptoCurrency { @ColumnInfo(name = "precision") private int mPrecision; + public CryptoCurrency() { + } + + public CryptoCurrency(String name, CryptoNet cryptoNet, int precision) { + this.mName = name; + this.mCryptoNet = cryptoNet; + this.mPrecision = precision; + } + public long getId() { return mId; } diff --git a/app/src/main/java/cy/agorise/crystalwallet/network/BitcoinCryptoNetVerifier.java b/app/src/main/java/cy/agorise/crystalwallet/network/BitcoinCryptoNetVerifier.java new file mode 100644 index 0000000..f29ea0d --- /dev/null +++ b/app/src/main/java/cy/agorise/crystalwallet/network/BitcoinCryptoNetVerifier.java @@ -0,0 +1,46 @@ +package cy.agorise.crystalwallet.network; + +import cy.agorise.crystalwallet.apigenerator.insightapi.GetGenesisBlock; +import cy.agorise.crystalwallet.enums.CryptoCoin; + +public class BitcoinCryptoNetVerifier extends CryptoNetVerifier{ + + final CryptoCoin cryptoCoin; + + public BitcoinCryptoNetVerifier(CryptoCoin cryptoCoin) { + this.cryptoCoin = cryptoCoin; + } + + @Override + public void checkURL(final String url) { + + final long startTime = System.currentTimeMillis(); + GetGenesisBlock genesisBloc = new GetGenesisBlock(url, new GetGenesisBlock.genesisBlockListener() { + @Override + public void genesisBlock(String value) { + if(cryptoCoin.getParameters()!= null){ + if(value.equals(cryptoCoin.getParameters().getGenesisBlock().getHashAsString())){ + + CryptoNetManager.verifiedCryptoNetURL(cryptoCoin.getCryptoNet(), url, System.currentTimeMillis() - startTime); + } + //TODO bad genesis block + }else{ + CryptoNetManager.verifiedCryptoNetURL(cryptoCoin.getCryptoNet(), url, System.currentTimeMillis() - startTime); + } + } + + @Override + public void fail() { + //TODO failed + } + }); + } + + @Override + public String getChainId() { + if(cryptoCoin == null || cryptoCoin.getParameters()== null) { + return null; + } + return cryptoCoin.getParameters().getGenesisBlock().getHashAsString(); + } +} diff --git a/app/src/main/java/cy/agorise/crystalwallet/network/CryptoNetVerifier.java b/app/src/main/java/cy/agorise/crystalwallet/network/CryptoNetVerifier.java index 046a3d7..c0e38ee 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/network/CryptoNetVerifier.java +++ b/app/src/main/java/cy/agorise/crystalwallet/network/CryptoNetVerifier.java @@ -1,5 +1,6 @@ package cy.agorise.crystalwallet.network; +import cy.agorise.crystalwallet.enums.CryptoCoin; import cy.agorise.crystalwallet.enums.CryptoNet; /** @@ -15,6 +16,8 @@ public abstract class CryptoNetVerifier { static CryptoNetVerifier getNetworkVerify(CryptoNet cryptoNet){ if(cryptoNet.getLabel().equals(CryptoNet.BITSHARES.getLabel())){ return new BitsharesCryptoNetVerifier(); + }else if(cryptoNet.getLabel().equals(CryptoNet.BITCOIN.getLabel())){ + return new BitcoinCryptoNetVerifier(CryptoCoin.BITCOIN); } return null; }