aboutsummaryrefslogtreecommitdiff
path: root/rpc.cpp
diff options
context:
space:
mode:
authorgavinandresen <gavinandresen@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-10-20 15:58:16 +0000
committergavinandresen <gavinandresen@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-10-20 15:58:16 +0000
commit2ea5fa07105ef52ba94c43e6a70a14ef6008abb0 (patch)
treefa04a1ed8e06d1c67a11ef9f38ef67fb5516e4b4 /rpc.cpp
parent5cbf75324d1509a1262b65c5073314a4da3f6d77 (diff)
validateaddress RPC command
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@169 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'rpc.cpp')
-rw-r--r--rpc.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/rpc.cpp b/rpc.cpp
index 88e44cc478..81d36b378b 100644
--- a/rpc.cpp
+++ b/rpc.cpp
@@ -654,7 +654,28 @@ Value backupwallet(const Array& params, bool fHelp)
return Value::null;
}
+Value validateaddress(const Array& params, bool fHelp)
+{
+ if (fHelp || params.size() != 1)
+ throw runtime_error(
+ "validateaddress <bitcoinaddress>\n"
+ "Return information about <bitcoinaddress>.");
+
+ string strAddress = params[0].get_str();
+ uint160 hash160;
+ bool isValid = AddressToHash160(strAddress, hash160);
+ Object ret;
+ ret.push_back(Pair("isvalid", isValid));
+ if (isValid)
+ {
+ // Call Hash160ToAddress() so we always return current ADDRESSVERSION
+ // version of the address:
+ ret.push_back(Pair("address", Hash160ToAddress(hash160)));
+ ret.push_back(Pair("ismine", (mapPubKeys.count(hash160) > 0)));
+ }
+ return ret;
+}
@@ -695,6 +716,7 @@ pair<string, rpcfn_type> pCallTable[] =
make_pair("listreceivedbyaddress", &listreceivedbyaddress),
make_pair("listreceivedbylabel", &listreceivedbylabel),
make_pair("backupwallet", &backupwallet),
+ make_pair("validateaddress", &validateaddress),
};
map<string, rpcfn_type> mapCallTable(pCallTable, pCallTable + sizeof(pCallTable)/sizeof(pCallTable[0]));
@@ -715,6 +737,7 @@ string pAllowInSafeMode[] =
"getlabel",
"getaddressesbylabel",
"backupwallet",
+ "validateaddress",
};
set<string> setAllowInSafeMode(pAllowInSafeMode, pAllowInSafeMode + sizeof(pAllowInSafeMode)/sizeof(pAllowInSafeMode[0]));