Advertisement
jwinterm

BTCtalksender

May 29th, 2014
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.06 KB | None | 0 0
  1. import csv
  2. import time
  3. import json
  4. from bitcoinrpc.authproxy import AuthServiceProxy
  5.  
  6. #Address to connect with local wallet running as rpc server
  7. url = "http://user:pass@localhost:50554/"
  8.  
  9. #Setup connection and check balance
  10. conn = AuthServiceProxy(url)
  11. data = conn.getbalance()
  12. print data
  13.  
  14. #Open output file for recording transaction ids
  15. outputtx = open('outputtx.txt', 'w')
  16. outputtx.write('{0}, {1}, {2}, {3}\n'.format("list#", "userid", "useraddress", "tx id"))
  17.  
  18. #Run through list of all addresses and only add ones not banned
  19. goodlist = []    #the list of good addresses
  20. with open('TALK.csv', 'rb') as alladdresses:      #TALK.csv is just the google doc listed exported as csv
  21.     reader = csv.reader(alladdresses)
  22.     for row in reader:
  23.         #All bad address have a note in column 5, so if its length is short it's good
  24.         if len(row[5]) < 2:
  25.             goodlist.append(row)
  26.         else:
  27.             print "Banned!!!", row
  28.            
  29. #Run through the goodlist and send coins to each address, make note of tx, and wait
  30. for idx, val in enumerate(goodlist):
  31.     #Make val idx variables explicit
  32.     userid = val[0]
  33.     useraddress = val[1]
  34.     #Check is address is valid
  35.     print "Validating user {0} @ {1}".format(userid, useraddress)
  36.     isvalid = conn.validateaddress(useraddress)[u'isvalid']
  37.     time.sleep(3)
  38.     if isvalid == True:
  39.         #Send pi coins to each address
  40.         try:
  41.             print "Sending coins to {0} @ {1}".format(userid, useraddress)
  42.             senttx = conn.sendtoaddress(useraddress, 3.14159265, 'test airdrop', 'test airdrop')
  43.             print "coins sent!"
  44.             time.sleep(1)
  45.         except:
  46.             print "Failed!"
  47.             senttx = 'FAILED TX'
  48.             time.sleep(1)    
  49.     else:
  50.         print "Bad address!!!"
  51.     #Log user info and tx id
  52.     outputtx.write('{0}, {1}, {2}, {3}\n'.format(idx+1, userid, useraddress, senttx))
  53.     time.sleep(17)
  54.  
  55. #Close output file
  56. outputtx.close()
  57.  
  58. #Check balance should be about 3606 less than first check
  59. data = conn.getbalance()
  60. print data
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement