As noted in #25634, encryptwallet
generates new keys or descriptors because:
We always want to rotate keys after encryption because the old keys were written to disk unencrypted and thus may have been compromised.
This makes sense for a wallet where the keys/descriptors were generated by the wallet itself. The problem arises when a user explicitly imports a key or descriptor to a previously blank wallet, or in the case of a legacy wallet when they run sethdseed
. This is because now the expectation is set that the wallet should only be using these keys/descriptors/seeds, so it is unexpected when the wallet uses something completely different upon encryption.
Note: Currently when a blank wallet with imported descriptors is encrypted, new descriptors are not generated, but this is considered a bug and will likely be fixed by #25634