18 if (fHelp || params.size() != 0)
20 "getconnectioncount\n"
21 "Returns the number of connections to other nodes.");
27 static void CopyNodeStats(std::vector<CNodeStats>& vstats)
32 vstats.reserve(
vNodes.size());
36 vstats.push_back(stats);
42 if (fHelp || params.size() != 0)
45 "Returns data about each connected network node.");
47 vector<CNodeStats> vstats;
48 CopyNodeStats(vstats);
52 BOOST_FOREACH(
const CNodeStats& stats, vstats) {
72 obj.push_back(
Pair(
"syncnode",
true));
83 if (params.size() == 2)
84 strCommand = params[1].
get_str();
85 if (fHelp || params.size() != 2 ||
86 (strCommand !=
"onetry" && strCommand !=
"add" && strCommand !=
"remove"))
88 "addnode <node> <add|remove|onetry>\n"
89 "Attempts add or remove <node> from the addnode list or try a connection to <node> once.");
91 string strNode = params[0].get_str();
93 if (strCommand ==
"onetry")
106 if (strCommand ==
"add")
112 else if(strCommand ==
"remove")
115 throw JSONRPCError(-24,
"Error: Node has not been added.");
124 if (fHelp || params.size() < 1 || params.size() > 2)
126 "getaddednodeinfo <dns> [node]\n"
127 "Returns information about the given added node, or all added nodes\n"
128 "(note that onetry addnodes are not listed here)\n"
129 "If dns is false, only a list of added nodes will be provided,\n"
130 "otherwise connected information will also be available.");
134 list<string> laddedNodes(0);
135 if (params.size() == 1)
139 laddedNodes.push_back(strAddNode);
143 string strNode = params[1].get_str();
146 if (strAddNode == strNode)
148 laddedNodes.push_back(strAddNode);
151 if (laddedNodes.size() == 0)
152 throw JSONRPCError(-24,
"Error: Node has not been added.");
158 BOOST_FOREACH(
string& strAddNode, laddedNodes)
159 ret.push_back(
Pair(
"addednode", strAddNode));
165 list<pair<string, vector<CService> > > laddedAddreses(0);
166 BOOST_FOREACH(
string& strAddNode, laddedNodes)
168 vector<CService> vservNode(0);
170 laddedAddreses.push_back(make_pair(strAddNode, vservNode));
174 obj.push_back(
Pair(
"addednode", strAddNode));
175 obj.push_back(
Pair(
"connected",
false));
177 obj.push_back(
Pair(
"addresses", addresses));
182 for (list<pair<
string, vector<CService> > >::iterator it = laddedAddreses.begin(); it != laddedAddreses.end(); it++)
185 obj.push_back(
Pair(
"addednode", it->first));
188 bool fConnected =
false;
189 BOOST_FOREACH(
CService& addrNode, it->second)
195 if (pnode->
addr == addrNode)
199 node.push_back(
Pair(
"connected", pnode->
fInbound ?
"inbound" :
"outbound"));
203 node.push_back(
Pair(
"connected",
"false"));
204 addresses.push_back(node);
206 obj.push_back(
Pair(
"connected", fConnected));
207 obj.push_back(
Pair(
"addresses", addresses));
217 if (fHelp || params.size() > 1)
219 "makekeypair [prefix]\n"
220 "Make a public/private key pair.\n"
221 "[prefix] is optional preferred prefix for the public key.\n");
223 string strPrefix =
"";
224 if (params.size() > 0)
225 strPrefix = params[0].
get_str();
235 }
while (nCount < 10000 && strPrefix !=
HexStr(pubkey.
begin(), pubkey.
end()).substr(0, strPrefix.size()));
237 if (strPrefix !=
HexStr(pubkey.
begin(), pubkey.
end()).substr(0, strPrefix.size()))
253 if (fHelp || params.size() < 6)
255 "sendalert <message> <privatekey> <minver> <maxver> <priority> <id> [cancelupto]\n"
256 "<message> is the alert text message\n"
257 "<privatekey> is base58 hex string of alert master private key\n"
258 "<minver> is the minimum applicable internal client version\n"
259 "<maxver> is the maximum applicable internal client version\n"
260 "<priority> is integer priority number\n"
261 "<id> is the alert id\n"
262 "[cancelupto] cancels all alert id's up to this number\n"
263 "Returns true or false.");
268 alert.
nMinVer = params[2].get_int();
269 alert.
nMaxVer = params[3].get_int();
271 alert.
nID = params[5].get_int();
272 if (params.size() > 6)
273 alert.
nCancel = params[6].get_int();
284 if (!vchSecret.SetString(params[1].get_str()))
285 throw runtime_error(
"Invalid alert master key");
286 CKey key = vchSecret.GetKey();
289 "Unable to sign alert, check alert master key?\n");
294 "Failed to process alert.\n");
309 result.push_back(
Pair(
"nID", alert.
nID));
#define strprintf(format,...)
Value sendalert(const Array ¶ms, bool fHelp)
const_iterator begin() const
Value addnode(const Array ¶ms, bool fHelp)
std::vector< unsigned char > vchMsg
bool Sign(const uint256 &hash, std::vector< unsigned char > &vchSig) const
bool ProcessAlert(bool fThread=true)
Double ended buffer combining vector and stream-like interfaces.
Object JSONRPCError(int code, const string &message)
vector< std::string > vAddedNodes
Config::Object_type Object
An alert is a combination of a serialized CUnsignedAlert and a signature.
CPubKey GetPubKey() const
A base58-encoded secret key.
A combination of a network address (CNetAddr) and a (TCP) port.
Alerts are for notifying old versions if they become too obsolete and need to upgrade.
An encapsulated public key.
static const Value_impl null
Value getconnectioncount(const Array ¶ms, bool fHelp)
void MakeNewKey(bool fCompressed)
A CService with information about it as peer.
std::string ToString() const
uint256 Hash(const T1 pbegin, const T1 pend)
Value makekeypair(const Array ¶ms, bool fHelp)
std::vector< unsigned char > vchSig
CNode * ConnectNode(CAddress addrConnect, const char *pszDest)
const unsigned char * begin() const
CCriticalSection cs_vAddedNodes
Value getpeerinfo(const Array ¶ms, bool fHelp)
bool RelayTo(CNode *pnode) const
bool Lookup(const char *pszName, std::vector< CService > &vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions)
Value getaddednodeinfo(const Array ¶ms, bool fHelp)
An encapsulated private key.
Information about a peer.
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
std::string get_str(std::string::const_iterator begin, std::string::const_iterator end)
void copyStats(CNodeStats &stats)
CCriticalSection cs_vNodes
const unsigned char * end() const
const_iterator end() const