#!/usr/bin/env python

import sys, electrum

i = electrum.Interface()
i.register_callback('connected', lambda: sys.stderr.write("Connected to %s\n" % i.connection_msg))
i.start()
i.send([('blockchain.numblocks.subscribe',[])])

while True:
    try:
        r = i.get_response()
    except KeyboardInterrupt:
        break
    if r.get('method') == 'blockchain.numblocks.subscribe':
        print r.get('result')