Merge branch 'master' of github.com:jedmccaleb/NewCoin

Conflicts:
	src/RPCServer.cpp
This commit is contained in:
jed
2012-06-14 16:54:08 -07:00
32 changed files with 120 additions and 16938 deletions

View File

@@ -13,7 +13,7 @@
#include "key.h"
#include "utils.h"
#include "TaggedCache.h"
#include "boost/filesystem.hpp"
#include "boost/filesystem.hpp"
Application* theApp = NULL;
@@ -102,17 +102,12 @@ void Application::run()
mConnectionPool.start();
// New stuff.
NewcoinAddress rootSeedMaster;
NewcoinAddress rootAddress;
rootSeedMaster.setFamilySeed(CKey::PassPhraseToKey("masterpassphrase"));
NewcoinAddress rootSeedMaster = NewcoinAddress::createSeedGeneric("masterpassphrase");
NewcoinAddress rootGeneratorMaster = NewcoinAddress::createGeneratorPublic(rootSeedMaster);
rootAddress.setAccountPublic(rootGeneratorMaster, 0);
NewcoinAddress rootAddress = NewcoinAddress::createAccountPublic(rootGeneratorMaster, 0);
// Print enough information to be able to claim root account.
std::cerr << "Root master seed: " << rootSeedMaster.humanFamilySeed() << std::endl;
std::cerr << "Root master seed: " << rootSeedMaster.humanSeed() << std::endl;
std::cerr << "Root account: " << rootAddress.humanAccountID() << std::endl;
Ledger::pointer firstLedger = boost::make_shared<Ledger>(rootAddress, SYSTEM_CURRENCY_START);
@@ -132,7 +127,6 @@ void Application::run()
// temporary
mIOService.run(); // This blocks
//BOOST_LOG_TRIVIAL(info) << "Done.";
std::cout << "Done." << std::endl;
}

View File

@@ -180,7 +180,7 @@ void Config::load()
RPC_ALLOW_REMOTE = boost::lexical_cast<bool>(strTemp);
if (sectionSingleB(secConfig, SECTION_VALIDATION_SEED, strTemp))
VALIDATION_SEED.setFamilySeedGeneric(strTemp);
VALIDATION_SEED.setSeedGeneric(strTemp);
(void) sectionSingleB(secConfig, SECTION_PEER_SSL_CIPHER_LIST, PEER_SSL_CIPHER_LIST);
if (sectionSingleB(secConfig, SECTION_PEER_SCAN_INTERVAL_MIN, strTemp))

View File

