2018-08-14 09:19:55 +03:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import hashlib
|
|
|
|
import sys
|
2018-08-14 09:28:53 +03:00
|
|
|
import argparse
|
2018-08-14 09:19:55 +03:00
|
|
|
|
|
|
|
import client
|
|
|
|
|
|
|
|
def main():
|
2018-08-14 09:28:53 +03:00
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument('--testnet', action='store_true')
|
|
|
|
parser.add_argument('address', nargs='+')
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
if args.testnet:
|
|
|
|
port = 60001
|
2020-04-11 18:28:45 +03:00
|
|
|
from pycoin.symbols.xtn import network
|
2018-08-14 09:28:53 +03:00
|
|
|
else:
|
|
|
|
port = 50001
|
2020-04-11 18:28:45 +03:00
|
|
|
from pycoin.symbols.btc import network
|
2018-08-14 09:28:53 +03:00
|
|
|
|
2019-08-03 14:46:39 +03:00
|
|
|
conn = client.Client(('localhost', port))
|
2018-08-14 09:28:53 +03:00
|
|
|
for addr in args.address:
|
2020-04-11 18:28:45 +03:00
|
|
|
script = network.parse.address(addr).script()
|
2018-08-14 09:28:53 +03:00
|
|
|
script_hash = hashlib.sha256(script).digest()[::-1].hex()
|
|
|
|
reply = conn.call('blockchain.scripthash.get_balance', script_hash)
|
|
|
|
result = reply['result']
|
|
|
|
print('{} has {} satoshis'.format(addr, result))
|
2018-08-14 09:19:55 +03:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|