Files
pallectrum/electrum/scripts/get_history.py

34 lines
785 B
Python
Raw Normal View History

2017-09-05 15:27:08 +02:00
#!/usr/bin/env python3
2012-06-14 21:11:37 +02:00
import sys
2018-11-02 20:14:59 +01:00
import asyncio
2017-11-29 10:12:47 +01:00
from electrum import bitcoin
2018-11-02 20:14:59 +01:00
from electrum.network import Network
from electrum.util import json_encode, print_msg, create_and_start_event_loop, log_exceptions
from electrum.simple_config import SimpleConfig
2018-11-02 20:14:59 +01:00
2012-06-14 21:11:37 +02:00
try:
addr = sys.argv[1]
2013-11-10 12:30:57 -08:00
except Exception:
2017-09-05 15:27:08 +02:00
print("usage: get_history <bitcoin_address>")
2012-06-14 21:11:37 +02:00
sys.exit(1)
config = SimpleConfig()
2018-11-02 20:14:59 +01:00
loop, stopping_fut, loop_thread = create_and_start_event_loop()
network = Network(config)
2018-11-02 20:14:59 +01:00
network.start()
@log_exceptions
async def f():
try:
sh = bitcoin.address_to_scripthash(addr)
hist = await network.get_history_for_scripthash(sh)
print_msg(json_encode(hist))
finally:
stopping_fut.set_result(1)
asyncio.run_coroutine_threadsafe(f(), loop)