Fix: Prevent crash on null legacy_spkm in GetDescriptorsForLegacy
This pull request resolves a critical issue that caused Bitcoin Core to crash during legacy wallet migration. The ‘GetDescriptorsForLegacy’ function was not properly handling cases where ’legacy_spkm’ was a null pointer, leading to a dereference error.
This PR implements the following changes:
- Adds an explicit null pointer check for ’legacy_spkm’.
- Adds detailed error logging, including the key associated with the null pointer.
- Adds user-facing error messages to inform the user of the migration failure.
- Adds a unit test to ‘wallet_tests.cpp’ to ensure the fix is robust and to prevent future regressions.
This change improves the stability of the wallet migration process and provides better debugging information.