From 8ae7a24e2717b33eba75922677b7936871d7ec29 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Thu, 9 Jan 2020 06:34:32 +0100 Subject: [PATCH] Move print_key() from main.cpp to WIF module (named wif_print_key) --- src/WIF.cpp | 7 +++++++ src/WIF.h | 2 ++ src/main.cpp | 10 ++-------- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/WIF.cpp b/src/WIF.cpp index b25508a..ffa9fa8 100644 --- a/src/WIF.cpp +++ b/src/WIF.cpp @@ -21,6 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +#include #include #include "base58.h" #include "checksum.h" @@ -50,3 +51,9 @@ std::string wif_pub_encode(ec_pubkey_t pub) { return "EOS" + base58_encode(buf, buf + sizeof(buf)); } + +void wif_print_key(struct ec_keypair *key) { + + std::cout << "Private: " << wif_priv_encode(key->secret) << std::endl; + std::cout << "Public: " << wif_pub_encode(key->pub) << std::endl; +} diff --git a/src/WIF.h b/src/WIF.h index d3518b0..986949c 100644 --- a/src/WIF.h +++ b/src/WIF.h @@ -31,4 +31,6 @@ std::string wif_priv_encode(ec_privkey_t priv); std::string wif_pub_encode(ec_pubkey_t pub); +void wif_print_key(struct ec_keypair *key); + #endif /* WIF_H */ diff --git a/src/main.cpp b/src/main.cpp index 2e179e5..99e6ec5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,12 +29,6 @@ #include "WIF.h" #include "ec.h" -static void print_key(struct ec_keypair *key) { - - std::cout << "Private: " << wif_priv_encode(key->secret) << std::endl; - std::cout << "Public: " << wif_pub_encode(key->pub) << std::endl; -} - static void search(const char *words, size_t n) { size_t count = 0; @@ -57,7 +51,7 @@ static void search(const char *words, size_t n) { if (pubstr.find(word) != std::string::npos) { std::cout << "----" << std::endl; std::cout << "Found: " << word << std::endl; - print_key(&pair); + wif_print_key(&pair); count++; } } @@ -76,7 +70,7 @@ int main(int argc, char **argv) { } else { struct ec_keypair pair; ec_generate_key(&pair); - print_key(&pair); + wif_print_key(&pair); } return 0;