Exemple #1
0
    def run_simple_send(self, n):
        #start yield generator with wallet1
        yigen_proc = local_command(
            ['python', 'yield-generator.py',
             str(self.wallets[1]['seed'])],
            redirect=self.wallets[1]['seed'],
            bg=True)

        #A significant delay is needed to wait for the yield generator to sync its wallet
        time.sleep(30)

        #run a single sendpayment call with wallet2
        amt = 100000000  #in satoshis
        dest_address = btc.privkey_to_address(os.urandom(32),
                                              common.get_addr_vbyte())
        try:
            for i in range(n):
                sp_proc = local_command(['python','sendpayment.py','--yes','-N','1', self.wallets[2]['seed'],\
                                                      str(amt), dest_address])
        except subprocess.CalledProcessError, e:
            if yigen_proc:
                yigen_proc.terminate()
            print e.returncode
            print e.message
            raise
			def __init__(self, blockr_domain, txd, unconfirmfun, confirmfun):
				threading.Thread.__init__(self)
				self.daemon = True
				self.blockr_domain = blockr_domain
				self.unconfirmfun = unconfirmfun
				self.confirmfun = confirmfun
				self.tx_output_set = set([(sv['script'], sv['value']) for sv in txd['outs']])
				self.output_addresses = [btc.script_to_address(scrval[0],
					common.get_addr_vbyte()) for scrval in self.tx_output_set]
				common.debug('txoutset=' + pprint.pformat(self.tx_output_set))
				common.debug('outaddrs=' + ','.join(self.output_addresses))
 def __init__(self, blockr_domain, txd, unconfirmfun, confirmfun):
     threading.Thread.__init__(self)
     self.daemon = True
     self.blockr_domain = blockr_domain
     self.unconfirmfun = unconfirmfun
     self.confirmfun = confirmfun
     self.tx_output_set = set([(sv['script'], sv['value'])
                               for sv in txd['outs']])
     self.output_addresses = [
         btc.script_to_address(scrval[0], common.get_addr_vbyte())
         for scrval in self.tx_output_set
     ]
     common.debug('txoutset=' + pprint.pformat(self.tx_output_set))
     common.debug('outaddrs=' + ','.join(self.output_addresses))
	def add_tx_notify(self, txd, unconfirmfun, confirmfun, notifyaddr):
		if not self.notifythread:
			self.notifythread = BitcoinCoreNotifyThread(self)
			self.notifythread.start()
		one_addr_imported = False
		for outs in txd['outs']:
			addr = btc.script_to_address(outs['script'], common.get_addr_vbyte())
			if self.rpc('getaccount', [addr]) != '':
				one_addr_imported = True
				break
		if not one_addr_imported:
			self.rpc('importaddress', [notifyaddr, 'joinmarket-notify', False])
		tx_output_set = set([(sv['script'], sv['value']) for sv in txd['outs']])
		self.txnotify_fun.append((tx_output_set, unconfirmfun, confirmfun))
 def add_tx_notify(self, txd, unconfirmfun, confirmfun, notifyaddr):
     if not self.notifythread:
         self.notifythread = BitcoinCoreNotifyThread(self)
         self.notifythread.start()
     one_addr_imported = False
     for outs in txd['outs']:
         addr = btc.script_to_address(outs['script'],
                                      common.get_addr_vbyte())
         if self.rpc('getaccount', [addr]) != '':
             one_addr_imported = True
             break
     if not one_addr_imported:
         self.rpc('importaddress', [notifyaddr, 'joinmarket-notify', False])
     tx_output_set = set([(sv['script'], sv['value'])
                          for sv in txd['outs']])
     self.txnotify_fun.append((tx_output_set, unconfirmfun, confirmfun))
Exemple #6
0
    def run_simple_send(self, n):
        #start yield generator with wallet1
	yigen_proc = local_command(['python','yield-generator.py', 
	                            str(self.wallets[1]['seed'])],redirect=self.wallets[1]['seed'],bg=True)
	
	#A significant delay is needed to wait for the yield generator to sync its wallet
	time.sleep(30)
	
	#run a single sendpayment call with wallet2
	amt = 100000000 #in satoshis
	dest_address = btc.privkey_to_address(os.urandom(32), common.get_addr_vbyte())
	try:
	    for i in range(n):
		sp_proc = local_command(['python','sendpayment.py','--yes','-N','1', self.wallets[2]['seed'],\
	                                       str(amt), dest_address])
	except subprocess.CalledProcessError, e:
	    if yigen_proc:
		yigen_proc.terminate()
	    print e.returncode
	    print e.message
	    raise
Exemple #7
0
    def run_tumble(self, amt):
        yigen_procs = []
	for i in range(6):
	    ygp = local_command(['python','yield-generator.py',\
	                         str(self.wallets[i]['seed'])], bg=True)
	    time.sleep(2) #give it a chance
	    yigen_procs.append(ygp)
	
	#A significant delay is needed to wait for the yield generators to sync 
	time.sleep(60)
	
	#start a tumbler
	amt = amt*1e8 #in satoshis
	#send to any old address
	dest_address = btc.privkey_to_address(os.urandom(32), common.get_addr_vbyte())	
	try:
	    #default mixdepth source is zero, so will take coins from m 0.
	    #see tumbler.py --h for details
	    expected = ['tumble with these tx']
	    test_in = ['y']
	    p = pexpect.spawn('python',['tumbler.py', '-N', '1', '0',
	                             '-a', '0', '-M', '5', 
	                             self.wallets[6]['seed'], dest_address])
	    interact(p, test_in, expected)
	    p.expect(pexpect.EOF, timeout=100000)
	    p.close()
	    if p.exitstatus != 0:
		print 'failed due to exit status: '+str(p.exitstatus)
		return False
	    #print('use seed: '+self.wallets[6]['seed'])
	    #print('use dest addr: '+dest_address)
	    #ret = raw_input('quit?')
	except subprocess.CalledProcessError, e:
	    for ygp in yigen_procs:
		ygp.kill()
	    print e.returncode
	    print e.message
	    raise
Exemple #8
0
    def run_nparty_join(self):
	yigen_procs = []
	for i in range(self.n):
	    ygp = local_command(['python','yield-generator.py',\
	                         str(self.wallets[i]['seed'])], bg=True)
	    time.sleep(2) #give it a chance
	    yigen_procs.append(ygp)
	
	#A significant delay is needed to wait for the yield generators to sync 
	time.sleep(60)
	
	#run a single sendpayment call 
	amt = 100000000 #in satoshis
	dest_address = btc.privkey_to_address(os.urandom(32), common.get_addr_vbyte())	
	try:
	    sp_proc = local_command(['python','sendpayment.py','--yes','-N', str(self.n),\
	                             self.wallets[self.n]['seed'], str(amt), dest_address])
	except subprocess.CalledProcessError, e:
	    for ygp in yigen_procs:
		ygp.kill()
	    print e.returncode
	    print e.message
	    raise
Exemple #9
0
    def run_nparty_join(self):
        yigen_procs = []
        for i in range(self.n):
            ygp = local_command(['python','yield-generator.py',\
                                 str(self.wallets[i]['seed'])], bg=True)
            time.sleep(2)  #give it a chance
            yigen_procs.append(ygp)

        #A significant delay is needed to wait for the yield generators to sync
        time.sleep(60)

        #run a single sendpayment call
        amt = 100000000  #in satoshis
        dest_address = btc.privkey_to_address(os.urandom(32),
                                              common.get_addr_vbyte())
        try:
            sp_proc = local_command(['python','sendpayment.py','-N', str(self.n),\
                                     self.wallets[self.n]['seed'], str(amt), dest_address])
        except subprocess.CalledProcessError, e:
            for ygp in yigen_procs:
                ygp.kill()
            print e.returncode
            print e.message
            raise
Exemple #10
0
	for m in range(wallet.max_mix_depth):
		print 'mixing depth %d m/0/%d/' % (m, m)
		balance_depth = 0
		for forchange in [0, 1]:
			print(' ' + ('receive' if forchange==0 else 'change') +
				' addresses m/0/%d/%d/' % (m, forchange))
			for k in range(wallet.index[m][forchange] + options.gaplimit):
				addr = wallet.get_addr(m, forchange, k)
				balance = 0.0
				for addrvalue in wallet.unspent.values():
					if addr == addrvalue['address']:
						balance += addrvalue['value']
				balance_depth += balance
				used = ('used' if k < wallet.index[m][forchange] else ' new')
				privkey = btc.encode_privkey(wallet.get_key(m, forchange, k), 'wif_compressed',
					get_addr_vbyte()) if options.showprivkey else ''
				if method == 'displayall' or  balance > 0 or (used == ' new' and forchange==0):
					print '  m/0/%d/%d/%03d %-35s%s %.8f btc %s' % (m, forchange, k, addr, used, balance/1e8, privkey)
		print 'for mixdepth=%d balance=%.8fbtc' % (m, balance_depth/1e8)
		total_balance += balance_depth
	print 'total balance = %.8fbtc' % (total_balance/1e8)
elif method == 'summary':
	total_balance = 0
	for m in range(wallet.max_mix_depth):
		balance_depth = 0
		for forchange in [0, 1]:
			for k in range(wallet.index[m][forchange]):
				addr = wallet.get_addr(m, forchange, k)
				for addrvalue in wallet.unspent.values():
					if addr == addrvalue['address']:
						balance_depth += addrvalue['value']
Exemple #11
0
        print 'mixing depth %d m/0/%d/' % (m, m)
        balance_depth = 0
        for forchange in [0, 1]:
            print(' ' + ('receive' if forchange == 0 else 'change') +
                  ' addresses m/0/%d/%d/' % (m, forchange))
            for k in range(wallet.index[m][forchange] + options.gaplimit):
                addr = wallet.get_addr(m, forchange, k)
                balance = 0.0
                for addrvalue in wallet.unspent.values():
                    if addr == addrvalue['address']:
                        balance += addrvalue['value']
                balance_depth += balance
                used = ('used' if k < wallet.index[m][forchange] else ' new')
                privkey = btc.encode_privkey(
                    wallet.get_key(m, forchange, k), 'wif_compressed',
                    get_addr_vbyte()) if options.showprivkey else ''
                if method == 'displayall' or balance > 0 or (used == ' new' and
                                                             forchange == 0):
                    print '  m/0/%d/%d/%03d %-35s%s %.8f btc %s' % (
                        m, forchange, k, addr, used, balance / 1e8, privkey)
        print 'for mixdepth=%d balance=%.8fbtc' % (m, balance_depth / 1e8)
        total_balance += balance_depth
    print 'total balance = %.8fbtc' % (total_balance / 1e8)
elif method == 'summary':
    total_balance = 0
    for m in range(wallet.max_mix_depth):
        balance_depth = 0
        for forchange in [0, 1]:
            for k in range(wallet.index[m][forchange]):
                addr = wallet.get_addr(m, forchange, k)
                for addrvalue in wallet.unspent.values():