Skip to content

Commit

Permalink
update cash account server list
Browse files Browse the repository at this point in the history
  • Loading branch information
pokkst committed Jul 19, 2019
1 parent 501b33f commit 6349037
Show file tree
Hide file tree
Showing 2 changed files with 171 additions and 75 deletions.
Binary file modified WalletTemplate-test.wallet
Binary file not shown.
246 changes: 171 additions & 75 deletions core/src/main/java/org/bitcoinj/net/NetHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
public class NetHelper {
private String[] cashAcctServers = new String[]{
"https://cashacct.imaginary.cash",
"https://api.cashaccount.info"
"https://api.cashaccount.info",
"https://electrum.imaginary.cash",
"https://cashaccounts.bchdata.cash",
"https://cashacct.electroncash.dk",
"https://rest.bitcoin.com/v2/cashAccounts"
};

private String[] blockExplorers = new String[]{
Expand Down Expand Up @@ -130,11 +134,69 @@ private String getTxHexFromCashAcct(String cashAccount) {
String name = splitAccount[0];
String block = splitAccount[1];

if (!block.contains(".")) {
if(!lookupServer.contains("rest.bitcoin.com"))
{
if (!block.contains(".")) {
InputStream is = null;

try {
is = (new URL(lookupServer + "/lookup/" + block + "/" + name)).openStream();
} catch (IOException var56) {
var56.printStackTrace();
}

try {
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
String jsonText = org.bitcoinj.utils.JSONHelper.readJSONFile(rd);
JSONObject json = new JSONObject(jsonText);
txHex = json.getJSONArray("results").getJSONObject(0).getString("transaction");
} catch (JSONException | IOException var53) {
var53.printStackTrace();
} finally {
try {
is.close();
} catch (IOException var47) {
var47.printStackTrace();
}

}
} else {
String[] splitBlock = block.split("\\.");
String mainBlock = splitBlock[0];
String collision = splitBlock[1];
InputStream is = null;

try {
is = (new URL(lookupServer + "/lookup/" + mainBlock + "/" + name + "/" + collision)).openStream();
} catch (IOException var52) {
var52.printStackTrace();
}

try {
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
String jsonText = org.bitcoinj.utils.JSONHelper.readJSONFile(rd);
JSONObject json = new JSONObject(jsonText);
txHex = json.getJSONArray("results").getJSONObject(0).getString("transaction");
} catch (JSONException | IOException var49) {
var49.printStackTrace();
} finally {
try {
if (is != null) {
is.close();
}
} catch (IOException var48) {
var48.printStackTrace();
}

}
}
}
else
{
InputStream is = null;

try {
is = (new URL(lookupServer + "/lookup/" + block + "/" + name)).openStream();
is = (new URL(lookupServer + "/check/" + name + "/" + block)).openStream();
} catch (IOException var56) {
var56.printStackTrace();
}
Expand All @@ -153,35 +215,6 @@ private String getTxHexFromCashAcct(String cashAccount) {
var47.printStackTrace();
}

}
} else {
String[] splitBlock = block.split("\\.");
String mainBlock = splitBlock[0];
String collision = splitBlock[1];
InputStream is = null;

try {
is = (new URL(lookupServer + "/lookup/" + mainBlock + "/" + name + "/" + collision)).openStream();
} catch (IOException var52) {
var52.printStackTrace();
}

try {
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
String jsonText = org.bitcoinj.utils.JSONHelper.readJSONFile(rd);
JSONObject json = new JSONObject(jsonText);
txHex = json.getJSONArray("results").getJSONObject(0).getString("transaction");
} catch (JSONException | IOException var49) {
var49.printStackTrace();
} finally {
try {
if (is != null) {
is.close();
}
} catch (IOException var48) {
var48.printStackTrace();
}

}
}

Expand Down Expand Up @@ -250,62 +283,125 @@ private String getExpectedCashAccountAddress(String cashAccount) {
String[] splitAccount = cashAccount.split("#");
String name = splitAccount[0];
String block = splitAccount[1];
if (!block.contains(".")) {
InputStream is = null;

try {
is = (new URL(lookupServer + "/account/" + block + "/" + name)).openStream();
} catch (IOException var56) {
var56.printStackTrace();
}
if(!lookupServer.contains("rest.bitcoin.com")) {
if (!block.contains(".")) {
InputStream is = null;

try {
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
String jsonText = org.bitcoinj.utils.JSONHelper.readJSONFile(rd);
JSONObject json = new JSONObject(jsonText);
address = json.getJSONObject("information").getJSONArray("payment").getJSONObject(0).getString("address");
} catch (JSONException var53) {
var53.printStackTrace();
} catch (IOException var54) {
var54.printStackTrace();
} finally {
try {
is.close();
} catch (IOException var48) {
var48.printStackTrace();
is = (new URL(lookupServer + "/account/" + block + "/" + name)).openStream();
} catch (IOException var56) {
var56.printStackTrace();
}

}
} else {
String[] splitBlock = block.split("\\.");
String mainBlock = splitBlock[0];
String collision = splitBlock[1];
InputStream is = null;
try {
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
String jsonText = org.bitcoinj.utils.JSONHelper.readJSONFile(rd);
JSONObject json = new JSONObject(jsonText);
address = json.getJSONObject("information").getJSONArray("payment").getJSONObject(0).getString("address");
} catch (JSONException var53) {
var53.printStackTrace();
} catch (IOException var54) {
var54.printStackTrace();
} finally {
try {
is.close();
} catch (IOException var48) {
var48.printStackTrace();
}

try {
is = (new URL(lookupServer + "/account/" + mainBlock + "/" + name + "/" + collision)).openStream();
} catch (IOException var52) {
var52.printStackTrace();
}
} else {
String[] splitBlock = block.split("\\.");
String mainBlock = splitBlock[0];
String collision = splitBlock[1];
InputStream is = null;

try {
is = (new URL(lookupServer + "/account/" + mainBlock + "/" + name + "/" + collision)).openStream();
} catch (IOException var52) {
var52.printStackTrace();
}

try {
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
String jsonText = org.bitcoinj.utils.JSONHelper.readJSONFile(rd);
JSONObject json = new JSONObject(jsonText);
address = json.getJSONObject("information").getJSONArray("payment").getJSONObject(0).getString("address");
} catch (JSONException var49) {
var49.printStackTrace();
} catch (IOException var50) {
var50.printStackTrace();
} finally {
try {
if (is != null) {
is.close();
}
} catch (IOException var47) {
var47.printStackTrace();
}

}
}
}
else
{
if (!block.contains(".")) {
InputStream is = null;

try {
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
String jsonText = org.bitcoinj.utils.JSONHelper.readJSONFile(rd);
JSONObject json = new JSONObject(jsonText);
address = json.getJSONObject("information").getJSONArray("payment").getJSONObject(0).getString("address");
} catch (JSONException var49) {
var49.printStackTrace();
} catch (IOException var50) {
var50.printStackTrace();
} finally {
try {
if (is != null) {
is = (new URL(lookupServer + "/lookup/" + name + "/" + block)).openStream();
} catch (IOException var56) {
var56.printStackTrace();
}

try {
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
String jsonText = org.bitcoinj.utils.JSONHelper.readJSONFile(rd);
JSONObject json = new JSONObject(jsonText);
address = json.getJSONObject("information").getJSONArray("payment").getJSONObject(0).getString("address");
} catch (JSONException var53) {
var53.printStackTrace();
} catch (IOException var54) {
var54.printStackTrace();
} finally {
try {
is.close();
} catch (IOException var48) {
var48.printStackTrace();
}
} catch (IOException var47) {
var47.printStackTrace();

}
} else {
String[] splitBlock = block.split("\\.");
String mainBlock = splitBlock[0];
String collision = splitBlock[1];
InputStream is = null;

try {
is = (new URL(lookupServer + "/lookup/" + name + "/" + mainBlock + "/" + collision)).openStream();
} catch (IOException var52) {
var52.printStackTrace();
}

try {
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
String jsonText = org.bitcoinj.utils.JSONHelper.readJSONFile(rd);
JSONObject json = new JSONObject(jsonText);
address = json.getJSONObject("information").getJSONArray("payment").getJSONObject(0).getString("address");
} catch (JSONException var49) {
var49.printStackTrace();
} catch (IOException var50) {
var50.printStackTrace();
} finally {
try {
if (is != null) {
is.close();
}
} catch (IOException var47) {
var47.printStackTrace();
}
}
}
}

Expand Down

0 comments on commit 6349037

Please sign in to comment.