1
0

create scripts directory

This commit is contained in:
thomasv
2012-10-08 15:19:05 +02:00
parent 880b08f337
commit e70c20803f
5 changed files with 2 additions and 2 deletions

16
scripts/blocks Executable file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/env python
from electrum import TcpStratumInterface
i = TcpStratumInterface('electrum.novit.ro', 50001)
i.init_socket()
i.start()
i.send([('blockchain.numblocks.subscribe',[])])
while True:
try:
r = i.responses.get(True, 100000000000)
except KeyboardInterrupt:
break
if r.get('method') == 'blockchain.numblocks.subscribe':
print r.get('result')

29
scripts/get_history Executable file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/env python
import sys
from electrum import TcpStratumInterface
try:
addr = sys.argv[1]
except:
print "usage: get_history <bitcoin_address>"
sys.exit(1)
i = TcpStratumInterface('electrum.novit.ro', 50001)
i.init_socket()
i.start()
i.send([('blockchain.address.get_history',[addr])])
while True:
try:
r = i.responses.get(True, 100000000000)
except KeyboardInterrupt:
break
method = r.get('method')
if method == 'blockchain.address.get_history':
confirmed = unconfirmed = 0
h = r.get('result')
for item in h:
print item['tx_hash'], item['value']
break

12
scripts/peers Executable file
View File

@@ -0,0 +1,12 @@
#!/usr/bin/env python
from electrum import TcpStratumInterface
i = TcpStratumInterface('electrum.novit.ro', 50001)
i.init_socket()
i.start()
i.send([('server.peers.subscribe',[])])
while True:
r = i.responses.get(True, 100000000000)
print r.get('result')

35
scripts/watch_address Executable file
View File

@@ -0,0 +1,35 @@
#!/usr/bin/env python
import sys
from electrum import TcpStratumInterface
try:
addr = sys.argv[1]
except:
print "usage: watch_address <bitcoin_address>"
sys.exit(1)
i = TcpStratumInterface('electrum.novit.ro', 50001)
i.init_socket()
i.start()
i.send([('blockchain.address.subscribe',[addr])])
while True:
r = i.responses.get(True, 100000000000)
method = r.get('method')
if method == 'blockchain.address.subscribe':
i.send([('blockchain.address.get_history',[addr])])
elif method == 'blockchain.address.get_history':
confirmed = unconfirmed = 0
h = r.get('result')
if h is None:
continue
for item in h:
v = item['value']
if item['height']:
confirmed += v
else:
unconfirmed += v
print (confirmed+unconfirmed)/1.e8