Creating an Ergo mining pool

There is an attack that we need to solve before this becomes pratical:

How to protect the transaction paying the mining pool? Since once the transaction becomes public, anyone else can broadcast it and miner will lose the ergs. Looking for suggestions on how to prevent it.

One solution seems to guard the pool funding input using a script that fixes the miner public key:

minerPubKey == <myPubKey>

We can make it more usable by allowing to withdraw the funds as well:

minerPubKey == <myPubKey> || <myPubKey>