Commit 55ba2f09 authored by Wladimir J. van der Laan's avatar Wladimir J. van der Laan
Browse files

Add check for valid keys in `importprivkey`

The base58 armoring was checked, but not the resulting private key,
which could be out of range. Fix this by adding a check.
parent 19a00829
Showing with 3 additions and 1 deletion
+3 -1
......@@ -101,9 +101,11 @@ Value importprivkey(const Array& params, bool fHelp)
CBitcoinSecret vchSecret;
bool fGood = vchSecret.SetString(strSecret);
if (!fGood) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key");
if (!fGood) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key encoding");
CKey key = vchSecret.GetKey();
if (!key.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Private key outside allowed range");
CPubKey pubkey = key.GetPubKey();
CKeyID vchAddress = pubkey.GetID();
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment