In my Firebase database, I need two write to two locations at once. I have rules for both locations that ensure that a user can\'t write there without simultaneously writing
No. Transactions function on a single node.
That means that if you want to run a multi-location transaction, you will essentially have to run that transaction at the "lowest level shared node" in the tree. That is hardly ever a good idea.
The alternative would be to secure your multi-location write using server-side security rules. For an example of this, see Is the way the Firebase database quickstart handles counts secure?, which essentially builds a compare-and-set operation using security rules.