def sendpayment_choose_orders(self, cj_amount, makercount, nonrespondants=[], 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.options.answeryes: if len(self.ignored_makers) > 0: noun = 'total' else: noun = 'additional' total_fee_pc = 1.0 * total_cj_fee / cj_amount debug(noun + ' coinjoin fee = ' + str(float('%.3g' % (100.0 * total_fee_pc))) + '%') sendpayment.check_high_fee(total_fee_pc) if raw_input('send with these orders? (y/n):')[0] != 'y': 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 active_nicks is None: active_nicks = [] if nonrespondants is None: nonrespondants = [] 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.options.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))) + '%') sendpayment.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 create_tx(self): crow = self.taker.db.execute( 'SELECT COUNT(DISTINCT counterparty) FROM orderbook;' ).fetchone() counterparty_count = crow['COUNT(DISTINCT counterparty)'] counterparty_count -= len(self.ignored_makers) if counterparty_count < self.taker.options.makercount: print 'not enough counterparties to fill order, ending' self.taker.msgchan.shutdown() return utxos = self.taker.utxo_data change_addr = None choose_orders_recover = None if self.taker.cjamount == 0: total_value = sum([va['value'] for va in utxos.values()]) orders, cjamount = choose_sweep_orders( self.taker.db, total_value, self.taker.options.txfee, self.taker.options.makercount, self.taker.chooseOrdersFunc, self.ignored_makers) if not self.taker.options.answeryes: total_cj_fee = total_value - cjamount - self.taker.options.txfee log.debug('total cj fee = ' + str(total_cj_fee)) total_fee_pc = 1.0 * total_cj_fee / cjamount log.debug('total coinjoin fee = ' + str(float('%.3g' % ( 100.0 * total_fee_pc))) + '%') sendpayment.check_high_fee(total_fee_pc) if raw_input('send with these orders? (y/n):')[0] != 'y': # noinspection PyTypeChecker self.finishcallback(None) return else: orders, total_cj_fee = self.sendpayment_choose_orders( self.taker.cjamount, self.taker.options.makercount) if not orders: log.debug( 'ERROR not enough liquidity in the orderbook, exiting') return total_amount = self.taker.cjamount + total_cj_fee + \ self.taker.options.txfee print 'total amount spent = ' + str(total_amount) cjamount = self.taker.cjamount change_addr = self.taker.changeaddr choose_orders_recover = self.sendpayment_choose_orders auth_addr = self.taker.utxo_data[self.taker.auth_utxo]['address'] self.taker.start_cj(self.taker.wallet, cjamount, orders, utxos, self.taker.destaddr, change_addr, self.taker.options.txfee, self.finishcallback, choose_orders_recover, auth_addr)