Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge bitcoin#1401: [Wallet][Bug] Fix ScriptPubKeyMan::CanGetAddresses
5f21fc4 [Wallet] Properly return keys to external pool for non-HD wallets (random-zebra) 998cdb2 [Wallet][Bug] Fix ScriptPubKeyMan::CanGetAddresses (random-zebra) Pull request description: This fixes a bug found in the recent HD wallet implementation. Trying to send any transaction (included delegations) on non-upgraded wallets results in a crash due to the following assertion failure in `CWallet::CreateTransaction`: ```cpp // Reserve a new key pair from key pool CPubKey vchPubKey; bool ret; ret = reservekey.GetReservedKey(vchPubKey, true); assert(ret); // should never fail, as we just unlocked ``` **Cause**: `assert(ret)` fails here because `GetReservedKey` returns false on non-HD wallets requesting change addresses (or stake addresses) because, in this case, `CanGetAddresses` returns false: both `setInternalKeyPool` and `setStakingKeyPool` are empty. **Fix**: on wallets with HD disabled, `CanGetAddresses` should call `KeypoolCountExternalKeys` (which checks the size of `set_external_keypool`) with any changeType, as that's the pool used then in `ReserveKeyFromKeyPool`. ACKs for top commit: Fuzzbawls: utACK 5f21fc4 furszy: ACK 5f21fc4 and merging. Tree-SHA512: 65b7291a169ed617a5c148f137aa74a2f93509a8a65adb3d777efd7a5109ca7e0103612c24bea8b98c5262d018d53b96c68016d990b9ec5bf9ace031237e88c6
- Loading branch information