bitcoin/bitcoin — pull request #3593 by laanwj (2014-01-28 09:06:50+00:00)
Title: 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.

check errors due to wrong encoding

importprivkey foo
error: {"code":-5,"message":"Invalid private key encoding"}

=0x00....

importprivkey cMahea7zqjxrtgAbB7LSGbcQUr1uX1ojuat9jZodMN87J7g8rY9t
error: {"code":-5,"message":"Private key outside allowed range"}

=0xFF....

importprivkey cWALDjUu1tszsCBMjBjL4mhtjHDZMS5U52WHJ29iqqspZx2Er6J2
error: {"code":-5,"message":"Private key outside allowed range"}

=n-1

importprivkey cWALDjUu1tszsCBMjBjL4mhYj2wHUWYDR8Q8aSjLKzjkW5eBtpzu
(ok)

=n

importprivkey cWALDjUu1tszsCBMjBjL4mhYj2wHUWYDR8Q8aSjLKzjkWaXMLRaY
error: {"code":-5,"message":"Private key outside allowed range"}