Note: This backport apparently was skipped due to being (mostly) irrelevant changes that our linter takes care of anyway. But there was one line of code changed on wallet_basic and a few variable name changes that are being a pain, so I'm bringing in the relevant parts.
Backport of Core PR13136 (hiding whitespace changes makes this easier)