optimize txout caching: only wrap next_input if necessary