def run(self): # TODO this thread doesnt wake up for what could be hours # need a loop that periodically checks self.finished # TODO another issue is, what if the bot has run out of utxos and # needs to wait for some tx to confirm before it can trade # presumably it needs to wait here until the tx confirms time.sleep(self.tmaker.waittime) if self.finished: return print 'giving up waiting' # cancel the remaining order self.tmaker.modify_orders([0], []) orders, total_cj_fee = choose_orders(self.tmaker.db, self.tmaker.amount, self.tmaker.makercount, weighted_order_choose) print 'chosen orders to fill ' + str(orders) + ' totalcjfee=' + str( total_cj_fee) total_amount = self.tmaker.amount + total_cj_fee + self.tmaker.txfee print 'total amount spent = ' + str(total_amount) utxos = self.tmaker.wallet.select_utxos(self.tmaker.mixdepth, total_amount) self.tmaker.start_cj( self.tmaker.wallet, self.tmaker.amount, orders, utxos, self.tmaker.destaddr, self.tmaker.wallet.get_internal_addr(self.tmaker.mixdepth), self.tmaker.txfee, self.finishcallback)
def tumbler_choose_orders(self, cj_amount, makercount, nonrespondants=None, active_nicks=None): if nonrespondants is None: nonrespondants = [] if active_nicks is None: active_nicks = [] self.ignored_makers += nonrespondants while True: orders, total_cj_fee = choose_orders( self.taker.db, cj_amount, makercount, weighted_order_choose, self.ignored_makers + active_nicks) abs_cj_fee = 1.0 * total_cj_fee / makercount rel_cj_fee = abs_cj_fee / cj_amount log.debug('rel/abs average fee = ' + str(rel_cj_fee) + ' / ' + str( abs_cj_fee)) if rel_cj_fee > self.taker.options['maxcjfee'][ 0] and abs_cj_fee > self.taker.options['maxcjfee'][1]: log.debug('cj fee higher than maxcjfee, waiting ' + str( self.taker.options['liquiditywait']) + ' seconds') time.sleep(self.taker.options['liquiditywait']) continue if orders is None: log.debug('waiting for liquidity ' + str( self.taker.options['liquiditywait']) + 'secs, hopefully more orders should come in') time.sleep(self.taker.options['liquiditywait']) continue break log.debug('chosen orders to fill ' + str(orders) + ' totalcjfee=' + str( total_cj_fee)) return orders, total_cj_fee
def tumbler_choose_orders(self, cj_amount, makercount, nonrespondants=None, active_nicks=None): if nonrespondants is None: nonrespondants = [] if active_nicks is None: active_nicks = [] self.ignored_makers += nonrespondants while True: orders, total_cj_fee = choose_orders( self.taker.db, cj_amount, makercount, weighted_order_choose, self.ignored_makers + active_nicks) abs_cj_fee = 1.0 * total_cj_fee / makercount rel_cj_fee = abs_cj_fee / cj_amount log.debug('rel/abs average fee = ' + str(rel_cj_fee) + ' / ' + str(abs_cj_fee)) if rel_cj_fee > self.taker.options.maxcjfee[ 0] and abs_cj_fee > self.taker.options.maxcjfee[1]: log.debug('cj fee higher than maxcjfee, waiting ' + str(self.taker.options.liquiditywait) + ' seconds') time.sleep(self.taker.options.liquiditywait) continue if orders is None: log.debug('waiting for liquidity ' + str(self.taker.options.liquiditywait) + 'secs, hopefully more orders should come in') time.sleep(self.taker.options.liquiditywait) continue break log.debug('chosen orders to fill ' + str(orders) + ' totalcjfee=' + str(total_cj_fee)) return orders, total_cj_fee
def sendpayment_choose_orders(self, cj_amount, makercount, nonrespondants=None, active_nicks=None): if nonrespondants is None: nonrespondants = [] if active_nicks is None: active_nicks = [] self.ignored_makers += nonrespondants orders, total_cj_fee = choose_orders( self.taker.db, cj_amount, makercount, self.taker.chooseOrdersFunc, self.ignored_makers + active_nicks) if not orders: return None, 0 print('chosen orders to fill ' + str(orders) + ' totalcjfee=' + str(total_cj_fee)) if not self.taker.answeryes: if len(self.ignored_makers) > 0: noun = 'total' else: noun = 'additional' total_fee_pc = 1.0 * total_cj_fee / cj_amount log.debug(noun + ' coinjoin fee = ' + str(float('%.3g' % (100.0 * total_fee_pc))) + '%') check_high_fee(total_fee_pc) if raw_input('send with these orders? (y/n):')[0] != 'y': log.debug('ending') self.taker.msgchan.shutdown() return None, -1 return orders, total_cj_fee
def sendpayment_choose_orders(self, cj_amount, makercount, nonrespondants=None, active_nicks=None): if nonrespondants is None: nonrespondants = [] if active_nicks is None: active_nicks = [] self.ignored_makers += nonrespondants orders, total_cj_fee = choose_orders( self.taker.db, cj_amount, makercount, self.taker.chooseOrdersFunc, self.ignored_makers + active_nicks) if not orders: return None, 0 print('chosen orders to fill ' + str(orders) + ' totalcjfee=' + str( total_cj_fee)) if not self.taker.answeryes: if len(self.ignored_makers) > 0: noun = 'total' else: noun = 'additional' total_fee_pc = 1.0 * total_cj_fee / cj_amount log.debug(noun + ' coinjoin fee = ' + str(float('%.3g' % ( 100.0 * total_fee_pc))) + '%') check_high_fee(total_fee_pc) if raw_input('send with these orders? (y/n):')[0] != 'y': log.debug('ending') self.taker.msgchan.shutdown() return None, -1 return orders, total_cj_fee
def sendpayment_choose_orders(self, cj_amount, makercount, nonrespondants=None, active_nicks=None): if nonrespondants is None: nonrespondants = [] if active_nicks is None: active_nicks = [] self.ignored_makers += nonrespondants orders, total_cj_fee = choose_orders( self.taker.db, cj_amount, makercount, self.taker.chooseOrdersFunc, self.ignored_makers + active_nicks) if not orders: return None, 0 log.debug('chosen orders to fill ' + str(orders) + ' totalcjfee=' + str( total_cj_fee)) return orders, total_cj_fee
def sendpayment_choose_orders(self, cj_amount, makercount, nonrespondants=None, active_nicks=None): if nonrespondants is None: nonrespondants = [] if active_nicks is None: active_nicks = [] self.ignored_makers += nonrespondants orders, total_cj_fee = choose_orders( self.taker.db, cj_amount, makercount, self.taker.chooseOrdersFunc, self.ignored_makers + active_nicks) if not orders: return None, 0 print('chosen orders to fill ' + str(orders) + ' totalcjfee=' + str(total_cj_fee)) if not self.taker.answeryes: if len(self.ignored_makers) > 0: noun = 'total' else: noun = 'additional' total_fee_pc = 1.0 * total_cj_fee / cj_amount log.info(noun + ' coinjoin fee = ' + str(float('%.3g' % (100.0 * total_fee_pc))) + '%') check_high_fee(total_fee_pc) if jm_single().config.getint("POLICY", "minimum_makers") != 0: log.info("If some makers don't respond, we will still " "create a coinjoin with at least " + str(jm_single().config.getint( "POLICY", "minimum_makers")) + ". " "If you don't want this feature, set minimum_makers=" "0 in joinmarket.cfg") if raw_input('send with these orders? (y/n):')[0] != 'y': log.info('ending') self.taker.msgchan.shutdown() return None, -1 return orders, total_cj_fee