Extra debug, bugfixes.

This commit is contained in:
JoelKatz
2011-12-30 18:49:30 -08:00
parent 3d82f2bb8b
commit f6830341a0

View File

@@ -5,6 +5,7 @@
#include "json/value.h" #include "json/value.h"
#include "json/reader.h" #include "json/reader.h"
#include "json/writer.h"
#include "RPCServer.h" #include "RPCServer.h"
#include "RequestParser.h" #include "RequestParser.h"
@@ -99,7 +100,17 @@ std::string RPCServer::handleRequest(const std::string& requestStr)
else if(!valParams.isArray()) else if(!valParams.isArray())
return(HTTPReply(400, "")); return(HTTPReply(400, ""));
#ifdef DEBUG
Json::StyledStreamWriter w;
w.write(std::cerr, valParams);
#endif
Json::Value result=doCommand(strMethod, valParams); Json::Value result=doCommand(strMethod, valParams);
#ifdef DEBUG
w.write(std::cerr, result);
#endif
std::string strReply = JSONRPCReply(result, Json::Value(), id); std::string strReply = JSONRPCReply(result, Json::Value(), id);
return( HTTPReply(200, strReply) ); return( HTTPReply(200, strReply) );
} }
@@ -114,26 +125,35 @@ Json::Value RPCServer::doCreateFamily(Json::Value& params)
std::string query; std::string query;
uint160 family; uint160 family;
if(params.isArray()) params=params[0u];
if(params.isConvertibleTo(Json::stringValue)) query=params.asString(); if(params.isConvertibleTo(Json::stringValue)) query=params.asString();
Json::Value ret(Json::objectValue); Json::Value ret(Json::objectValue);
if(query.empty()) if(query.empty())
{ {
std::cerr << "empty" << std::endl;
uint256 privKey; uint256 privKey;
family=theApp->getWallet().addFamily(privKey); family=theApp->getWallet().addFamily(privKey);
ret["PrivateGenerator"]=privKey.GetHex(); ret["PrivateGenerator"]=privKey.GetHex();
} }
else if(LocalAccountFamily::isHexPrivateKey(query)) else if(LocalAccountFamily::isHexPrivateKey(query))
{ {
std::cerr << "hprivk" << std::endl;
uint256 pk; uint256 pk;
pk.SetHex(query); pk.SetHex(query);
family=theApp->getWallet().addFamily(pk, false); family=theApp->getWallet().addFamily(pk, false);
} }
else if(LocalAccountFamily::isHexPublicKey(query)) else if(LocalAccountFamily::isHexPublicKey(query))
{
std::cerr << "hpubk" << std::endl;
family=theApp->getWallet().addFamily(query); family=theApp->getWallet().addFamily(query);
}
else else
{
std::cerr << "PassPhrase(" << query << ")" << std::endl;
family=theApp->getWallet().addFamily(query, false); family=theApp->getWallet().addFamily(query, false);
}
if(!family) if(!family)
JSONRPCError(500, "Invalid family specifier"); JSONRPCError(500, "Invalid family specifier");
@@ -145,6 +165,7 @@ Json::Value RPCServer::doCreateFamily(Json::Value& params)
Json::Value RPCServer::doGetAccount(Json::Value &params) Json::Value RPCServer::doGetAccount(Json::Value &params)
{ // getaccount <family> <number> { // getaccount <family> <number>
} }
Json::Value RPCServer::doGetNewAccount(Json::Value &params) Json::Value RPCServer::doGetNewAccount(Json::Value &params)