mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-23 12:35:50 +00:00
Finish 'info' RPC call.
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include "json/value.h"
|
#include "json/value.h"
|
||||||
#include "json/reader.h"
|
#include "json/reader.h"
|
||||||
@@ -230,8 +231,9 @@ Json::Value RPCServer::doInfo(Json::Value ¶ms)
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
else if(paramCount==1)
|
|
||||||
{
|
if(paramCount>2) return JSONRPCError(500, "Invalid parameters");
|
||||||
|
|
||||||
uint160 family;
|
uint160 family;
|
||||||
if(Wallet::isHexFamily(fParam))
|
if(Wallet::isHexFamily(fParam))
|
||||||
family.SetHex(fParam);
|
family.SetHex(fParam);
|
||||||
@@ -252,12 +254,25 @@ Json::Value RPCServer::doInfo(Json::Value ¶ms)
|
|||||||
obj["Comment"]=comment;
|
obj["Comment"]=comment;
|
||||||
obj["PublicGenerator"]=pubKey;
|
obj["PublicGenerator"]=pubKey;
|
||||||
obj["Locked"]=isLocked ? "true" : "false";
|
obj["Locked"]=isLocked ? "true" : "false";
|
||||||
return obj;
|
|
||||||
}
|
if(paramCount==2)
|
||||||
else if(paramCount==2)
|
|
||||||
{
|
{
|
||||||
|
Json::Value keyNum=params[1u];
|
||||||
|
if(keyNum.isString()) keyNum=Json::Value(boost::lexical_cast<int>(keyNum.asString()));
|
||||||
|
if(keyNum.isConvertibleTo(Json::intValue))
|
||||||
|
{
|
||||||
|
uint160 k=theApp->getWallet().peekKey(family, keyNum.asInt());
|
||||||
|
if(!!k)
|
||||||
|
{
|
||||||
|
Json::Value key(Json::objectValue);
|
||||||
|
key["Number"]=keyNum.asInt();
|
||||||
|
key["Address"]=NewcoinAddress(k).GetString();
|
||||||
|
obj["Account"]=key;
|
||||||
}
|
}
|
||||||
else return JSONRPCError(500, "Invalid parameters");
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::Value RPCServer::doCommand(const std::string& command, Json::Value& params)
|
Json::Value RPCServer::doCommand(const std::string& command, Json::Value& params)
|
||||||
|
|||||||
11
Wallet.cpp
11
Wallet.cpp
@@ -49,7 +49,7 @@ LocalAccountFamily::~LocalAccountFamily()
|
|||||||
if(mRootPubKey!=NULL) EC_POINT_free(mRootPubKey);
|
if(mRootPubKey!=NULL) EC_POINT_free(mRootPubKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint160 LocalAccountFamily::getAccount(int seq)
|
uint160 LocalAccountFamily::getAccount(int seq, bool keep)
|
||||||
{
|
{
|
||||||
std::map<int, LocalAccountEntry::pointer>::iterator ait=mAccounts.find(seq);
|
std::map<int, LocalAccountEntry::pointer>::iterator ait=mAccounts.find(seq);
|
||||||
if(ait!=mAccounts.end()) return ait->second->getAccountID();
|
if(ait!=mAccounts.end()) return ait->second->getAccountID();
|
||||||
@@ -425,7 +425,7 @@ LocalAccount::pointer Wallet::getLocalAccount(const uint160& family, int seq)
|
|||||||
{
|
{
|
||||||
std::map<uint160, LocalAccountFamily::pointer>::iterator fit=families.find(family);
|
std::map<uint160, LocalAccountFamily::pointer>::iterator fit=families.find(family);
|
||||||
if(fit==families.end()) return LocalAccount::pointer();
|
if(fit==families.end()) return LocalAccount::pointer();
|
||||||
uint160 acct=fit->second->getAccount(seq);
|
uint160 acct=fit->second->getAccount(seq, true);
|
||||||
|
|
||||||
std::map<uint160, LocalAccount::pointer>::iterator ait=accounts.find(acct);
|
std::map<uint160, LocalAccount::pointer>::iterator ait=accounts.find(acct);
|
||||||
if(ait!=accounts.end()) return ait->second;
|
if(ait!=accounts.end()) return ait->second;
|
||||||
@@ -435,6 +435,13 @@ LocalAccount::pointer Wallet::getLocalAccount(const uint160& family, int seq)
|
|||||||
return lac;
|
return lac;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint160 Wallet::peekKey(const uint160& family, int seq)
|
||||||
|
{
|
||||||
|
std::map<uint160, LocalAccountFamily::pointer>::iterator fit=families.find(family);
|
||||||
|
if(fit==families.end()) return uint160();
|
||||||
|
return fit->second->getAccount(seq, false);
|
||||||
|
}
|
||||||
|
|
||||||
void Wallet::delFamily(const uint160& familyName)
|
void Wallet::delFamily(const uint160& familyName)
|
||||||
{
|
{
|
||||||
std::map<uint160, LocalAccountFamily::pointer>::iterator fit=families.find(familyName);
|
std::map<uint160, LocalAccountFamily::pointer>::iterator fit=families.find(familyName);
|
||||||
|
|||||||
3
Wallet.h
3
Wallet.h
@@ -90,7 +90,7 @@ public:
|
|||||||
|
|
||||||
std::map<int, LocalAccountEntry::pointer>& getAcctMap() { return mAccounts; }
|
std::map<int, LocalAccountEntry::pointer>& getAcctMap() { return mAccounts; }
|
||||||
LocalAccountEntry::pointer get(int seq);
|
LocalAccountEntry::pointer get(int seq);
|
||||||
uint160 getAccount(int seq);
|
uint160 getAccount(int seq, bool keep);
|
||||||
|
|
||||||
std::string getPubKeyHex() const; // The text name of the public key
|
std::string getPubKeyHex() const; // The text name of the public key
|
||||||
std::string getShortName() const { return mName; }
|
std::string getShortName() const { return mName; }
|
||||||
@@ -165,6 +165,7 @@ public:
|
|||||||
|
|
||||||
LocalAccount::pointer getLocalAccount(const uint160& famBase, int seq);
|
LocalAccount::pointer getLocalAccount(const uint160& famBase, int seq);
|
||||||
LocalAccount::pointer getLocalAccount(const uint160& acctID);
|
LocalAccount::pointer getLocalAccount(const uint160& acctID);
|
||||||
|
uint160 peekKey(const uint160& family, int seq);
|
||||||
std::string getPubKeyHex(const uint160& famBase);
|
std::string getPubKeyHex(const uint160& famBase);
|
||||||
std::string getShortName(const uint160& famBase);
|
std::string getShortName(const uint160& famBase);
|
||||||
bool getFamilyInfo(const uint160& family, std::string& name, std::string& comment);
|
bool getFamilyInfo(const uint160& family, std::string& name, std::string& comment);
|
||||||
|
|||||||
Reference in New Issue
Block a user