Skip to content

Commit 591aa68

Browse files
author
lemastero
committed
remove daedalus_changePassphrase
1 parent 2ea284b commit 591aa68

File tree

7 files changed

+1
-99
lines changed

7 files changed

+1
-99
lines changed

src/main/scala/io/iohk/ethereum/jsonrpc/JsonMethodsImplicits.scala

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -308,19 +308,4 @@ object JsonMethodsImplicits extends JsonMethodsImplicits {
308308
def encodeJson(t: LockAccountResponse): JValue =
309309
JBool(t.result)
310310
}
311-
312-
implicit val daedalus_changePassphrase = new Codec[ChangePassphraseRequest, ChangePassphraseResponse] {
313-
def decodeJson(params: Option[JArray]): Either[JsonRpcError, ChangePassphraseRequest] = {
314-
params match {
315-
case Some(JArray(JString(addr) :: JString(oldPassphrase) :: JString(newPassphrase) :: _)) =>
316-
extractAddress(addr).map(a => ChangePassphraseRequest(a, oldPassphrase, newPassphrase))
317-
case _ =>
318-
Left(InvalidParams())
319-
}
320-
}
321-
322-
def encodeJson(t: ChangePassphraseResponse): JValue =
323-
JString("")
324-
}
325-
326311
}

