descriptor: don't prepend key origins twice
OriginPubkeyProvider::GetPubKey() derives its sub-provider straight into the output provider and then prepends its origin to the entry it finds there. The sub-providers insert with emplace(), so if the same key was already expanded by another key expression the insert is a no-op and the entry that gets the origin prepended is the one that already has it. musig() is where this shows up, because it expands its participants into the provider it is given, so two musig() expressions in the same key expression list end up expanding a shared participant twice. A participant origin of m/86h/1h/0h then comes out as m/86h/1h/0h/86h/1h/0h in the input and output taproot BIP32 derivation maps of a PSBT, so a signer that follows them derives the wrong key. When the two expressions declare different origins for the participant, the fingerprint of one is combined with the path of both. Derive into a temporary provider and apply the origin there. Merge the rest into the output, then insert the clean origin separately. This avoids stacking paths and makes an explicit origin replace an implicit one already present for the same key.
S
Shuvam Pandey committed
b42f7fade0cd9a6fb3d69fcdff71436a99ba0005
Parent: 7b15e2c