Generalized getTransactions function.