Skip to content

Commit

Permalink
Fix BIP47 UTXO processing
Browse files Browse the repository at this point in the history
  • Loading branch information
pokkst committed Jun 28, 2020
1 parent 25b8657 commit f9f77fb
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions core/src/main/java/org/bitcoinj/kits/BIP47AppKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ private void completeSetupOfWallet() {
this.grabNotificationAddressUtxos(notifAsCashAddr);
}

private String[] apiServersAddress = new String[] {"https://insomnia.fountainhead.cash/v1/address/utxos/", "http://rest.bitcoin.com/v2/address/utxo/"};
private String[] apiServersTx = new String[] {"https://insomnia.fountainhead.cash/v1/tx/data/", "http://rest.bitcoin.com/v2/rawtransactions/getRawTransaction/"};
private String[] apiServersAddress = new String[] {"http://rest.bitcoin.com/v2/address/utxo/"};
private String[] apiServersTx = new String[] {"http://rest.bitcoin.com/v2/rawtransactions/getRawTransaction/"};

private void grabNotificationAddressUtxos(final String cashAddr) {
new Thread() {
Expand Down Expand Up @@ -219,7 +219,12 @@ public void run() {

private void grabTransactionAndProcessNotificationTransaction(String txid) {
String randApiServer = apiServersTx[new Random().nextInt(apiServersTx.length)];
JSONObject txJson = getJSONObject(randApiServer + txid);
String url = randApiServer + txid;

if(randApiServer.contains("rest.bitcoin.com")) {
url += "?verbose=true";
}
JSONObject txJson = getJSONObject(url);
if(txJson != null) {
try {
String txHexVariable = "";
Expand Down Expand Up @@ -443,8 +448,6 @@ public boolean loadBip47MetaData() {
return false;
}

System.out.println("loadBip47MetaData: " + jsonString);

return importBip47MetaData(jsonString);
}

Expand All @@ -470,8 +473,6 @@ public String readBip47MetaDataFile() {
* <p>Load channels from json. Return true if any payment code was loaded. </p>
*/
public boolean importBip47MetaData(String jsonString) {
System.out.println("loadBip47MetaData: " + jsonString);

Gson gson = new Gson();
Type collectionType = new TypeToken<Collection<BIP47Channel>>() {
}.getType();
Expand Down Expand Up @@ -501,13 +502,10 @@ public synchronized void saveBip47MetaData() {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String json = gson.toJson(bip47MetaData.values());

System.out.println("saveBip47MetaData: " + json);

File file = new File(directory, this.vWalletFileName.concat(".bip47"));

try {
FileUtils.writeStringToFile(file, json, Charset.defaultCharset(), false);
System.out.println("saveBip47MetaData: saved");
} catch (IOException e) {
e.printStackTrace();
}
Expand Down

0 comments on commit f9f77fb

Please sign in to comment.