remove remote wallet (broken, will be replaced)
[electrum-nvc.git] / watch_address
1 #!/usr/bin/env python
2
3 import sys
4 from electrum import TcpStratumInterface
5
6 try:
7     addr = sys.argv[1]
8 except:
9     print "usage: watch_address <bitcoin_address>"
10     sys.exit(1)
11
12 i = TcpStratumInterface('electrum.novit.ro', 50001)
13 i.init_socket()
14 i.start()
15 i.send([('blockchain.address.subscribe',[addr])])
16
17 while True:
18     r = i.responses.get(True, 100000000000)
19     method = r.get('method') 
20     if method == 'blockchain.address.subscribe':
21         i.send([('blockchain.address.get_history',[addr])])
22     elif method == 'blockchain.address.get_history':
23         confirmed = unconfirmed = 0
24         h = r.get('result')
25         if h is None:
26             continue
27         for item in h:
28             v = item['value']
29             if item['height']:
30                 confirmed += v
31             else:
32                 unconfirmed += v
33         print (confirmed+unconfirmed)/1.e8
34
35