|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
|
import sys |
|
|
import sys |
|
|
import time |
|
|
import time |
|
|
|
|
|
from electrum import bitcoin |
|
|
from electrum import SimpleConfig, Network |
|
|
from electrum import SimpleConfig, Network |
|
|
from electrum.util import print_msg, json_encode |
|
|
from electrum.util import print_msg, json_encode |
|
|
|
|
|
|
|
@ -11,6 +12,8 @@ except Exception: |
|
|
print("usage: watch_address <bitcoin_address>") |
|
|
print("usage: watch_address <bitcoin_address>") |
|
|
sys.exit(1) |
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
|
|
|
sh = bitcoin.address_to_scripthash(addr) |
|
|
|
|
|
|
|
|
# start network |
|
|
# start network |
|
|
c = SimpleConfig() |
|
|
c = SimpleConfig() |
|
|
network = Network(c) |
|
|
network = Network(c) |
|
@ -26,7 +29,7 @@ if not network.is_connected(): |
|
|
|
|
|
|
|
|
# 2. send the subscription |
|
|
# 2. send the subscription |
|
|
callback = lambda response: print_msg(json_encode(response.get('result'))) |
|
|
callback = lambda response: print_msg(json_encode(response.get('result'))) |
|
|
network.send([('blockchain.address.subscribe',[addr])], callback) |
|
|
network.send([('blockchain.scripthash.subscribe',[sh])], callback) |
|
|
|
|
|
|
|
|
# 3. wait for results |
|
|
# 3. wait for results |
|
|
while network.is_connected(): |
|
|
while network.is_connected(): |
|
|