Advertisement
Guest User

Untitled

a guest
Feb 10th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.15 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. import re
  4. import json
  5. import platform
  6. import os
  7. from slickrpc import Proxy
  8.  
  9.  
  10. # fucntion to define rpc_connection
  11. def def_credentials(chain):
  12.     rpcport = '';
  13.     operating_system = platform.system()
  14.     if operating_system == 'Darwin':
  15.         ac_dir = os.environ['HOME'] + '/Library/Application Support/Komodo'
  16.     elif operating_system == 'Linux':
  17.         ac_dir = os.environ['HOME'] + '/.komodo'
  18.     elif operating_system == 'Windows':
  19.         ac_dir = '%s/komodo/' % os.environ['APPDATA']
  20.     if chain == 'KMD':
  21.         coin_config_file = str(ac_dir + '/komodo.conf')
  22.     else:
  23.         coin_config_file = str(ac_dir + '/' + chain + '/' + chain + '.conf')
  24.     with open(coin_config_file, 'r') as f:
  25.         for line in f:
  26.             l = line.rstrip()
  27.             if re.search('rpcuser', l):
  28.                 rpcuser = l.replace('rpcuser=', '')
  29.             elif re.search('rpcpassword', l):
  30.                 rpcpassword = l.replace('rpcpassword=', '')
  31.             elif re.search('rpcport', l):
  32.                 rpcport = l.replace('rpcport=', '')
  33.     if len(rpcport) == 0:
  34.         if chain == 'KMD':
  35.             rpcport = 7771
  36.         else:
  37.             print("rpcport not in conf file, exiting")
  38.             print("check " + coin_config_file)
  39.             exit(1)
  40.  
  41.     return (Proxy("http://%s:%s@127.0.0.1:%d" % (rpcuser, rpcpassword, int(rpcport))))
  42.  
  43. CHAIN = 'LABSTRE'
  44. ADDRESS = 'RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA'
  45. rpc_connection = def_credentials(CHAIN)
  46.  
  47. getinfo_result = rpc_connection.getinfo()
  48. height = getinfo_result['blocks']
  49. getnotarysendmany_result = rpc_connection.getnotarysendmany()
  50.  
  51. for block in range(2,height):
  52.     getblock_result = rpc_connection.getblock(str(block), 2)
  53.     if len(getblock_result['tx'][0]['vout']) > 1:
  54.         vouts = getblock_result['tx'][0]['vout']
  55.         for vout in vouts[1:]:
  56.             blah = vout['scriptPubKey']['addresses'][0]
  57.             if blah in getnotarysendmany_result:
  58.                 getnotarysendmany_result[blah] += 1
  59.             else:
  60.                 print('what')
  61.  
  62. print(getnotarysendmany_result)
  63.  
  64.  
  65.  
  66.  
  67. #pprint.pprint(getraw_result['result']['vin'][0])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement