Skip to content

Commit

Permalink
Avoid exception when loading bip47 for the first time by saving the b…
Browse files Browse the repository at this point in the history
…ip47 file first.
  • Loading branch information
kmels committed Feb 13, 2018
1 parent cb6e2a6 commit 5e2f643
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions core/src/main/java/org/bitcoinj/wallet/bip47/Wallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,10 @@ public void loadBip47MetaData() {
String jsonString;
try {
jsonString = FileUtils.readFileToString(file, Charset.defaultCharset());
} catch (IOException e) {
e.printStackTrace();
} catch (IOException e){
log.debug("Creating BIP47 wallet file at " + file.getAbsolutePath() + " ...");
saveBip47MetaData();
loadBip47MetaData();
return;
}

Expand All @@ -302,6 +304,12 @@ public void loadBip47MetaData() {
}

public synchronized void saveBip47MetaData() {
try {
vWallet.saveToFile(vWalletFile);
} catch (IOException io){
log.error("Failed to save wallet file",io);
}

Gson gson = new GsonBuilder().setPrettyPrinting().create();
String json = gson.toJson(bip47MetaData.values());

Expand Down

0 comments on commit 5e2f643

Please sign in to comment.