diff --git a/src/NewcoinAddress.cpp b/src/NewcoinAddress.cpp index 96b65f918..6dc0479de 100644 --- a/src/NewcoinAddress.cpp +++ b/src/NewcoinAddress.cpp @@ -2,6 +2,7 @@ #include "key.h" #include "Config.h" #include "BitcoinUtil.h" +#include "rfc1751.h" #include "openssl/rand.h" @@ -438,6 +439,30 @@ BIGNUM* NewcoinAddress::getFamilyPrivateKey() const return ret; } +std::string NewcoinAddress::humanFamilySeed1751() const +{ + switch (nVersion) { + case VER_NONE: + throw std::runtime_error("unset source"); + + case VER_FAMILY_SEED: + { + std::string strHuman; + std::string strKey; + uint128 uSeed = getFamilySeed(); + + strKey.assign(uSeed.begin(), uSeed.end()); + + key2eng(strHuman, strKey); + + return strHuman; + } + + default: + throw std::runtime_error("bad source"); + } +} + std::string NewcoinAddress::humanFamilySeed() const { switch (nVersion) { @@ -452,6 +477,22 @@ std::string NewcoinAddress::humanFamilySeed() const } } +int NewcoinAddress::setFamilySeed1751(const std::string& strHuman1751) +{ + std::string strKey; + int iResult = eng2key(strKey, strHuman1751); + + if (1 == iResult) + { + std::vector vch(strKey.begin(), strKey.end()); + uint128 uSeed(vch); + + setFamilySeed(uSeed); + } + + return iResult; +} + bool NewcoinAddress::setFamilySeed(const std::string& strSeed) { return SetString(strSeed.c_str(), VER_FAMILY_SEED); diff --git a/src/NewcoinAddress.h b/src/NewcoinAddress.h index 9ca8ebc0f..c98568c6e 100644 --- a/src/NewcoinAddress.h +++ b/src/NewcoinAddress.h @@ -112,8 +112,10 @@ public: BIGNUM* getFamilyPrivateKey() const; std::string humanFamilySeed() const; + std::string humanFamilySeed1751() const; bool setFamilySeed(const std::string& strSeed); + int setFamilySeed1751(const std::string& strHuman1751); void setFamilySeed(uint128 hash128); void setFamilySeedRandom(); };