def make_wallets(n, wallet_structures=None, mean_amt=1, sdev_amt=0): '''n: number of wallets to be created wallet_structure: array of n arrays , each subarray specifying the number of addresses to be populated with coins at each depth (for now, this will only populate coins into 'receive' addresses) mean_amt: the number of coins (in btc units) in each address as above sdev_amt: if randomness in amouts is desired, specify here. Returns: a dict of dicts of form {0:{'seed':seed,'wallet':Wallet object},1:..,}''' if len(wallet_structures) != n: raise Exception("Number of wallets doesn't match wallet structures") seeds = common.chunks(binascii.hexlify(os.urandom(15 * n)), n) wallets = {} for i in range(n): wallets[i] = { 'seed': seeds[i], 'wallet': common.Wallet(seeds[i], max_mix_depth=5) } for j in range(5): for k in range(wallet_structures[i][j]): deviation = sdev_amt * random.random() amt = mean_amt - sdev_amt / 2.0 + deviation if amt < 0: amt = 0.001 common.bc_interface.grab_coins( wallets[i]['wallet'].get_receive_addr(j), amt) return wallets
def setUp(self): #create 2 new random wallets. #put 100 coins into the first receive address #to allow that bot to start. seed1, seed2 = [ binascii.hexlify(x) for x in [os.urandom(15), os.urandom(15)] ] self.wallets = {} wallet1 = common.Wallet(seed1) wallet2 = common.Wallet(seed2) self.wallets[1] = {'seed': seed1, 'wallet': wallet1} self.wallets[2] = {'seed': seed2, 'wallet': wallet2} #get first address in each wallet addr1 = wallet1.get_receive_addr(0) common.debug("address for wallet1: " + addr1) addr2 = wallet2.get_receive_addr(0) common.debug("address for wallet2: " + addr2) common.bc_interface.grab_coins(addr1, 10) common.bc_interface.grab_coins(addr2, 10)
def setUp(self): self.n = 2 #create n+1 new random wallets. #put 10 coins into the first receive address #to allow that bot to start. seeds = map(None, *([iter(os.urandom((self.n + 1) * 15))] * 15)) seeds = [binascii.hexlify(''.join(x)) for x in seeds] self.wallets = {} for i, seed in enumerate(seeds): self.wallets[i] = {'seed': seed, 'wallet': common.Wallet(seed)} #get first address in each wallet for i in self.wallets.keys(): common.bc_interface.grab_coins( self.wallets[i]['wallet'].get_receive_addr(0), amt=10)