makekeypair rpc call

This commit is contained in:
myriadcoin
2014-08-10 22:55:27 +02:00
parent d4ca711da7
commit 5abb930261
4 changed files with 39 additions and 2 deletions
+33
View File
@@ -133,6 +133,39 @@ public:
};
#endif
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;
}
Value validateaddress(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
+1
View File
@@ -267,6 +267,7 @@ static const CRPCCommand vRPCCommands[] =
{ "createmultisig", &createmultisig, true, true , false },
{ "validateaddress", &validateaddress, true, false, false }, /* uses wallet if enabled */
{ "verifymessage", &verifymessage, false, false, false },
{ "makekeypair", &makekeypair, true, false, false },
#ifdef ENABLE_WALLET
/* Wallet */
+3
View File
@@ -188,4 +188,7 @@ extern json_spirit::Value gettxoutsetinfo(const json_spirit::Array& params, bool
extern json_spirit::Value gettxout(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value verifychain(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value makekeypair(const json_spirit::Array& params, bool fHelp);
#endif
+2 -2
View File
@@ -51,7 +51,7 @@ struct {
// NOTE: These tests rely on CreateNewBlock doing its own self-validation!
BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
{
CScript scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
CScript scriptPubKey = CScript() << ParseHex("04e89be8fd50694cb8263f50e36ec7c5d41ae58d6391795312bb23d3c6c58a9112fd2b1a178cc62e53ab9f8c595e4def299288e2cd42d3a86c7ee5203f00397a0c") << OP_CHECKSIG;
CBlockTemplate *pblocktemplate;
CTransaction tx,tx2;
CScript script;
@@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
for (unsigned int i = 0; i < sizeof(blockinfo)/sizeof(*blockinfo); ++i)
{
CBlock *pblock = &pblocktemplate->block; // pointer for convenience
pblock->nVersion = 1;
// pblock->nVersion = 1;
pblock->nTime = chainActive.Tip()->GetMedianTimePast()+1;
pblock->vtx[0].vin[0].scriptSig = CScript();
pblock->vtx[0].vin[0].scriptSig.push_back(blockinfo[i].extranonce);