Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. import requests
  2. import json
  3.  
  4. def main():
  5. # default RPC port for XBY
  6. rpc_port = 34001
  7.  
  8. # RPC credentials, as specified in xtrabytes.conf
  9. rpc_user = "testuser"
  10. rpc_password = "testpassword"
  11.  
  12. # Generating the url from the specified credentials
  13. url = "http://" + rpc_user + ":" + rpc_password + "@localhost:" + str(rpc_port)
  14.  
  15. # Setting the header
  16. headers = {'content-type': 'application/json'}
  17.  
  18. # Specifying the recipients wallets. Although it might be easier to read from file/DB
  19. recipients = ['address1', 'address2', 'address3']
  20.  
  21. # Set amount
  22. amount_to_send = 1000
  23.  
  24. # Loop over the receiving addresses
  25. for recipient in recipients:
  26. # Example of sending the money transfer command
  27. payload = {
  28. "method": "sendtoaddress",
  29. "params": [recipient, amount_to_send],
  30. "jsonrpc": "2.0",
  31. "id": 0,
  32. }
  33.  
  34. # Send the RPC request
  35. response = requests.post(
  36. url, data=json.dumps(payload), headers=headers).json()
  37.  
  38. # Print the Response
  39. print(response.json()['result'])
  40.  
  41. if __name__ == "__main__":
  42. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement