Fixed bugs in wallet initialization

This commit is contained in:
CalDescent 2022-05-08 08:24:54 +01:00
parent fa4679dcc4
commit bbf7193c51
2 changed files with 9 additions and 2 deletions

View File

@ -106,6 +106,9 @@ public class PirateChainWalletController extends Thread {
try { try {
this.currentWallet = new PirateWallet(entropyBytes); this.currentWallet = new PirateWallet(entropyBytes);
if (!this.currentWallet.isReady()) {
this.currentWallet = null;
}
return true; return true;
} catch (IOException e) { } catch (IOException e) {
LOGGER.info("Unable to initialize wallet: {}", e.getMessage()); LOGGER.info("Unable to initialize wallet: {}", e.getMessage());

View File

@ -78,8 +78,8 @@ public class PirateWallet {
String outputSeedResponse = LiteWalletJni.initfromseed(SERVER_URI, this.params, inputSeedPhrase, "1886500", this.saplingOutput64, this.saplingSpend64); // Thread-safe. String outputSeedResponse = LiteWalletJni.initfromseed(SERVER_URI, this.params, inputSeedPhrase, "1886500", this.saplingOutput64, this.saplingSpend64); // Thread-safe.
JSONObject outputSeedJson = new JSONObject(outputSeedResponse); JSONObject outputSeedJson = new JSONObject(outputSeedResponse);
String outputSeedPhrase = null; String outputSeedPhrase = null;
if (outputSeedJson.has("seedPhrase")) { if (outputSeedJson.has("seed")) {
outputSeedJson.getString("seedPhrase"); outputSeedPhrase = outputSeedJson.getString("seed");
} }
// Ensure seed phrase in response matches supplied seed phrase // Ensure seed phrase in response matches supplied seed phrase
@ -104,6 +104,10 @@ public class PirateWallet {
return false; return false;
} }
public boolean isReady() {
return this.ready;
}
public void setReady(boolean ready) { public void setReady(boolean ready) {
this.ready = ready; this.ready = ready;
} }