getrawchangeaddress should fail when keypool exhausted
An user on IRC reported an issue where `getrawchangeaddress` keeps returning a single address when the keypool is exhausted. In my opinion this is strange behaviour. - Change CReserveKey to fail when running out of keys in the keypool. - Make `getrawchangeaddress` return RPC_WALLET_KEYPOOL_RAN_OUT when unable to create an address. - Add a Python RPC test for checking the keypool behaviour in combination with encrypted wallets.
This commit is contained in:
@@ -201,7 +201,7 @@ Value getrawchangeaddress(const Array& params, bool fHelp)
|
||||
CReserveKey reservekey(pwalletMain);
|
||||
CPubKey vchPubKey;
|
||||
if (!reservekey.GetReservedKey(vchPubKey))
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Error: Unable to obtain key for change");
|
||||
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");
|
||||
|
||||
reservekey.KeepKey();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user