Added steem url and verifier

Added bip21 implementation with lowercase
This commit is contained in:
hvarona 2018-11-11 21:59:28 -04:00
parent 8ff53de0ae
commit 6e81192b37
4 changed files with 16 additions and 29 deletions

View file

@ -57,6 +57,17 @@ public class CrystalApplication extends Application {
public static final CryptoCurrency BITCOIN_CURRENCY = new CryptoCurrency("BTC",CryptoNet.BITCOIN,8); public static final CryptoCurrency BITCOIN_CURRENCY = new CryptoCurrency("BTC",CryptoNet.BITCOIN,8);
public static String STEEM_URL[] =
{
"https://api.steemit.com",
"https://api.steemitdev.com",
"https://api.steemitstage.com",
"https://api.steem.house",
"https://appbasetest.timcliff.com",
};
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
@ -108,6 +119,8 @@ public class CrystalApplication extends Application {
db.cryptoCurrencyDao().insertCryptoCurrency(BITCOIN_CURRENCY); db.cryptoCurrencyDao().insertCryptoCurrency(BITCOIN_CURRENCY);
} }
CryptoNetManager.addCryptoNetURL(CryptoNet.STEEM,STEEM_URL);
GeneralSetting generalSettingPreferredLanguage = db.generalSettingDao().getSettingByName(GeneralSetting.SETTING_NAME_PREFERRED_LANGUAGE); GeneralSetting generalSettingPreferredLanguage = db.generalSettingDao().getSettingByName(GeneralSetting.SETTING_NAME_PREFERRED_LANGUAGE);

View file

@ -495,7 +495,7 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
} }
private void calculateUri(CalculateBitcoinUriRequest request) { private void calculateUri(CalculateBitcoinUriRequest request) {
StringBuilder uri = new StringBuilder(this.cryptoCoin.getLabel()+":"); StringBuilder uri = new StringBuilder(this.cryptoCoin.getLabel().toLowerCase()+":");
CrystalDatabase db = CrystalDatabase.getAppDatabase(request.getContext()); CrystalDatabase db = CrystalDatabase.getAppDatabase(request.getContext());
long index = db.bitcoinAddressDao().getLastExternalAddress(request.getAccount().getId()); long index = db.bitcoinAddressDao().getLastExternalAddress(request.getAccount().getId());

View file

@ -33,7 +33,6 @@ import cy.agorise.crystalwallet.models.GrapheneAccount;
import cy.agorise.crystalwallet.models.GrapheneAccountInfo; import cy.agorise.crystalwallet.models.GrapheneAccountInfo;
import cy.agorise.crystalwallet.models.seed.BIP39; import cy.agorise.crystalwallet.models.seed.BIP39;
import cy.agorise.crystalwallet.network.CryptoNetManager; import cy.agorise.crystalwallet.network.CryptoNetManager;
import cy.agorise.crystalwallet.requestmanagers.CryptoNetEquivalentRequest;
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequest; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequest;
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestsListener; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestsListener;
import cy.agorise.crystalwallet.requestmanagers.GetBitsharesAccountNameCacheRequest; import cy.agorise.crystalwallet.requestmanagers.GetBitsharesAccountNameCacheRequest;
@ -185,8 +184,6 @@ public class SteemAccountManager implements CryptoAccountManager, CryptoNetInfoR
this.validateExistAcccount((ValidateExistBitsharesAccountRequest) request); this.validateExistAcccount((ValidateExistBitsharesAccountRequest) request);
} else if (request instanceof ValidateBitsharesSendRequest) { } else if (request instanceof ValidateBitsharesSendRequest) {
this.validateSendRequest((ValidateBitsharesSendRequest) request); this.validateSendRequest((ValidateBitsharesSendRequest) request);
} else if (request instanceof CryptoNetEquivalentRequest) {
this.getEquivalentValue((CryptoNetEquivalentRequest) request);
} else if (request instanceof GetBitsharesAccountNameCacheRequest) { } else if (request instanceof GetBitsharesAccountNameCacheRequest) {
this.getBitsharesAccountNameCacheRequest((GetBitsharesAccountNameCacheRequest) request); this.getBitsharesAccountNameCacheRequest((GetBitsharesAccountNameCacheRequest) request);
} else { } else {
@ -699,31 +696,6 @@ public class SteemAccountManager implements CryptoAccountManager, CryptoNetInfoR
} }
} }
/**
* Gets the current change from two assets
*/
private void getEquivalentValue(final CryptoNetEquivalentRequest request){
if(request.getFromCurrency() instanceof BitsharesAsset && request.getToCurrency() instanceof BitsharesAsset) {
BitsharesAsset fromAsset = (BitsharesAsset) request.getFromCurrency();
BitsharesAsset toAsset = (BitsharesAsset) request.getToCurrency();
ApiRequest getEquivalentRequest = new ApiRequest(0, new ApiRequestListener() {
@Override
public void success(Object answer, int idPetition) {
request.setPrice((Long)answer);
}
@Override
public void fail(int idPetition) {
//TODO error
}
});
GrapheneApiGenerator.getEquivalentValue(fromAsset.getBitsharesId(),toAsset.getBitsharesId(), getEquivalentRequest);
}else{
//TODO error
System.out.println("Equivalent Value error ");
}
}
/** /**
* Class to retrieve the account id or the account name, if one of those is missing * Class to retrieve the account id or the account name, if one of those is missing
*/ */

View file

@ -18,6 +18,8 @@ public abstract class CryptoNetVerifier {
return new BitsharesCryptoNetVerifier(); return new BitsharesCryptoNetVerifier();
}else if(cryptoNet.getLabel().equals(CryptoNet.BITCOIN.getLabel())){ }else if(cryptoNet.getLabel().equals(CryptoNet.BITCOIN.getLabel())){
return new BitcoinCryptoNetVerifier(CryptoCoin.BITCOIN); return new BitcoinCryptoNetVerifier(CryptoCoin.BITCOIN);
}else if(cryptoNet.getLabel().equals(CryptoNet.STEEM.getLabel())){
return new SteemCryptoNetVerifier();
} }
return null; return null;
} }