mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
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.
This commit is contained in:
parent
12e1fcc34e
commit
c7f9332596
1 changed files with 3 additions and 1 deletions
|
|
@ -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();
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue