'Factory for exchanges.'

def make_exchange(self, route, amount, fee, participant, status=u'succeeded', error=u'', ref=u'dummy-trans-id', address=u'dummy-address'):

    if (not isinstance(route, ExchangeRoute)):
        network = route
        route = ExchangeRoute.from_network(participant, network)
        if (not route):
            route = ExchangeRoute.insert(participant, network, address)
            assert route
    e_id = record_exchange(self.db, route, amount, fee, participant, u'pre', ref)
    record_exchange_result(self.db, e_id, status, error, participant)
    return e_id
