Skip to content

Commit

Permalink
Merge pull request #996 from ergoplatform/i995
Browse files Browse the repository at this point in the history
Fixing #995: testMnemonic now checked during wallet init or restore
  • Loading branch information
kushti committed Dec 16, 2019
2 parents 9157512 + 79936b0 commit 4c64c0d
Showing 1 changed file with 5 additions and 3 deletions.
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 4c64c0d

Please sign in to comment.