This logic is reused multiple times. It might make sense to factor it out into a helper method in a future PR. _Originally posted by @samdealy in https://github.com/mobilecoinfoundation/mobilecoin/pull/3315#discussion_r1170570845_