electrum-bitcoinprivate/scripts/watch_address

27 lines
593 B
Plaintext
Raw Normal View History

2012-04-30 02:48:19 -07:00
#!/usr/bin/env python
2013-10-06 03:28:45 -07:00
import sys, time, electrum
2012-05-10 05:38:49 -07:00
2012-04-30 02:48:19 -07:00
try:
addr = sys.argv[1]
2013-11-10 12:30:57 -08:00
except Exception:
2012-04-30 02:48:19 -07:00
print "usage: watch_address <bitcoin_address>"
2012-06-14 12:11:37 -07:00
sys.exit(1)
2012-04-30 02:48:19 -07:00
2013-10-06 03:28:45 -07:00
# 1. start the interface and wait for connection
interface = electrum.Interface('electrum.no-ip.org:50002:s')
interface.start(wait = True)
if not interface.is_connected:
print "not connected"
exit()
# 2. send the subscription
callback = lambda _,result: electrum.print_json(result.get('result'))
interface.send([('blockchain.address.subscribe',[addr])], callback)
# 3. wait for results
2012-04-30 02:48:19 -07:00
while True:
2013-10-06 03:28:45 -07:00
time.sleep(1)