mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add rfc1751 support to NewcoinAddress.
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
#include "key.h"
|
#include "key.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "BitcoinUtil.h"
|
#include "BitcoinUtil.h"
|
||||||
|
#include "rfc1751.h"
|
||||||
|
|
||||||
#include "openssl/rand.h"
|
#include "openssl/rand.h"
|
||||||
|
|
||||||
@@ -438,6 +439,30 @@ BIGNUM* NewcoinAddress::getFamilyPrivateKey() const
|
|||||||
return ret;
|
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
|
std::string NewcoinAddress::humanFamilySeed() const
|
||||||
{
|
{
|
||||||
switch (nVersion) {
|
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<unsigned char> vch(strKey.begin(), strKey.end());
|
||||||
|
uint128 uSeed(vch);
|
||||||
|
|
||||||
|
setFamilySeed(uSeed);
|
||||||
|
}
|
||||||
|
|
||||||
|
return iResult;
|
||||||
|
}
|
||||||
|
|
||||||
bool NewcoinAddress::setFamilySeed(const std::string& strSeed)
|
bool NewcoinAddress::setFamilySeed(const std::string& strSeed)
|
||||||
{
|
{
|
||||||
return SetString(strSeed.c_str(), VER_FAMILY_SEED);
|
return SetString(strSeed.c_str(), VER_FAMILY_SEED);
|
||||||
|
|||||||
@@ -112,8 +112,10 @@ public:
|
|||||||
BIGNUM* getFamilyPrivateKey() const;
|
BIGNUM* getFamilyPrivateKey() const;
|
||||||
|
|
||||||
std::string humanFamilySeed() const;
|
std::string humanFamilySeed() const;
|
||||||
|
std::string humanFamilySeed1751() const;
|
||||||
|
|
||||||
bool setFamilySeed(const std::string& strSeed);
|
bool setFamilySeed(const std::string& strSeed);
|
||||||
|
int setFamilySeed1751(const std::string& strHuman1751);
|
||||||
void setFamilySeed(uint128 hash128);
|
void setFamilySeed(uint128 hash128);
|
||||||
void setFamilySeedRandom();
|
void setFamilySeedRandom();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user