Skip to content

Commit

Permalink
Merge pull request #2 from kmels/release-0.14
Browse files Browse the repository at this point in the history
Remove bip47meta encryption
  • Loading branch information
Jimmy Morales committed Feb 13, 2018
2 parents c931219 + 5e2f643 commit 37bbf00
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions core/src/main/java/org/bitcoinj/wallet/bip47/Wallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,20 +275,21 @@ public void setBlockchainDownloadProgressTracker(BlockchainDownloadProgressTrack
/**
*
*/
public void loadBip47MetaData(Function<String,String> decryption) {
public void loadBip47MetaData() {
File file = new File(directory, getCoin().concat(".bip47"));
String encryptedJson;
String jsonString;
try {
encryptedJson = FileUtils.readFileToString(file, Charset.defaultCharset());
} catch (IOException e) {
e.printStackTrace();
jsonString = FileUtils.readFileToString(file, Charset.defaultCharset());
} catch (IOException e){
log.debug("Creating BIP47 wallet file at " + file.getAbsolutePath() + " ...");
saveBip47MetaData();
loadBip47MetaData();
return;
}

if (StringUtils.isEmpty(encryptedJson)) {
if (StringUtils.isEmpty(jsonString)) {
return;
}
String jsonString = decryption.apply(encryptedJson);

log.debug("loadBip47MetaData: "+jsonString);

Expand All @@ -302,18 +303,22 @@ public void loadBip47MetaData(Function<String,String> decryption) {
}
}

public synchronized void saveBip47MetaData(Function<String, String> encryption) {
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());

log.debug("saveBip47MetaData: "+json);

String encryptedJson = encryption.apply(json);

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

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

0 comments on commit 37bbf00

Please sign in to comment.