diff --git a/include/libeosio/WIF.hpp b/include/libeosio/WIF.hpp index 767da80..2978c88 100644 --- a/include/libeosio/WIF.hpp +++ b/include/libeosio/WIF.hpp @@ -38,6 +38,23 @@ extern const std::string WIF_PVT_LEG; extern const std::string WIF_PVT_K1; extern const std::string WIF_SIG_K1; +/** + * Codecs + */ + +// A WIF Codec is an public and private key prefix pair. +typedef struct { + std::string pub; + std::string pvt; +} wif_codec_t; + +extern const wif_codec_t WIF_CODEC_K1; +extern const wif_codec_t WIF_CODEC_LEG; + +inline wif_codec_t wif_create_legacy_codec(const std::string& pub_prefix) { + return { pub_prefix, WIF_PVT_LEG }; +} + /** * Encode an EC private key to WIF String. */ diff --git a/src/WIF.cpp b/src/WIF.cpp index 9d8712d..7de1c6b 100644 --- a/src/WIF.cpp +++ b/src/WIF.cpp @@ -36,6 +36,9 @@ const std::string WIF_PVT_LEG = ""; const std::string WIF_PVT_K1 = "PVT_K1_"; const std::string WIF_SIG_K1 = "SIG_K1_"; +const wif_codec_t WIF_CODEC_K1 = { WIF_PUB_K1, WIF_PVT_K1 }; +const wif_codec_t WIF_CODEC_LEG = wif_create_legacy_codec(WIF_PUB_LEG); + std::string wif_priv_encode(const ec_privkey_t& priv, const std::string& prefix) { checksum_t check;