Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Descriptor expansions only need pubkey entries for PKH/WPKH #15263
Fix this by pushing the population of pubkey entries down into the individual descriptor implementation's
This should make it easier to implement #14491 without importing P2PKH outputs for the individual public keys listed inside a multisig.
Nit: the top comment of
This currently doesn't import the public keys, only the scripts. That can be solved by adding
Later on in the import process
This in turn is relevant for
That's where my brain gives up, but I'm guessing that
That's what the code originally was, before I complained that that would make outputs to multisig participant keys marked as IsMIne.
I agree this is hard to reason about... replacing all this logic with descriptor based logic will hopefully make it more transparent and with fewer gotchas.
Right, the problem is that our only way of importing a public key does two things that ought to be independent:
If it was just the first, it would be harmless; teaching how to sign something never hurts if you don't accidentally also make unrelated things treated as IsMine.
What this change does is make descriptor expansions for multisig no longer fill up the pubkeys that occur in the script. This is safe because they weren't actually needed for the first effect, and has the added benefit that when combined with the importmulti code will cause these multisig individual keys to not become watched.
However, it does keep the effect that when you import say a P2WPKH descriptor, the pubkey will be expanded, and then imported, causing P2PKH outputs for the same key to also become watched. Thankfully, that is "policy compatible" - anyone able to spend a P2WPKH output would also be able to spend the P2PKH version. It's unfortunate, but not a disaster. The full solution will be descriptor based IsMine logic, where we can exactly control what is treated as ours.
Is this import also what causes
Anyway, utACK 11e0fd8
@Sjors Similar but different effect.
For private keys we rely on the "ImplicitlyLearnRelatedScripts" function to know how to spend P2PKH/P2SH/P2WSH (in memory) for every private key in the wallet.
For public keys, the reason is that we only have one record (watch only keys) in the keystore for both watching and solving public key related scripts.