electrum-bitcoinprivate/scripts/watch_address

35 lines
715 B
Plaintext
Raw Normal View History

2012-04-30 02:48:19 -07:00
#!/usr/bin/env python
2014-07-29 01:43:04 -07:00
import sys
import time
import 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
2014-07-29 01:43:04 -07:00
# start network
c = electrum.SimpleConfig()
s = electrum.daemon.get_daemon(c,True)
network = electrum.NetworkProxy(s,c)
network.start()
2012-04-30 02:48:19 -07:00
2014-07-29 01:43:04 -07:00
# wait until connected
while network.is_connecting():
time.sleep(0.1)
if not network.is_connected():
print_msg("daemon is not connected")
sys.exit(1)
2013-10-06 03:28:45 -07:00
# 2. send the subscription
2014-07-29 01:43:04 -07:00
callback = lambda response: electrum.print_json(response.get('result'))
network.send([('blockchain.address.subscribe',[addr])], callback)
2013-10-06 03:28:45 -07:00
# 3. wait for results
2014-07-29 01:43:04 -07:00
while network.is_connected():
2013-10-06 03:28:45 -07:00
time.sleep(1)