This is a pure refactoring (no functional changes) that clarifies the use of CWallet::encrypted_batch
as well as the code using it according to my proposal in #14139. (A more detailed description and rationale can be found there.)
The change is split in two commits that correspond to logical units (matching the description in the proposal): A general cleanup of the code and the use of RAII (as also recommended in the developer guidelines) for setting/resetting encrypted_batch
temporarily. In case the second commit is seen as overengineering, I’m happy to change the PR to include just the first commit.
The second commit (using RAII) obsoletes #14138.