diff --git a/src/RPCServer.cpp b/src/RPCServer.cpp index a8188edad..f5853627f 100644 --- a/src/RPCServer.cpp +++ b/src/RPCServer.cpp @@ -653,6 +653,39 @@ Json::Value RPCServer::doWalletPropose(Json::Value& params) } } +// wallet_seed [||] +Json::Value RPCServer::doWalletSeed(Json::Value& params) +{ + if (params.size() > 1) + { + return "invalid params"; + } + else + { + NewcoinAddress naSeed; + NewcoinAddress naGenerator; + NewcoinAddress naAccount; + + if (params.size()) + { + naSeed.setFamilySeedGeneric(params[0u].asString()); + } + else + { + naSeed.setFamilySeedRandom(); + } + naGenerator.setFamilyGenerator(naSeed); + naAccount.setAccountPublic(naGenerator, 0); + + Json::Value obj(Json::objectValue); + + obj["seed"] = naSeed.humanFamilySeed(); + obj["key"] = naSeed.humanFamilySeed1751(); + + return obj; + } +} + void RPCServer::validatorsResponse(const boost::system::error_code& err, std::string strResponse) { std::cerr << "Fetch '" VALIDATORS_FILE_NAME "' complete." << std::endl; @@ -799,13 +832,12 @@ Json::Value RPCServer::doCommand(const std::string& command, Json::Value& params if (command == "wallet_claim") return doWalletClaim(params); if (command == "wallet_propose") return doWalletPropose(params); + if (command == "wallet_seed") return doWalletSeed(params); // // Obsolete or need rewrite: // - if (command=="lock") return doLock(params); - if (command=="unlock") return doUnlock(params); if (command=="sendto") return doSendTo(params); if (command=="tx") return doTx(params); if (command=="ledger") return doLedger(params); diff --git a/src/RPCServer.h b/src/RPCServer.h index 07bebf172..8cd22cd89 100644 --- a/src/RPCServer.h +++ b/src/RPCServer.h @@ -56,6 +56,7 @@ class RPCServer : public boost::enable_shared_from_this Json::Value doWalletClaim(Json::Value& params); Json::Value doWalletPropose(Json::Value& params); + Json::Value doWalletSeed(Json::Value& params); // Parses a string account name into a local or remote NewcoinAddress. NewcoinAddress parseAccount(const std::string& account); diff --git a/src/main.cpp b/src/main.cpp index 66dd94c31..46b066400 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -51,6 +51,7 @@ void printHelp(const po::options_description& desc) cout << " unl_reset" << endl; cout << " validation_create [||]" << endl; cout << " wallet_claim [] []" << endl; + cout << " wallet_seed [||]" << endl; cout << " wallet_propose" << endl; }