@@ -158,7 +158,7 @@ static BIGNUM* makeHash(const NewcoinAddress& pubGen, int seq, BIGNUM* order)
do
{
Serializer s((33*8+32+32)/8);
s.addRaw(pubGen.getFamilyGenerator());
s.addRaw(pubGen.getGenerator());
s.add32(seq);
s.add32(subSeq++);
uint256 root=s.getSHA512Half();
@@ -173,7 +173,7 @@ static BIGNUM* makeHash(const NewcoinAddress& pubGen, int seq, BIGNUM* order)
// --> public generator
EC_KEY* CKey::GeneratePublicDeterministicKey(const NewcoinAddress& pubGen, int seq)
{ // publicKey(n) = rootPublicKey EC_POINT_+ Hash(pubHash|seq)*point
EC_KEY* rootKey = CKey::GenerateRootPubKey(pubGen.getFamilyGeneratorBN());
EC_KEY* rootKey = CKey::GenerateRootPubKey(pubGen.getGeneratorBN());
const EC_POINT* rootPubKey = EC_KEY_get0_public_key(rootKey);
BN_CTX* ctx = BN_CTX_new();
EC_KEY* pkey = EC_KEY_new_by_curve_name(NID_secp256k1);

View File

@@ -60,7 +60,7 @@ void NewcoinAddress::clear()
NewcoinAddress NewcoinAddress::createNodePublic(const NewcoinAddress& naSeed)
{
CKey ckSeed(naSeed.getFamilySeed());
CKey ckSeed(naSeed.getSeed());
NewcoinAddress naNew;
// YYY Should there be a GetPubKey() equiv that returns a uint256?
@@ -163,7 +163,7 @@ NewcoinAddress NewcoinAddress::createNodePrivate(const NewcoinAddress& naSeed)
{
uint256 uPrivKey;
NewcoinAddress naNew;
CKey ckSeed(naSeed.getFamilySeed());
CKey ckSeed(naSeed.getSeed());
ckSeed.GetPrivateKeyU(uPrivKey);
@@ -445,8 +445,8 @@ void NewcoinAddress::setAccountPrivate(uint256 hash256)
void NewcoinAddress::setAccountPrivate(const NewcoinAddress& naGenerator, const NewcoinAddress& naSeed, int seq)
{
CKey pubkey = CKey(naSeed.getFamilySeed());
CKey ckPrivkey = CKey(naGenerator, pubkey.GetSecretBN(), seq);
CKey ckPubkey = CKey(naSeed.getSeed());
CKey ckPrivkey = CKey(naGenerator, ckPubkey.GetSecretBN(), seq);
uint256 uPrivKey;
ckPrivkey.GetPrivateKeyU(uPrivKey);
@@ -557,10 +557,10 @@ std::vector<unsigned char> NewcoinAddress::accountPrivateDecrypt(const NewcoinAd
}
//
// Family Generators
// Generators
//
BIGNUM* NewcoinAddress::getFamilyGeneratorBN() const
BIGNUM* NewcoinAddress::getGeneratorBN() const
{ // returns the public generator
switch (nVersion) {
case VER_NONE:
@@ -579,7 +579,7 @@ BIGNUM* NewcoinAddress::getFamilyGeneratorBN() const
return ret;
}
const std::vector<unsigned char>& NewcoinAddress::getFamilyGenerator() const
const std::vector<unsigned char>& NewcoinAddress::getGenerator() const
{ // returns the public generator
switch (nVersion) {
case VER_NONE:
@@ -594,7 +594,7 @@ const std::vector<unsigned char>& NewcoinAddress::getFamilyGenerator() const
}
}
std::string NewcoinAddress::humanFamilyGenerator() const
std::string NewcoinAddress::humanGenerator() const
{
switch (nVersion) {
case VER_NONE:
@@ -608,31 +608,31 @@ std::string NewcoinAddress::humanFamilyGenerator() const
}
}
bool NewcoinAddress::setFamilyGenerator(const std::string& strGenerator)
bool NewcoinAddress::setGenerator(const std::string& strGenerator)
{
return SetString(strGenerator.c_str(), VER_FAMILY_GENERATOR);
}
void NewcoinAddress::setFamilyGenerator(const std::vector<unsigned char>& vPublic)
void NewcoinAddress::setGenerator(const std::vector<unsigned char>& vPublic)
{
SetData(VER_FAMILY_GENERATOR, vPublic);
}
NewcoinAddress NewcoinAddress::createGeneratorPublic(const NewcoinAddress& naSeed)
{
CKey ckSeed(naSeed.getFamilySeed());
CKey ckSeed(naSeed.getSeed());
NewcoinAddress naNew;
naNew.setFamilyGenerator(ckSeed.GetPubKey());
naNew.setGenerator(ckSeed.GetPubKey());
return naNew;
}
//
// Family Seed
// Seed
//
uint128 NewcoinAddress::getFamilySeed() const
uint128 NewcoinAddress::getSeed() const
{
switch (nVersion) {
case VER_NONE:
@@ -646,7 +646,7 @@ uint128 NewcoinAddress::getFamilySeed() const
}
}
std::string NewcoinAddress::humanFamilySeed1751() const
std::string NewcoinAddress::humanSeed1751() const
{
switch (nVersion) {
case VER_NONE:
@@ -657,7 +657,7 @@ std::string NewcoinAddress::humanFamilySeed1751() const
std::string strHuman;
std::string strLittle;
std::string strBig;
uint128 uSeed = getFamilySeed();
uint128 uSeed = getSeed();
strLittle.assign(uSeed.begin(), uSeed.end());
@@ -673,7 +673,7 @@ std::string NewcoinAddress::humanFamilySeed1751() const
}
}
std::string NewcoinAddress::humanFamilySeed() const
std::string NewcoinAddress::humanSeed() const
{
switch (nVersion) {
case VER_NONE:
@@ -687,7 +687,7 @@ std::string NewcoinAddress::humanFamilySeed() const
}
}
int NewcoinAddress::setFamilySeed1751(const std::string& strHuman1751)
int NewcoinAddress::setSeed1751(const std::string& strHuman1751)
{
std::string strKey;
int iResult = eng2key(strKey, strHuman1751);
@@ -697,18 +697,18 @@ int NewcoinAddress::setFamilySeed1751(const std::string& strHuman1751)
std::vector<unsigned char> vchLittle(strKey.rbegin(), strKey.rend());
uint128 uSeed(vchLittle);
setFamilySeed(uSeed);
setSeed(uSeed);
}
return iResult;
}
bool NewcoinAddress::setFamilySeed(const std::string& strSeed)
bool NewcoinAddress::setSeed(const std::string& strSeed)
{
return SetString(strSeed.c_str(), VER_FAMILY_SEED);
}
bool NewcoinAddress::setFamilySeedGeneric(const std::string& strText)
bool NewcoinAddress::setSeedGeneric(const std::string& strText)
{
NewcoinAddress naTemp;
bool bResult = true;
@@ -720,12 +720,12 @@ bool NewcoinAddress::setFamilySeedGeneric(const std::string& strText)
{
bResult = false;
}
else if (setFamilySeed(strText))
else if (setSeed(strText))
{
// std::cerr << "Recognized seed." << std::endl;
nothing();
}
else if (1 == setFamilySeed1751(strText))
else if (1 == setSeed1751(strText))
{
// std::cerr << "Recognized 1751 seed." << std::endl;
nothing();
@@ -733,44 +733,53 @@ bool NewcoinAddress::setFamilySeedGeneric(const std::string& strText)
else
{
// std::cerr << "Creating seed from pass phrase." << std::endl;
setFamilySeed(CKey::PassPhraseToKey(strText));
setSeed(CKey::PassPhraseToKey(strText));
}
return bResult;
}
void NewcoinAddress::setFamilySeed(uint128 hash128) {
void NewcoinAddress::setSeed(uint128 hash128) {
SetData(VER_FAMILY_SEED, hash128.begin(), 16);
}
void NewcoinAddress::setFamilySeedRandom()
void NewcoinAddress::setSeedRandom()
{
// XXX Maybe we should call MakeNewKey
uint128 key;
RAND_bytes((unsigned char *) &key, sizeof(key));
NewcoinAddress::setFamilySeed(key);
NewcoinAddress::setSeed(key);
}
NewcoinAddress NewcoinAddress::createSeedRandom()
{
NewcoinAddress naNew;
naNew.setFamilySeedRandom();
naNew.setSeedRandom();
return naNew;
}
NewcoinAddress NewcoinAddress::createSeedGeneric(const std::string& strText)
{
NewcoinAddress naNew;
naNew.setSeedGeneric(strText);
return naNew;
}
BOOST_AUTO_TEST_SUITE(newcoin_address)
BOOST_AUTO_TEST_CASE( my_test )
BOOST_AUTO_TEST_CASE( check_crypto )
{
// Construct a seed.
NewcoinAddress naSeed;
BOOST_CHECK(naSeed.setFamilySeedGeneric("masterpassphrase"));
BOOST_CHECK_MESSAGE(naSeed.humanFamilySeed() == "snoPBiXtMeMyMHUVTgbuqAfg1SUTb", naSeed.humanFamilySeed());
BOOST_CHECK(naSeed.setSeedGeneric("masterpassphrase"));
BOOST_CHECK_MESSAGE(naSeed.humanSeed() == "snoPBiXtMeMyMHUVTgbuqAfg1SUTb", naSeed.humanSeed());
// Create node public/private key pair
NewcoinAddress naNodePublic = NewcoinAddress::createNodePublic(naSeed);
@@ -790,7 +799,7 @@ BOOST_AUTO_TEST_CASE( my_test )
// Construct a public generator from the seed.
NewcoinAddress naGenerator = NewcoinAddress::createGeneratorPublic(naSeed);
BOOST_CHECK_MESSAGE(naGenerator.humanFamilyGenerator() == "fhuJKihSDzV2SkjLn9qbwm5AaRmixDPfFsHDCP6yfDZWcxDFz4mt", naGenerator.humanFamilyGenerator());
BOOST_CHECK_MESSAGE(naGenerator.humanGenerator() == "fhuJKihSDzV2SkjLn9qbwm5AaRmixDPfFsHDCP6yfDZWcxDFz4mt", naGenerator.humanGenerator());
// Create account #0 public/private key pair.
NewcoinAddress naAccountPublic0 = NewcoinAddress::createAccountPublic(naGenerator, 0);
@@ -827,4 +836,5 @@ BOOST_AUTO_TEST_CASE( my_test )
}
BOOST_AUTO_TEST_SUITE_END()
// vim:ts=4

View File

@@ -141,36 +141,37 @@ public:
}
//
// Family Generators
// Generators
// Use to generate a master or regular family.
//
BIGNUM* getFamilyGeneratorBN() const; // DEPRECATED
const std::vector<unsigned char>& getFamilyGenerator() const;
BIGNUM* getGeneratorBN() const; // DEPRECATED
const std::vector<unsigned char>& getGenerator() const;
std::string humanFamilyGenerator() const;
std::string humanGenerator() const;
bool setFamilyGenerator(const std::string& strGenerator);
void setFamilyGenerator(const std::vector<unsigned char>& vPublic);
// void setFamilyGenerator(const NewcoinAddress& seed);
bool setGenerator(const std::string& strGenerator);
void setGenerator(const std::vector<unsigned char>& vPublic);
// void setGenerator(const NewcoinAddress& seed);
// Create generator for making public deterministic keys.
static NewcoinAddress createGeneratorPublic(const NewcoinAddress& naSeed);
//
// Family Seeds
// Seeds
// Clients must disallow reconizable entries from being seeds.
uint128 getFamilySeed() const;
uint128 getSeed() const;
std::string humanFamilySeed() const;
std::string humanFamilySeed1751() const;
std::string humanSeed() const;
std::string humanSeed1751() const;
bool setFamilySeed(const std::string& strSeed);
int setFamilySeed1751(const std::string& strHuman1751);
bool setFamilySeedGeneric(const std::string& strText);
void setFamilySeed(uint128 hash128);
void setFamilySeedRandom();
bool setSeed(const std::string& strSeed);
int setSeed1751(const std::string& strHuman1751);
bool setSeedGeneric(const std::string& strText);
void setSeed(uint128 hash128);
void setSeedRandom();
static NewcoinAddress createSeedRandom();
static NewcoinAddress createSeedGeneric(const std::string& strText);
};
#endif

View File

@@ -221,7 +221,6 @@ void Peer::connected(const boost::system::error_code& error)
// Not redundant ip and port, add to connection list.
std::cerr << "Remote peer: accepted: " << strIp << " " << iPort << std::endl;
//BOOST_LOG_TRIVIAL(info) << "Connected to Peer.";
mIpPort = make_pair(strIp, iPort);
assert(!mIpPort.first.empty());
@@ -293,7 +292,7 @@ void Peer::handle_read_header(const boost::system::error_code& error)
else
{
detach("hrh2");
std::cerr << "Peer::handle_read_header: Error: " << error << std::endl; //else BOOST_LOG_TRIVIAL(info) << "Error: " << error;
std::cerr << "Peer::handle_read_header: Error: " << error << std::endl;
}
}
@@ -307,7 +306,7 @@ void Peer::handle_read_body(const boost::system::error_code& error)
else
{
detach("hrb");
std::cerr << "Peer::handle_read_body: Error: " << error << std::endl; //else BOOST_LOG_TRIVIAL(info) << "Error: " << error;
std::cerr << "Peer::handle_read_body: Error: " << error << std::endl;
}
}
@@ -336,7 +335,7 @@ void Peer::processReadBuffer()
newcoin::TMHello msg;
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvHello(msg);
else std::cerr << "parse error: " << type << std::endl; //else BOOST_LOG_TRIVIAL(info) << "Error: " << error;
else std::cerr << "parse error: " << type << std::endl;
}
break;
@@ -511,7 +510,7 @@ void Peer::processReadBuffer()
break;
default:
std::cerr << "Unknown Msg: " << type << std::endl; //else BOOST_LOG_TRIVIAL(info) << "Error: " << error;
std::cerr << "Unknown Msg: " << type << std::endl;
}
}
}

