Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- import time
- import json
- from bitcoinrpc.authproxy import AuthServiceProxy
- #Address to connect with local wallet running as rpc server
- url = "http://user:pass@localhost:50554/"
- #Setup connection and check balance
- conn = AuthServiceProxy(url)
- data = conn.getbalance()
- print data
- #Open output file for recording transaction ids
- outputtx = open('outputtx.txt', 'w')
- outputtx.write('{0}, {1}, {2}, {3}\n'.format("list#", "userid", "useraddress", "tx id"))
- #Run through list of all addresses and only add ones not banned
- goodlist = [] #the list of good addresses
- with open('TALK.csv', 'rb') as alladdresses: #TALK.csv is just the google doc listed exported as csv
- reader = csv.reader(alladdresses)
- for row in reader:
- #All bad address have a note in column 5, so if its length is short it's good
- if len(row[5]) < 2:
- goodlist.append(row)
- else:
- print "Banned!!!", row
- #Run through the goodlist and send coins to each address, make note of tx, and wait
- for idx, val in enumerate(goodlist):
- #Make val idx variables explicit
- userid = val[0]
- useraddress = val[1]
- #Check is address is valid
- print "Validating user {0} @ {1}".format(userid, useraddress)
- isvalid = conn.validateaddress(useraddress)[u'isvalid']
- time.sleep(3)
- if isvalid == True:
- #Send pi coins to each address
- try:
- print "Sending coins to {0} @ {1}".format(userid, useraddress)
- senttx = conn.sendtoaddress(useraddress, 3.14159265, 'test airdrop', 'test airdrop')
- print "coins sent!"
- time.sleep(1)
- except:
- print "Failed!"
- senttx = 'FAILED TX'
- time.sleep(1)
- else:
- print "Bad address!!!"
- #Log user info and tx id
- outputtx.write('{0}, {1}, {2}, {3}\n'.format(idx+1, userid, useraddress, senttx))
- time.sleep(17)
- #Close output file
- outputtx.close()
- #Check balance should be about 3606 less than first check
- data = conn.getbalance()
- print data
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement