I see, I agree that also works.
In Donation wallet, we keep a mapping between ScriptPubKey -> tweak
that we calculated during Step 2. Even though that is not a direct mapping from txid -> tweak
, you can still indirectly look up the tweak
of a transaction by looking at the outputs. I think this avoids having to scan all outputs of a block for every tweak, without needing to tag the tweaks with their txid
. However, it does require a grouping of the outputs.