def register(ctx): '''Adds a user to the database, generates a wallet for them, gives them its address to send funds to.''' # Author is a Member id = ctx.message.author.id name = ctx.message.author.name if is_registered(id): yield from bot.say( 'You are already registered. Use ?getaddress to get your tip wallet address' ) return new_user(id, name) # Generate a new address dconn = Bitcoind('~/.dashcore/dash.conf', rpcport=19998) # testnet, 9998 is realnet addr = dconn.getnewaddress() dconn.setaccount(addr, id) # Generate and save a QR code with the address im = qrcode.make(addr) filename = '/tmp/' + addr + '.png' im.save(filename, 'png') yield from bot.say( 'Welcome %s, your tip wallet address is %s.\nPlease send some dash here to be able to tip.' % (name, addr)) yield from bot.send_file(ctx.message.channel, filename) # Clean up the image file os.remove(filename)
def getaddress(ctx): '''Resends the user's current account address''' # Author is a Member id = ctx.message.author.id if not is_registered(id): yield from bot.say( 'You are not registered. Use ?register to create an account.') return dconn = Bitcoind('~/.dashcore/dash.conf', rpcport=19998) # testnet, 9998 is realnet addr = dconn.getaccountaddress(id) dconn.setaccount(addr, id) # Generate and save a QR code with the address im = qrcode.make(addr) filename = '/tmp/' + addr + '.png' im.save(filename, 'png') yield from bot.say('Your tip wallet address is %s.' % (addr)) yield from bot.send_file(ctx.message.channel, filename) # Clean up the image file os.remove(filename)