makekeypair

This commit is contained in:
zetacoin
2013-12-28 12:37:24 +02:00
parent e8041944dd
commit 6c0e79376a
2 changed files with 34 additions and 2 deletions
+32
View File
@@ -182,7 +182,38 @@ Value stop(const Array& params, bool fHelp)
return "Zetacoin server stopping";
}
Value makekeypair(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 1)
throw runtime_error(
"makekeypair [prefix]\n"
"Make a public/private key pair.\n"
"[prefix] is optional preferred prefix for the public key.\n");
string strPrefix = "";
if (params.size() > 0)
strPrefix = params[0].get_str();
CKey key;
CPubKey pubkey;
string pubkeyhex;
int nCount = 0;
do
{
key.MakeNewKey(false);
nCount++;
pubkey = key.GetPubKey();
pubkeyhex = HexStr(pubkey.begin(), pubkey.end());
} while (nCount < 10000 && strPrefix != pubkeyhex.substr(0, strPrefix.size()));
if (strPrefix != pubkeyhex.substr(0, strPrefix.size()))
return Value::null;
Object result;
result.push_back(Pair("PublicKey", pubkeyhex));
result.push_back(Pair("PrivateKey", CBitcoinSecret(key).ToString()));
return result;
}
//
// Call Table
@@ -258,6 +289,7 @@ static const CRPCCommand vRPCCommands[] =
{ "lockunspent", &lockunspent, false, false },
{ "listlockunspent", &listlockunspent, false, false },
{ "verifychain", &verifychain, true, false },
{ "makekeypair", &makekeypair, false, false },
};
CRPCTable::CRPCTable()
+2 -2
View File
@@ -27,7 +27,7 @@ public:
pchMessageStart[1] = 0xb5;
pchMessageStart[2] = 0x03;
pchMessageStart[3] = 0xdf;
vAlertPubKey = ParseHex("04f09702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");
vAlertPubKey = ParseHex("045337216002ca6a71d63edf062895417610a723d453e722bf4728996c58661cdac3d4dec5cecd449b9086e9602b35cc726a9e0163e1a4d40f521fbdaebb674658");
nDefaultPort = 17333;
nRPCPort = 8332;
bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);
@@ -119,7 +119,7 @@ public:
pchMessageStart[1] = 0xfe;
pchMessageStart[2] = 0xa9;
pchMessageStart[3] = 0x01;
vAlertPubKey = ParseHex("04303390343f91cc401d56d68b123028bf52e5fca1939df127f63c6467cdf9c8e2c14b61104cf817d0b780da337893ecc4aaff1309e536162dabbdb45200ca2b0a");
vAlertPubKey = ParseHex("04deffaef5b9552d1635013708eff25f2fac734cd6720d86fe83f9618572eb095b738efd752128b885c40ca0a37535df5a4b2b2cae5c80cea9bf315fb67ce9fcb2");
nDefaultPort = 27333;
nRPCPort = 18332;
strDataDir = "testnet";