Skip to content

Commit

Permalink
close #995 : the bug with testMnemonic check is fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Dec 16, 2019
1 parent 9157512 commit 79936b0
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class ErgoWalletActor(settings: ErgoSettings, boxSelector: BoxSelector)
}

private def walletCommands: Receive = {
case InitWallet(pass, mnemonicPassOpt) if secretStorageOpt.isEmpty =>
case InitWallet(pass, mnemonicPassOpt) if secretStorageOpt.isEmpty && walletSettings.testMnemonic.isEmpty =>
//Read high-quality random bits from Java's SecureRandom
val entropy = scorex.utils.Random.randomBytes(settings.walletSettings.seedStrengthBits / 8)
val mnemonicTry = new Mnemonic(walletSettings.mnemonicPhraseLanguage, walletSettings.seedStrengthBits)
Expand All @@ -202,7 +202,9 @@ class ErgoWalletActor(settings: ErgoSettings, boxSelector: BoxSelector)
self ! UnlockWallet(pass)
log.info("Wallet is initialized")

case RestoreWallet(mnemonic, passOpt, encryptionPass) if secretStorageOpt.isEmpty =>
case RestoreWallet(mnemonic, passOpt, encryptionPass)
if secretStorageOpt.isEmpty && walletSettings.testMnemonic.isEmpty =>

val secretStorage = JsonSecretStorage
.restore(mnemonic, passOpt, encryptionPass)(settings.walletSettings.secretStorage)
secretStorageOpt = Some(secretStorage)
Expand All @@ -211,7 +213,7 @@ class ErgoWalletActor(settings: ErgoSettings, boxSelector: BoxSelector)
log.info("Wallet is restored")

case _: RestoreWallet | _: InitWallet =>
sender() ! Failure(new Exception("Wallet is already initialized. Clear keystore to re-init it."))
sender() ! Failure(new Exception("Wallet is already initialized or testMnemonic is set. Clear current secret to re-init it."))

case UnlockWallet(pass) =>
secretStorageOpt match {
Expand Down

0 comments on commit 79936b0

Please sign in to comment.