mirror of
https://github.com/eosswedenorg/libantelope
synced 2026-06-16 03:34:56 +02:00
include/libeosio/WIF.hpp: add wif_codec_t struct and related functions/constants.
This commit is contained in:
parent
86d75df2ec
commit
18f35c66b5
2 changed files with 20 additions and 0 deletions
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue