Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ETCM-202] Fix address derivation command #753

Merged
merged 1 commit into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/main/scala/io/iohk/ethereum/cli/CliCommands.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import cats.implicits._
import com.monovore.decline.{Command, Opts}
import io.iohk.ethereum.crypto
import io.iohk.ethereum.crypto._
import io.iohk.ethereum.domain.Address
import io.iohk.ethereum.utils.ByteStringUtils
import java.security.SecureRandom
import org.bouncycastle.util.encoders.Hex
Expand Down Expand Up @@ -62,8 +63,9 @@ object CliCommands {

private def privKeyToAddress(privKey: Array[Byte]): String = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be now Address.fromPrivateKey?

val pubKey = pubKeyFromPrvKey(privKey)
val address = crypto.kec256(pubKey)
Hex.toHexString(address)
val address = Address(crypto.kec256(pubKey))

address.toUnprefixedString
}

val api: Command[String] = Command.apply(name = "cli", header = "Mantis CLI") {
Expand Down
6 changes: 3 additions & 3 deletions src/test/scala/io/iohk/ethereum/cli/CliCommandsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ object Fixture {
val privateKey2 = "00b11c32957057651d56cd83085ef3b259319057e0e887bd0fdaee657e6f75d1"
val privateKey3 = "00b11c32957057651d56cd83085ef3b259319057e0e887bd0fdaee657e6f75d2"

val address = "8b196738d90cf3d9fc299e0ec28e15ebdcbb0bdcb281d9d5084182c9c66d5d12"
val address2 = "add8c627e14480b36b30811758240d8acb282aae883043990d8a2d7e2e75cf3b"
val address3 = "1e9cd60cf3b2c902e60f809e604542f9a9fb55d3e8004ff122f662f88eb32b4a"
val address = "c28e15ebdcbb0bdcb281d9d5084182c9c66d5d12"
val address2 = "58240d8acb282aae883043990d8a2d7e2e75cf3b"
val address3 = "604542f9a9fb55d3e8004ff122f662f88eb32b4a"

val requestedBalance = 42

Expand Down