Skip to content

Commit 69932a3

Browse files
author
Michał Mrożek
authored
Merge pull request #753 from input-output-hk/etcm-202-mantis-cli
[ETCM-202] Fix address derivation command
2 parents 18c25a4 + 3bd4818 commit 69932a3

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/main/scala/io/iohk/ethereum/cli/CliCommands.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import cats.implicits._
44
import com.monovore.decline.{Command, Opts}
55
import io.iohk.ethereum.crypto
66
import io.iohk.ethereum.crypto._
7+
import io.iohk.ethereum.domain.Address
78
import io.iohk.ethereum.utils.ByteStringUtils
89
import java.security.SecureRandom
910
import org.bouncycastle.util.encoders.Hex
@@ -62,8 +63,9 @@ object CliCommands {
6263

6364
private def privKeyToAddress(privKey: Array[Byte]): String = {
6465
val pubKey = pubKeyFromPrvKey(privKey)
65-
val address = crypto.kec256(pubKey)
66-
Hex.toHexString(address)
66+
val address = Address(crypto.kec256(pubKey))
67+
68+
address.toUnprefixedString
6769
}
6870

6971
val api: Command[String] = Command.apply(name = "cli", header = "Mantis CLI") {

src/test/scala/io/iohk/ethereum/cli/CliCommandsSpec.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ object Fixture {
9090
val privateKey2 = "00b11c32957057651d56cd83085ef3b259319057e0e887bd0fdaee657e6f75d1"
9191
val privateKey3 = "00b11c32957057651d56cd83085ef3b259319057e0e887bd0fdaee657e6f75d2"
9292

93-
val address = "8b196738d90cf3d9fc299e0ec28e15ebdcbb0bdcb281d9d5084182c9c66d5d12"
94-
val address2 = "add8c627e14480b36b30811758240d8acb282aae883043990d8a2d7e2e75cf3b"
95-
val address3 = "1e9cd60cf3b2c902e60f809e604542f9a9fb55d3e8004ff122f662f88eb32b4a"
93+
val address = "c28e15ebdcbb0bdcb281d9d5084182c9c66d5d12"
94+
val address2 = "58240d8acb282aae883043990d8a2d7e2e75cf3b"
95+
val address3 = "604542f9a9fb55d3e8004ff122f662f88eb32b4a"
9696

9797
val requestedBalance = 42
9898

0 commit comments

Comments
 (0)