Change parseUri to compares with lowercase cryptocoin

This commit is contained in:
hvarona 2018-11-18 21:41:29 -04:00
parent ce1df325d8
commit 73ba419b66

View file

@ -544,12 +544,13 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
String cryptoNet = uri.substring(0,uri.indexOf(":")); String cryptoNet = uri.substring(0,uri.indexOf(":"));
if(cryptoNet.equalsIgnoreCase(this.cryptoCoin.name().toLowerCase())){ if(cryptoNet.equalsIgnoreCase(this.cryptoCoin.name().toLowerCase())){
try{ try{
Address address = Address.fromBase58(this.cryptoCoin.getParameters(), request.getAddress()); int parameterIndex =uri.indexOf("?");
Address address = Address.fromBase58(this.cryptoCoin.getParameters(), uri.substring(uri.indexOf(":")+1,parameterIndex>0?parameterIndex:uri.length()));
request.setAddress(address.toString()); request.setAddress(address.toString());
request.setStatus(BitcoinUriParseRequest.StatusCode.VALID); request.setStatus(BitcoinUriParseRequest.StatusCode.VALID);
if(uri.indexOf("?")>0){ if(parameterIndex>0){
try { try {
String[] parameters = uri.substring(uri.indexOf("?") + 1).split("&"); String[] parameters = uri.substring(parameterIndex + 1).split("&");
for (String parameter : parameters) { for (String parameter : parameters) {
int idx = parameter.indexOf("="); int idx = parameter.indexOf("=");
if (idx > 0 && parameter.substring(0, idx).equalsIgnoreCase("amount")) { if (idx > 0 && parameter.substring(0, idx).equalsIgnoreCase("amount")) {
@ -566,13 +567,14 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
request.setStatus(BitcoinUriParseRequest.StatusCode.NOT_VALID); request.setStatus(BitcoinUriParseRequest.StatusCode.NOT_VALID);
} }
}else{ }else{
if(uri.indexOf("?")>0){ int parameterIndex =uri.indexOf("?");
if(parameterIndex>0){
try{ try{
Address address = Address.fromBase58(this.cryptoCoin.getParameters(), request.getAddress()); Address address = Address.fromBase58(this.cryptoCoin.getParameters(), uri.substring(uri.indexOf(":")+1,parameterIndex>0?parameterIndex:uri.length()));
request.setAddress(address.toString()); request.setAddress(address.toString());
request.setStatus(BitcoinUriParseRequest.StatusCode.VALID); request.setStatus(BitcoinUriParseRequest.StatusCode.VALID);
try{ try{
String[] parameters = uri.substring(uri.indexOf("?")+1).split("&"); String[] parameters = uri.substring(parameterIndex+1).split("&");
for(String parameter : parameters){ for(String parameter : parameters){
int idx = parameter.indexOf("="); int idx = parameter.indexOf("=");
if(idx > 0 && parameter.substring(0,idx).equalsIgnoreCase("amount")){ if(idx > 0 && parameter.substring(0,idx).equalsIgnoreCase("amount")){
@ -586,7 +588,7 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
} }
}else{ }else{
try{ try{
Address address = Address.fromBase58(this.cryptoCoin.getParameters(), request.getAddress()); Address address = Address.fromBase58(this.cryptoCoin.getParameters(), uri);
request.setAddress(address.toString()); request.setAddress(address.toString());
request.setStatus(BitcoinUriParseRequest.StatusCode.VALID); request.setStatus(BitcoinUriParseRequest.StatusCode.VALID);