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:
Wladimir J. van der Laan
2014-06-16 14:45:32 +02:00
parent 6ad2c2402e
commit 6c37f7fd78
4 changed files with 137 additions and 6 deletions

View File

@@ -2010,11 +2010,7 @@ bool CReserveKey::GetReservedKey(CPubKey& pubkey)
if (nIndex != -1)
vchPubKey = keypool.vchPubKey;
else {
if (pwallet->vchDefaultKey.IsValid()) {
LogPrintf("CReserveKey::GetReservedKey(): Warning: Using default key instead of a new key, top up your keypool!");
vchPubKey = pwallet->vchDefaultKey;
} else
return false;
return false;
}
}
assert(vchPubKey.IsValid());