mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Add RPC command account_email_set.
This commit is contained in:
@@ -328,33 +328,83 @@ Json::Value RPCServer::accountFromString(const uint256& uLedger, NewcoinAddress&
|
||||
// account_email_set <seed> <paying_account> [<email_address>]
|
||||
Json::Value RPCServer::doAccountEmailSet(Json::Value ¶ms)
|
||||
{
|
||||
NewcoinAddress naSrcAccountID;
|
||||
NewcoinAddress naSeed;
|
||||
uint256 uLedger;
|
||||
|
||||
if (params.size() < 2 || params.size() > 3)
|
||||
{
|
||||
return "invalid params";
|
||||
}
|
||||
else if (!naSeed.setFamilySeedGeneric(params[0u].asString()))
|
||||
{
|
||||
return "disallowed seed";
|
||||
}
|
||||
else if (!naSrcAccountID.setAccountID(params[1u].asString()))
|
||||
{
|
||||
return "source account id needed";
|
||||
}
|
||||
else if (!mNetOps->available())
|
||||
{
|
||||
return JSONRPCError(503, "network not available");
|
||||
}
|
||||
else if ((uLedger = mNetOps->getClosedLedger()).isZero())
|
||||
{
|
||||
return JSONRPCError(503, "no closed ledger");
|
||||
}
|
||||
|
||||
NewcoinAddress naMasterGenerator;
|
||||
NewcoinAddress naAccountPublic;
|
||||
NewcoinAddress naAccountPrivate;
|
||||
AccountState::pointer asSrc;
|
||||
Json::Value obj = authorize(uLedger, naSeed, naSrcAccountID, naAccountPublic, naAccountPrivate, asSrc, naMasterGenerator);
|
||||
|
||||
STAmount saSrcBalance = asSrc->getBalance();
|
||||
|
||||
if (!obj.empty())
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
else if (saSrcBalance < theConfig.FEE_DEFAULT)
|
||||
{
|
||||
return JSONRPCError(500, "insufficent funds");
|
||||
}
|
||||
|
||||
// Hash as per: http://en.gravatar.com/site/implement/hash/
|
||||
std::string strEmail = 3 == params.size() ? params[2u].asString() : "";
|
||||
std::vector<unsigned char> vucMD5(128/8, 0);
|
||||
std::string strMD5Lower;
|
||||
|
||||
boost::trim(strEmail);
|
||||
boost::to_lower(strEmail);
|
||||
|
||||
std::vector<unsigned char> vucMD5(128/8, 0);
|
||||
MD5(reinterpret_cast<const unsigned char*>(strEmail.c_str()), strEmail.size(), &vucMD5.front());
|
||||
|
||||
strMD5Lower = strHex(vucMD5);
|
||||
boost::to_lower(strMD5Lower);
|
||||
uint128 uEmailHash(vucMD5);
|
||||
|
||||
Transaction::pointer trans = Transaction::sharedAccountSet(
|
||||
naAccountPublic, naAccountPrivate,
|
||||
naSrcAccountID,
|
||||
asSrc->getSeq(),
|
||||
theConfig.FEE_DEFAULT,
|
||||
0, // YYY No source tag
|
||||
strEmail.empty(),
|
||||
uEmailHash,
|
||||
false,
|
||||
uint256(),
|
||||
std::vector<unsigned char>());
|
||||
|
||||
(void) mNetOps->processTransaction(trans);
|
||||
|
||||
Json::Value ret(Json::objectValue);
|
||||
|
||||
ret["email"] = strEmail;
|
||||
ret["hash"] = strHex(vucMD5);
|
||||
ret["url_gravatar"] = str(boost::format("http://www.gravatar.com/avatar/%s") % strMD5Lower);
|
||||
obj["transaction"] = trans->getSTransaction()->getJson(0);
|
||||
obj["status"] = trans->getStatus();
|
||||
|
||||
if (!strEmail.empty())
|
||||
{
|
||||
ret["Email"] = strEmail;
|
||||
ret["EmailHash"] = strHex(vucMD5);
|
||||
ret["UrlGravatar"] = AccountState::createGravatarUrl(uEmailHash);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -507,6 +557,14 @@ Json::Value RPCServer::doAccountLines(Json::Value ¶ms)
|
||||
}
|
||||
}
|
||||
|
||||
Json::Value RPCServer::doAccountMessageSet(Json::Value& params) {
|
||||
return "not implemented";
|
||||
}
|
||||
|
||||
Json::Value RPCServer::doAccountWalletSet(Json::Value& params) {
|
||||
return "not implemented";
|
||||
}
|
||||
|
||||
Json::Value RPCServer::doConnect(Json::Value& params)
|
||||
{
|
||||
// connect <ip> [port]
|
||||
@@ -1263,8 +1321,7 @@ Json::Value RPCServer::doWalletCreate(Json::Value& params)
|
||||
{
|
||||
return "account already exists";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Trying to build:
|
||||
// peer_wallet_create <paying_account> <paying_signature> <account_id> [<initial_funds>] [<annotation>]
|
||||
|
||||
@@ -1272,7 +1329,6 @@ Json::Value RPCServer::doWalletCreate(Json::Value& params)
|
||||
NewcoinAddress naAccountPublic;
|
||||
NewcoinAddress naAccountPrivate;
|
||||
AccountState::pointer asSrc;
|
||||
uint256 uLedger = mNetOps->getClosedLedger();
|
||||
Json::Value obj = authorize(uLedger, naSeed, naSrcAccountID, naAccountPublic, naAccountPrivate, asSrc, naMasterGenerator);
|
||||
|
||||
STAmount saSrcBalance = asSrc->getBalance();
|
||||
@@ -1286,8 +1342,7 @@ Json::Value RPCServer::doWalletCreate(Json::Value& params)
|
||||
{
|
||||
return JSONRPCError(500, "insufficent funds");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Transaction::pointer trans = Transaction::sharedCreate(
|
||||
naAccountPublic, naAccountPrivate,
|
||||
naSrcAccountID,
|
||||
@@ -1304,8 +1359,6 @@ Json::Value RPCServer::doWalletCreate(Json::Value& params)
|
||||
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// wallet_propose
|
||||
Json::Value RPCServer::doWalletPropose(Json::Value& params)
|
||||
@@ -1502,6 +1555,8 @@ Json::Value RPCServer::doCommand(const std::string& command, Json::Value& params
|
||||
if (command == "account_email_set") return doAccountEmailSet(params);
|
||||
if (command == "account_info") return doAccountInfo(params);
|
||||
if (command == "account_lines") return doAccountLines(params);
|
||||
if (command == "account_message_set") return doAccountMessageSet(params);
|
||||
if (command == "account_wallet_set") return doAccountWalletSet(params);
|
||||
if (command == "connect") return doConnect(params);
|
||||
if (command == "credit_set") return doCreditSet(params);
|
||||
if (command == "peers") return doPeers(params);
|
||||
|
||||
@@ -51,6 +51,8 @@ private:
|
||||
Json::Value doAccountEmailSet(Json::Value ¶ms);
|
||||
Json::Value doAccountInfo(Json::Value& params);
|
||||
Json::Value doAccountLines(Json::Value ¶ms);
|
||||
Json::Value doAccountMessageSet(Json::Value ¶ms);
|
||||
Json::Value doAccountWalletSet(Json::Value ¶ms);
|
||||
Json::Value doConnect(Json::Value& params);
|
||||
Json::Value doCreditSet(Json::Value& params);
|
||||
Json::Value doLedger(Json::Value& params);
|
||||
|
||||
@@ -41,6 +41,8 @@ void printHelp(const po::options_description& desc)
|
||||
cout << " account_info <account>|<nickname>" << endl;
|
||||
cout << " account_info <seed>|<pass_phrase>|<key> [<index>]" << endl;
|
||||
cout << " account_lines <account>|<nickname>" << endl;
|
||||
cout << " account_message_set <seed> <paying_account> <pub_key>" << endl;
|
||||
cout << " account_wallet_set <seed> <paying_account> [<wallet_hash>]" << endl;
|
||||
cout << " connect <ip> [<port>]" << endl;
|
||||
cout << " credit_set <seed> <paying_account> <destination_account> <limit_amount> <currency> [<account_rate>]" << endl;
|
||||
cout << " ledger" << endl;
|
||||
|
||||
Reference in New Issue
Block a user