mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-06 01:41:01 +02:00
validateaddress RPC command
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@169 1a98c847-1fd6-4fd8-948a-caf3550aa51b
This commit is contained in:
parent
5cbf75324d
commit
2ea5fa0710
23
rpc.cpp
23
rpc.cpp
@ -654,7 +654,28 @@ Value backupwallet(const Array& params, bool fHelp)
|
|||||||
return Value::null;
|
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("listreceivedbyaddress", &listreceivedbyaddress),
|
||||||
make_pair("listreceivedbylabel", &listreceivedbylabel),
|
make_pair("listreceivedbylabel", &listreceivedbylabel),
|
||||||
make_pair("backupwallet", &backupwallet),
|
make_pair("backupwallet", &backupwallet),
|
||||||
|
make_pair("validateaddress", &validateaddress),
|
||||||
};
|
};
|
||||||
map<string, rpcfn_type> mapCallTable(pCallTable, pCallTable + sizeof(pCallTable)/sizeof(pCallTable[0]));
|
map<string, rpcfn_type> mapCallTable(pCallTable, pCallTable + sizeof(pCallTable)/sizeof(pCallTable[0]));
|
||||||
|
|
||||||
@ -715,6 +737,7 @@ string pAllowInSafeMode[] =
|
|||||||
"getlabel",
|
"getlabel",
|
||||||
"getaddressesbylabel",
|
"getaddressesbylabel",
|
||||||
"backupwallet",
|
"backupwallet",
|
||||||
|
"validateaddress",
|
||||||
};
|
};
|
||||||
set<string> setAllowInSafeMode(pAllowInSafeMode, pAllowInSafeMode + sizeof(pAllowInSafeMode)/sizeof(pAllowInSafeMode[0]));
|
set<string> setAllowInSafeMode(pAllowInSafeMode, pAllowInSafeMode + sizeof(pAllowInSafeMode)/sizeof(pAllowInSafeMode[0]));
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class CDataStream;
|
|||||||
class CAutoFile;
|
class CAutoFile;
|
||||||
static const unsigned int MAX_SIZE = 0x02000000;
|
static const unsigned int MAX_SIZE = 0x02000000;
|
||||||
|
|
||||||
static const int VERSION = 31305;
|
static const int VERSION = 31306;
|
||||||
static const char* pszSubVer = "";
|
static const char* pszSubVer = "";
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user