namuyan

electrum-tcp-jsonrpc

May 27th, 2018
156
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import socket
  2. import threading
  3. import json
  4.  
  5. """
  6. 'electrumx.tamami-foundation.org s t',
  7. 'electrumx2.tamami-foundation.org s t',
  8. 'electrumx3.tamami-foundation.org s t',
  9. 'electrumx1.monacoin.nl s t',
  10. 'electrumx2.monacoin.nl s t',
  11. 'electrumx1.monacoin.ninja s t',
  12. 'electrumx2.monacoin.ninja s t',
  13. 'electrumx1.movsign.info t',
  14. 'electrumx2.movsign.info t',
  15. 'electrum-mona.bitbank.cc s t',
  16. """
  17. host = 'electrum-mona.bitbank.cc'
  18. port = 50001
  19.  
  20.  
  21. def message(sock):
  22.     while True:
  23.         msg = sock.recv(1024*4)
  24.         print(msg.decode())
  25.  
  26.  
  27. def main():
  28.     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  29.     sock.connect((host, port))
  30.     #sock.settimeout(5)
  31.     threading.Thread(
  32.         target=message,
  33.         args=(sock,),
  34.         daemon=True).start()
  35.     while True:
  36.         try:
  37.             cmd = input('>> ')
  38.             print("send", json.loads(cmd))
  39.             cmd += '\n'
  40.             sock.send(cmd.encode())
  41.         except (EOFError, KeyboardInterrupt):
  42.             break
  43.         except BaseException as e:
  44.             print(e)
  45.  
  46.  
  47. if __name__ == '__main__':
  48.     main()
RAW Paste Data