Skip to content

Commit

Permalink
add optional account parameter for importprivkey, if omitted use default
Browse files Browse the repository at this point in the history
  • Loading branch information
mhanne committed Jun 18, 2011
1 parent cdcd781 commit a774c70
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1428,12 +1428,14 @@ void GetWalletDump(map<uint160,CKeyDump> &mapDump)

Value importprivkey(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"importprivkey <bitcoinprivkey>\n"
"importprivkey <bitcoinprivkey> [account]\n"
"Adds a private key (as returned by dumpprivkey) to your wallet.");

string secret = params[0].get_str();
string strAccount = "";
if(params.size() > 1) strAccount = params[1].get_str();
uint256 privKey;
bool fGood = SecretToPrivKey(secret,privKey);

Expand All @@ -1448,7 +1450,6 @@ Value importprivkey(const Array& params, bool fHelp)
key.SetPrivKeyInner(privKey);
vector<unsigned char> vchPubKey = key.GetPubKey();
string strAddress = PubKeyToAddress(vchPubKey);
string strAccount = "imported";
SetAddressBookName(strAddress, strAccount);

if (!AddKey(key))
Expand Down

0 comments on commit a774c70

Please sign in to comment.