From 81a95bad2ec7771c833e2565cddf6dd06eb14b06 Mon Sep 17 00:00:00 2001 From: canonbrother Date: Tue, 6 Jun 2023 16:00:27 +0800 Subject: [PATCH] fix eth checksum addr (#2028) --- src/ffi/ffiexports.cpp | 4 ++-- src/key_io.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ffi/ffiexports.cpp b/src/ffi/ffiexports.cpp index 79bc41903f6..994bdd0dd7d 100644 --- a/src/ffi/ffiexports.cpp +++ b/src/ffi/ffiexports.cpp @@ -182,9 +182,9 @@ uint64_t getMinRelayTxFee() { } std::array getEthPrivKey(std::array keyID) { + CKey ethPrivKey; + const auto ethKeyID = CKeyID{uint160{std::vector(keyID.begin(), keyID.end())}}; for (const auto &wallet : GetWallets()) { - const auto ethKeyID = CKeyID{uint160{std::vector(keyID.begin(), keyID.end())}}; - CKey ethPrivKey; if (wallet->GetEthKey(ethKeyID, ethPrivKey)) { std::array privKeyArray{}; std::copy(ethPrivKey.begin(), ethPrivKey.end(), privKeyArray.begin()); diff --git a/src/key_io.cpp b/src/key_io.cpp index 16181cb9b9e..2f98dd5a6c9 100644 --- a/src/key_io.cpp +++ b/src/key_io.cpp @@ -63,7 +63,7 @@ class DestinationEncoder { // Raw addr = ETH_ADDR_PREFIX + HexStr(id); // Produce ETH checksum address: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md - const auto address = id.ToString(); + const auto address = HexStr(id); std::vector input(address.begin(), address.end()); std::vector output; sha3(input, output);