mirror of
https://github.com/dashpay/dash.git
synced 2024-12-30 14:25:53 +01:00
Add makekeypair to generate ECDSA keys
Use this to generate keys for use in alert.cpp to replace old Litecoin keys.
This commit is contained in:
parent
0f2c10e18a
commit
ff3bb3d69e
@ -252,6 +252,7 @@ static const CRPCCommand vRPCCommands[] =
|
|||||||
{ "submitblock", &submitblock, false, false, false },
|
{ "submitblock", &submitblock, false, false, false },
|
||||||
{ "setmininput", &setmininput, false, false, false },
|
{ "setmininput", &setmininput, false, false, false },
|
||||||
{ "listsinceblock", &listsinceblock, false, false, true },
|
{ "listsinceblock", &listsinceblock, false, false, true },
|
||||||
|
{ "makekeypair", &makekeypair, true, false, true },
|
||||||
{ "dumpprivkey", &dumpprivkey, true, false, true },
|
{ "dumpprivkey", &dumpprivkey, true, false, true },
|
||||||
{ "importprivkey", &importprivkey, false, false, true },
|
{ "importprivkey", &importprivkey, false, false, true },
|
||||||
{ "listunspent", &listunspent, false, false, true },
|
{ "listunspent", &listunspent, false, false, true },
|
||||||
|
@ -175,6 +175,7 @@ extern json_spirit::Value listtransactions(const json_spirit::Array& params, boo
|
|||||||
extern json_spirit::Value listaddressgroupings(const json_spirit::Array& params, bool fHelp);
|
extern json_spirit::Value listaddressgroupings(const json_spirit::Array& params, bool fHelp);
|
||||||
extern json_spirit::Value listaccounts(const json_spirit::Array& params, bool fHelp);
|
extern json_spirit::Value listaccounts(const json_spirit::Array& params, bool fHelp);
|
||||||
extern json_spirit::Value listsinceblock(const json_spirit::Array& params, bool fHelp);
|
extern json_spirit::Value listsinceblock(const json_spirit::Array& params, bool fHelp);
|
||||||
|
extern json_spirit::Value makekeypair(const json_spirit::Array& params, bool fHelp);
|
||||||
extern json_spirit::Value gettransaction(const json_spirit::Array& params, bool fHelp);
|
extern json_spirit::Value gettransaction(const json_spirit::Array& params, bool fHelp);
|
||||||
extern json_spirit::Value backupwallet(const json_spirit::Array& params, bool fHelp);
|
extern json_spirit::Value backupwallet(const json_spirit::Array& params, bool fHelp);
|
||||||
extern json_spirit::Value keypoolrefill(const json_spirit::Array& params, bool fHelp);
|
extern json_spirit::Value keypoolrefill(const json_spirit::Array& params, bool fHelp);
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "bitcoinrpc.h"
|
#include "bitcoinrpc.h"
|
||||||
|
#include "alert.h"
|
||||||
|
#include "base58.h"
|
||||||
|
|
||||||
using namespace json_spirit;
|
using namespace json_spirit;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -206,3 +208,33 @@ Value getaddednodeinfo(const Array& params, bool fHelp)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
int nCount = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
key.MakeNewKey(false);
|
||||||
|
pubkey = key.GetPubKey();
|
||||||
|
nCount++;
|
||||||
|
} while (nCount < 10000 && strPrefix != HexStr(pubkey.begin(), pubkey.end()).substr(0, strPrefix.size()));
|
||||||
|
|
||||||
|
if (strPrefix != HexStr(pubkey.begin(), pubkey.end()).substr(0, strPrefix.size()))
|
||||||
|
return Value::null;
|
||||||
|
|
||||||
|
Object result;
|
||||||
|
result.push_back(Pair("PublicKey", HexStr(pubkey.begin(), pubkey.end())));
|
||||||
|
result.push_back(Pair("PrivateKey", CBitcoinSecret(key).ToString()));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user