src/main/scala/io/iohk/ethereum/jsonrpc/JsonRpcController.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,6 @@ class JsonRpcController(
327327
private def handleDaedalusRequest: PartialFunction[JsonRpcRequest, Future[JsonRpcResponse]] = {
328328
case req @ JsonRpcRequest(_, "daedalus_getAccountTransactions", _, _) =>
329329
handle[GetAccountTransactionsRequest, GetAccountTransactionsResponse](ethService.getAccountTransactions, req)
330-
331-
case req @ JsonRpcRequest(_, "daedalus_changePassphrase", _, _) =>
332-
handle[ChangePassphraseRequest, ChangePassphraseResponse](personalService.changePassphrase, req)
333330
}
334331

335332
private def handleQARequest: PartialFunction[JsonRpcRequest, Future[JsonRpcResponse]] = {
@@ -399,5 +396,4 @@ class JsonRpcController(
399396

400397
private def errorResponse[T](req: JsonRpcRequest, error: JsonRpcError): JsonRpcResponse =
401398
JsonRpcResponse(req.jsonrpc, None, Some(error), req.id.getOrElse(0))
402-
403399
}

src/main/scala/io/iohk/ethereum/jsonrpc/PersonalService.scala

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ object PersonalService {
5555
case class EcRecoverRequest(message: ByteString, signature: ECDSASignature)
5656
case class EcRecoverResponse(address: Address)
5757

58-
case class ChangePassphraseRequest(address: Address, oldPassphrase: String, newPassphrase: String)
59-
case class ChangePassphraseResponse()
60-
6158
val InvalidKey = InvalidParams("Invalid key provided, expected 32 bytes (64 hex digits)")
6259
val InvalidAddress = InvalidParams("Invalid address, expected 20 bytes (40 hex digits)")
6360
val InvalidPassphrase = LogicError("Could not decrypt key with given passphrase")
@@ -178,13 +175,6 @@ class PersonalService(
178175
}
179176
}
180177

181-
def changePassphrase(request: ChangePassphraseRequest): ServiceResponse[ChangePassphraseResponse] = Future {
182-
import request._
183-
keyStore.changePassphrase(address, oldPassphrase, newPassphrase)
184-
.map(_ => ChangePassphraseResponse())
185-
.left.map(handleError)
186-
}
187-
188178
private def sendTransaction(request: TransactionRequest, wallet: Wallet): Future[ByteString] = {
189179
implicit val timeout = Timeout(txPoolConfig.pendingTxManagerQueryTimeout)
190180

src/main/scala/io/iohk/ethereum/keystore/KeyStore.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ trait KeyStore {
3535
def listAccounts(): Either[KeyStoreError, List[Address]]
3636

3737
def unlockAccount(address: Address, passphrase: String): Either[KeyStoreError, Wallet]
38-
39-
def changePassphrase(address: Address, oldPassphrase: String, newPassphrase: String): Either[KeyStoreError, Unit]
4038
}
4139

4240
class KeyStoreImpl(keyStoreConfig: KeyStoreConfig, secureRandom: SecureRandom) extends KeyStore with Logger {

src/test/scala/io/iohk/ethereum/jsonrpc/JsonRpcControllerSpec.scala

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -573,25 +573,6 @@ class JsonRpcControllerSpec
573573
response.result shouldBe Some(JArray(peers.map(info => JString(info.toString))))
574574
}
575575

576-
it should "daedalus_changePassphrase" in new TestSetup {
577-
val address = Address(42)
578-
val oldPassphrase = "weakpass"
579-
val newPassphrase = "very5tr0ng&l0ngp4s5phr4s3"
580-
val params = JArray(JString(address.toString) :: JString(oldPassphrase) :: JString(newPassphrase) :: Nil)
581-
582-
(personalService.changePassphrase _)
583-
.expects(ChangePassphraseRequest(address, oldPassphrase, newPassphrase))
584-
.returning(Future.successful(Right(ChangePassphraseResponse())))
585-
586-
val rpcRequest = JsonRpcRequest("2.0", "daedalus_changePassphrase", Some(params), Some(1))
587-
val response = jsonRpcController.handleRequest(rpcRequest).futureValue
588-
589-
response.jsonrpc shouldBe "2.0"
590-
response.id shouldBe JInt(1)
591-
response.error shouldBe None
592-
response.result shouldBe Some(JString(""))
593-
}
594-
595576
it should "eth_sendTransaction" in new TestSetup {
596577
val params = JArray(
597578
JObject(

src/test/scala/io/iohk/ethereum/jsonrpc/PersonalServiceSpec.scala

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import io.iohk.ethereum.db.storage.AppStateStorage
1111
import io.iohk.ethereum.domain.{UInt256, _}
1212
import io.iohk.ethereum.jsonrpc.JsonRpcErrors._
1313
import io.iohk.ethereum.jsonrpc.PersonalService._
14-
import io.iohk.ethereum.keystore.KeyStore.{DecryptionFailed, IOError, KeyStoreError}
14+
import io.iohk.ethereum.keystore.KeyStore.{DecryptionFailed, IOError}
1515
import io.iohk.ethereum.keystore.{KeyStore, Wallet}
1616
import io.iohk.ethereum.transactions.PendingTransactionsManager._
1717
import io.iohk.ethereum.utils.{BlockchainConfig, MonetaryPolicyConfig, TxPoolConfig}
@@ -390,30 +390,6 @@ class PersonalServiceSpec
390390
}
391391
}
392392

393-
it should "handle changing passwords" in new TestSetup {
394-
type KeyStoreRes = Either[KeyStoreError, Unit]
395-
type ServiceRes = Either[JsonRpcError, ChangePassphraseResponse]
396-
397-
val table = Table[KeyStoreRes, ServiceRes](
398-
("keyStoreResult", "serviceResult"),
399-
(Right(()), Right(ChangePassphraseResponse())),
400-
(Left(KeyStore.KeyNotFound), Left(KeyNotFound)),
401-
(Left(KeyStore.DecryptionFailed), Left(InvalidPassphrase))
402-
)
403-
404-
val request = ChangePassphraseRequest(address, "weakpass", "very5tr0ng&l0ngp4s5phr4s3")
405-
406-
forAll(table) { (keyStoreResult, serviceResult) =>
407-
(keyStore.changePassphrase _)
408-
.expects(address, request.oldPassphrase, request.newPassphrase)
409-
.returning(keyStoreResult)
410-
411-
val result = personal.changePassphrase(request).futureValue
412-
result shouldEqual serviceResult
413-
}
414-
415-
}
416-
417393
trait TestSetup {
418394
val prvKey = ByteString(Hex.decode("7a44789ed3cd85861c0bbf9693c7e1de1862dd4396c390147ecf1275099c6e6f"))
419395
val address = Address(Hex.decode("aa6826f00d01fe4085f0c3dd12778e206ce4e2ac"))

src/test/scala/io/iohk/ethereum/keystore/KeyStoreImplSpec.scala

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -128,30 +128,6 @@ class KeyStoreImplSpec extends AnyFlatSpec with Matchers with BeforeAndAfter wit
128128
res shouldEqual Left(KeyNotFound)
129129
}
130130

131-
it should "change passphrase of an existing wallet" in new TestSetup {
132-
val oldPassphrase = "weakpass"
133-
val newPassphrase = "very5tr0ng&l0ngp4s5phr4s3"
134-
135-
keyStore.importPrivateKey(key1, oldPassphrase)
136-
keyStore.changePassphrase(addr1, oldPassphrase, newPassphrase) shouldEqual Right(())
137-
138-
keyStore.unlockAccount(addr1, newPassphrase) shouldEqual Right(Wallet(addr1, key1))
139-
}
140-
141-
it should "return an error when changing passphrase of an non-existent wallet" in new TestSetup {
142-
keyStore.changePassphrase(addr1, "oldpass", "newpasss") shouldEqual Left(KeyNotFound)
143-
}
144-
145-
it should "return an error when changing passphrase and provided with invalid old passphrase" in new TestSetup {
146-
keyStore.importPrivateKey(key1, "oldpasss")
147-
keyStore.changePassphrase(addr1, "wrongpass", "newpasss") shouldEqual Left(DecryptionFailed)
148-
}
149-
150-
it should "return an error when changing passphrase and provided with too short new passphrase" in new TestSetup {
151-
keyStore.importPrivateKey(key1, "oldpass")
152-
keyStore.changePassphrase(addr1, "wrongpass", "newpass") shouldEqual Left(PassPhraseTooShort(keyStoreConfig.minimalPassphraseLength))
153-
}
154-
155131
trait TestSetup {
156132
val keyStoreConfig = KeyStoreConfig(Config.config)
157133

0 commit comments

Comments
 (0)