electrum-bitcoinprivate/scripts/watch_address

34 lines
731 B
Plaintext
Raw Permalink Normal View History

2017-09-05 06:27:08 -07:00
#!/usr/bin/env python3
2012-04-30 02:48:19 -07:00
2014-07-29 01:43:04 -07:00
import sys
import time
from electrum import SimpleConfig, Network
from electrum.util import print_msg, json_encode
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:
2017-09-05 06:27:08 -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 = SimpleConfig()
network = Network(c)
2014-07-29 01:43:04 -07:00
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
callback = lambda response: print_msg(json_encode(response.get('result')))
2014-07-29 01:43:04 -07:00
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)