This is a first step towards closing #3314 by implementing functions in Wallet and ScriptPubKeyMan that determine if a key is "active" meaning "derived from a currently active scriptpubkey manager."
A key is NOT "active" if:
- It was imported using an
import{privkey, address, pubkey}rpc - It was derived before the wallet was encrypted (which replaces the active SPKM(s))
Users should be informed that these keys may be compromised:
- Some other wallet generated the private key and may still have a copy
- The private key was stored on disk unencrypted
This PR adds a new field isactive to rpc getaddressinfo, follow-up work will be adding this to the GUI address book as well, something like this. The original issue also recommends sweeping all value from keys in this category, I think that feature can be discussed in the future as a follow-up.
This PR also patches PKDescriptor from #22051 where matching public keys were not returned.
Follow-up PR for the GUI: https://github.com/bitcoin-core/gui/pull/723