View File

@@ -54,7 +54,7 @@ void PeerDoor::handleConnect(Peer::pointer new_connection,
{
new_connection->connected(error);
}
else cout << "Error: " << error; // BOOST_LOG_TRIVIAL(info) << "Error: " << error;
else cout << "Error: " << error;
startListening();
}

View File

@@ -45,7 +45,7 @@ void RPCDoor::handleConnect(RPCServer::pointer new_connection,
new_connection->connected();
}
else cout << "Error: " << error;//BOOST_LOG_TRIVIAL(info) << "Error: " << error;
else cout << "Error: " << error;
startListening();
}

View File

@@ -101,6 +101,7 @@ Json::Value RPCServer::RPCError(int iError)
void RPCServer::connected()
{
//BOOST_LOG_TRIVIAL(info) << "RPC request";
//std::cout << "RPC request" << std::endl;
@@ -263,7 +264,7 @@ Json::Value RPCServer::getMasterGenerator(const uint256& uLedger, const NewcoinA
return RPCError(rpcFAIL_GEN_DECRPYT);
}
naMasterGenerator.setFamilyGenerator(vucMasterGenerator);
naMasterGenerator.setGenerator(vucMasterGenerator);
return Json::Value(Json::objectValue);
}
@@ -363,7 +364,7 @@ Json::Value RPCServer::accountFromString(const uint256& uLedger, NewcoinAddress&
bIndex = false;
}
// Must be a seed.
else if (!naSeed.setFamilySeedGeneric(strIdent))
else if (!naSeed.setSeedGeneric(strIdent))
{
return RPCError(rpcBAD_SEED);
}
@@ -396,7 +397,7 @@ Json::Value RPCServer::accountFromString(const uint256& uLedger, NewcoinAddress&
RPCError(rpcNO_GEN_DECRPYT);
}
naGenerator.setFamilyGenerator(vucMasterGenerator);
naGenerator.setGenerator(vucMasterGenerator);
}
bIndex = !iIndex;
@@ -414,7 +415,7 @@ Json::Value RPCServer::doAccountEmailSet(Json::Value &params)
NewcoinAddress naSeed;
uint256 uLedger = mNetOps->getCurrentLedger();
if (!naSeed.setFamilySeedGeneric(params[0u].asString()))
if (!naSeed.setSeedGeneric(params[0u].asString()))
{
return RPCError(rpcBAD_SEED);
}
@@ -618,7 +619,7 @@ Json::Value RPCServer::doAccountMessageSet(Json::Value& params) {
uint256 uLedger = mNetOps->getCurrentLedger();
NewcoinAddress naMessagePubKey;
if (!naSeed.setFamilySeedGeneric(params[0u].asString()))
if (!naSeed.setSeedGeneric(params[0u].asString()))
{
return RPCError(rpcBAD_SEED);
}
@@ -669,7 +670,7 @@ Json::Value RPCServer::doAccountWalletSet(Json::Value& params) {
NewcoinAddress naSeed;
uint256 uLedger = mNetOps->getCurrentLedger();
if (!naSeed.setFamilySeedGeneric(params[0u].asString()))
if (!naSeed.setSeedGeneric(params[0u].asString()))
{
return RPCError(rpcBAD_SEED);
}
@@ -754,7 +755,7 @@ Json::Value RPCServer::doCreditSet(Json::Value& params)
uint256 uLedger = mNetOps->getCurrentLedger();
uint32 uAcceptRate = params.size() >= 6 ? boost::lexical_cast<uint32>(params[5u].asString()) : 0;
if (!naSeed.setFamilySeedGeneric(params[0u].asString()))
if (!naSeed.setSeedGeneric(params[0u].asString()))
{
return RPCError(rpcBAD_SEED);
}
@@ -797,7 +798,7 @@ Json::Value RPCServer::doCreditSet(Json::Value& params)
obj["transaction"] = trans->getSTransaction()->getJson(0);
obj["status"] = trans->getStatus();
obj["seed"] = naSeed.humanFamilySeed();
obj["seed"] = naSeed.humanSeed();
obj["srcAccountID"] = naSrcAccountID.humanAccountID();
obj["dstAccountID"] = naDstAccountID.humanAccountID();
obj["limitAmount"] = saLimitAmount.getText();
@@ -898,7 +899,7 @@ Json::Value RPCServer::doNicknameSet(Json::Value& params)
NewcoinAddress naSeed;
uint256 uLedger = mNetOps->getCurrentLedger();
if (!naSeed.setFamilySeedGeneric(params[0u].asString()))
if (!naSeed.setSeedGeneric(params[0u].asString()))
{
return RPCError(rpcBAD_SEED);
}
@@ -984,7 +985,7 @@ Json::Value RPCServer::doPasswordFund(Json::Value &params)
NewcoinAddress naSeed;
uint256 uLedger = mNetOps->getCurrentLedger();
if (!naSeed.setFamilySeedGeneric(params[0u].asString()))
if (!naSeed.setSeedGeneric(params[0u].asString()))
{
return RPCError(rpcBAD_SEED);
}
@@ -1033,12 +1034,12 @@ Json::Value RPCServer::doPasswordSet(Json::Value& params)
NewcoinAddress naRegularSeed;
NewcoinAddress naAccountID;
if (!naMasterSeed.setFamilySeedGeneric(params[0u].asString()))
if (!naMasterSeed.setSeedGeneric(params[0u].asString()))
{
// Should also not allow account id's as seeds.
return RPCError(rpcBAD_SEED);
}
else if (!naRegularSeed.setFamilySeedGeneric(params[1u].asString()))
else if (!naRegularSeed.setSeedGeneric(params[1u].asString()))
{
// Should also not allow account id's as seeds.
return RPCError(rpcBAD_SEED);
@@ -1066,7 +1067,7 @@ Json::Value RPCServer::doPasswordSet(Json::Value& params)
// Hash of regular account #0 public key.
// uint160 uGeneratorID = naRegular0Public.getAccountID();
std::vector<unsigned char> vucGeneratorCipher = naRegular0Private.accountPrivateEncrypt(naRegular0Public, naMasterGenerator.getFamilyGenerator());
std::vector<unsigned char> vucGeneratorCipher = naRegular0Private.accountPrivateEncrypt(naRegular0Public, naMasterGenerator.getGenerator());
std::vector<unsigned char> vucGeneratorSig;
// Prove that we have the corresponding private key to the generator id. So, we can get the generator id.
@@ -1109,10 +1110,10 @@ Json::Value RPCServer::doPasswordSet(Json::Value& params)
Json::Value obj(Json::objectValue);
// We "echo" the seeds so they can be checked.
obj["master_seed"] = naMasterSeed.humanFamilySeed();
obj["master_key"] = naMasterSeed.humanFamilySeed1751();
obj["regular_seed"] = naRegularSeed.humanFamilySeed();
obj["regular_key"] = naRegularSeed.humanFamilySeed1751();
obj["master_seed"] = naMasterSeed.humanSeed();
obj["master_key"] = naMasterSeed.humanSeed1751();
obj["regular_seed"] = naRegularSeed.humanSeed();
obj["regular_key"] = naRegularSeed.humanSeed1751();
obj["transaction"] = trns->getSTransaction()->getJson(0);
obj["status"] = trns->getStatus();
@@ -1147,7 +1148,7 @@ Json::Value RPCServer::doSend(Json::Value& params)
if (params.size() >= 7)
sSrcCurrency = params[6u].asString();
if (!naSeed.setFamilySeedGeneric(params[0u].asString()))
if (!naSeed.setSeedGeneric(params[0u].asString()))
{
return RPCError(rpcBAD_SEED);
}
@@ -1232,7 +1233,7 @@ Json::Value RPCServer::doSend(Json::Value& params)
obj["transaction"] = trans->getSTransaction()->getJson(0);
obj["status"] = trans->getStatus();
obj["seed"] = naSeed.humanFamilySeed();
obj["seed"] = naSeed.humanSeed();
obj["fee"] = saFee.getText();
obj["create"] = bCreate;
obj["srcAccountID"] = naSrcAccountID.humanAccountID();
@@ -1268,7 +1269,7 @@ Json::Value RPCServer::doTransitSet(Json::Value& params)
if (params.size() >= 8)
sTransitExpire = params[8u].asString();
if (!naSeed.setFamilySeedGeneric(params[0u].asString()))
if (!naSeed.setSeedGeneric(params[0u].asString()))
{
return RPCError(rpcBAD_SEED);
}
@@ -1307,7 +1308,7 @@ Json::Value RPCServer::doTransitSet(Json::Value& params)
obj["transaction"] = trans->getSTransaction()->getJson(0);
obj["status"] = trans->getStatus();
obj["seed"] = naSeed.humanFamilySeed();
obj["seed"] = naSeed.humanSeed();
obj["srcAccountID"] = naSrcAccountID.humanAccountID();
obj["transitRate"] = uTransitRate;
obj["transitStart"] = uTransitStart;
@@ -1491,16 +1492,16 @@ Json::Value RPCServer::doValidationCreate(Json::Value& params) {
{
std::cerr << "Creating random validation seed." << std::endl;
naSeed.setFamilySeedRandom(); // Get a random seed.
naSeed.setSeedRandom(); // Get a random seed.
}
else if (!naSeed.setFamilySeedGeneric(params[0u].asString()))
else if (!naSeed.setSeedGeneric(params[0u].asString()))
{
return RPCError(rpcBAD_SEED);
}
obj["validation_public_key"] = NewcoinAddress::createNodePublic(naSeed).humanNodePublic();
obj["validation_seed"] = naSeed.humanFamilySeed();
obj["validation_key"] = naSeed.humanFamilySeed1751();
obj["validation_seed"] = naSeed.humanSeed();
obj["validation_key"] = naSeed.humanSeed1751();
return obj;
}
@@ -1518,15 +1519,15 @@ Json::Value RPCServer::doValidationSeed(Json::Value& params) {
theConfig.VALIDATION_SEED.clear();
}
else if (!theConfig.VALIDATION_SEED.setFamilySeedGeneric(params[0u].asString()))
else if (!theConfig.VALIDATION_SEED.setSeedGeneric(params[0u].asString()))
{
return RPCError(rpcBAD_SEED);
}
else
{
obj["validation_public_key"] = NewcoinAddress::createNodePublic(theConfig.VALIDATION_SEED).humanNodePublic();
obj["validation_seed"] = theConfig.VALIDATION_SEED.humanFamilySeed();
obj["validation_key"] = theConfig.VALIDATION_SEED.humanFamilySeed1751();
obj["validation_seed"] = theConfig.VALIDATION_SEED.humanSeed();
obj["validation_key"] = theConfig.VALIDATION_SEED.humanSeed1751();
}
return obj;
@@ -1569,7 +1570,7 @@ Json::Value RPCServer::doWalletAccounts(Json::Value& params)
NewcoinAddress naSeed;
uint256 uLedger = mNetOps->getCurrentLedger();
if (!naSeed.setFamilySeedGeneric(params[0u].asString()))
if (!naSeed.setSeedGeneric(params[0u].asString()))
{
return RPCError(rpcBAD_SEED);
}
@@ -1612,7 +1613,7 @@ Json::Value RPCServer::doWalletAdd(Json::Value& params)
std::string sDstCurrency;
uint256 uLedger = mNetOps->getCurrentLedger();
if (!naRegularSeed.setFamilySeedGeneric(params[0u].asString()))
if (!naRegularSeed.setSeedGeneric(params[0u].asString()))
{
return RPCError(rpcBAD_SEED);
}
@@ -1620,7 +1621,7 @@ Json::Value RPCServer::doWalletAdd(Json::Value& params)
{
return RPCError(rpcSRC_ACT_MALFORMED);
}
else if (!naMasterSeed.setFamilySeedGeneric(params[2u].asString()))
else if (!naMasterSeed.setSeedGeneric(params[2u].asString()))
{
return RPCError(rpcBAD_SEED);
}
@@ -1713,12 +1714,12 @@ Json::Value RPCServer::doWalletClaim(Json::Value& params)
NewcoinAddress naMasterSeed;
NewcoinAddress naRegularSeed;
if (!naMasterSeed.setFamilySeedGeneric(params[0u].asString()))
if (!naMasterSeed.setSeedGeneric(params[0u].asString()))
{
// Should also not allow account id's as seeds.
return RPCError(rpcBAD_SEED);
}
else if (!naRegularSeed.setFamilySeedGeneric(params[1u].asString()))
else if (!naRegularSeed.setSeedGeneric(params[1u].asString()))
{
// Should also not allow account id's as seeds.
return RPCError(rpcBAD_SEED);
@@ -1753,7 +1754,7 @@ Json::Value RPCServer::doWalletClaim(Json::Value& params)
// Hash of regular account #0 public key.
uint160 uGeneratorID = naRegular0Public.getAccountID();
std::vector<unsigned char> vucGeneratorCipher = naRegular0Private.accountPrivateEncrypt(naRegular0Public, naMasterGenerator.getFamilyGenerator());
std::vector<unsigned char> vucGeneratorCipher = naRegular0Private.accountPrivateEncrypt(naRegular0Public, naMasterGenerator.getGenerator());
std::vector<unsigned char> vucGeneratorSig;
// Prove that we have the corresponding private key to the generator id. So, we can get the generator id.
@@ -1772,10 +1773,10 @@ Json::Value RPCServer::doWalletClaim(Json::Value& params)
Json::Value obj(Json::objectValue);
// We "echo" the seeds so they can be checked.
obj["master_seed"] = naMasterSeed.humanFamilySeed();
obj["master_key"] = naMasterSeed.humanFamilySeed1751();
obj["regular_seed"] = naRegularSeed.humanFamilySeed();
obj["regular_key"] = naRegularSeed.humanFamilySeed1751();
obj["master_seed"] = naMasterSeed.humanSeed();
obj["master_key"] = naMasterSeed.humanSeed1751();
obj["regular_seed"] = naRegularSeed.humanSeed();
obj["regular_key"] = naRegularSeed.humanSeed1751();
obj["account_id"] = naAccountPublic.humanAccountID();
obj["generator_id"] = strHex(uGeneratorID);
@@ -1800,7 +1801,7 @@ Json::Value RPCServer::doWalletCreate(Json::Value& params)
NewcoinAddress naSeed;
uint256 uLedger = mNetOps->getCurrentLedger();
if (!naSeed.setFamilySeedGeneric(params[0u].asString()))
if (!naSeed.setSeedGeneric(params[0u].asString()))
{
return RPCError(rpcBAD_SEED);
}
@@ -1859,15 +1860,15 @@ Json::Value RPCServer::doWalletPropose(Json::Value& params)
NewcoinAddress naSeed;
NewcoinAddress naAccount;
naSeed.setFamilySeedRandom();
naSeed.setSeedRandom();
NewcoinAddress naGenerator = NewcoinAddress::createGeneratorPublic(naSeed);
naAccount.setAccountPublic(naGenerator, 0);
Json::Value obj(Json::objectValue);
obj["master_seed"] = naSeed.humanFamilySeed();
obj["master_key"] = naSeed.humanFamilySeed1751();
obj["master_seed"] = naSeed.humanSeed();
obj["master_key"] = naSeed.humanSeed1751();
obj["account_id"] = naAccount.humanAccountID();
return obj;
@@ -1879,7 +1880,7 @@ Json::Value RPCServer::doWalletSeed(Json::Value& params)
NewcoinAddress naSeed;
if (params.size()
&& !naSeed.setFamilySeedGeneric(params[0u].asString()))
&& !naSeed.setSeedGeneric(params[0u].asString()))
{
return RPCError(rpcBAD_SEED);
}
@@ -1889,7 +1890,7 @@ Json::Value RPCServer::doWalletSeed(Json::Value& params)
if (!params.size())
{
naSeed.setFamilySeedRandom();
naSeed.setSeedRandom();
}
NewcoinAddress naGenerator = NewcoinAddress::createGeneratorPublic(naSeed);
@@ -1898,8 +1899,8 @@ Json::Value RPCServer::doWalletSeed(Json::Value& params)
Json::Value obj(Json::objectValue);
obj["seed"] = naSeed.humanFamilySeed();
obj["key"] = naSeed.humanFamilySeed1751();
obj["seed"] = naSeed.humanSeed();
obj["key"] = naSeed.humanSeed1751();
return obj;
}

View File

@@ -158,10 +158,4 @@ bool Wallet::dataStore(const std::string& strKey, const std::string& strValue)
return bSuccess;
}
bool Wallet::unitTest()
{
// Create 100 keys for each of 1,000 families and ensure all keys match
return true;
}
// vim:ts=4

View File

@@ -54,8 +54,6 @@ public:
bool dataDelete(const std::string& strKey);
bool dataFetch(const std::string& strKey, std::string& strValue);
bool dataStore(const std::string& strKey, const std::string& strValue);
static bool unitTest();
};
#endif