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)
async def iterate_keys_of_num(self, num): res = [] key = network.keys.private(secret_exponent=num) public_pair = getattr(key, "public_pair", lambda: None)() if not public_pair: return scripthashes = [] for k, v, text in network.output_for_public_pair(public_pair): if k not in ('address', 'address_uncompressed', 'address_segwit', 'p2sh_segwit'): continue try: sh = address_to_scripthash(v) scripthashes.append(sh) except Exception as e: logger.error(e) continue for scripthash in scripthashes: try: await self.get_bitcoin_balance(scripthash, num) except Exception as e: logger.error('e: %s %s: %s' % (e, num, scripthash))
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)
def test_address_to_scripthash(self): for priv_details in self.priv_pub_addr: sh = address_to_scripthash(priv_details['address']) self.assertEqual(priv_details['scripthash'], sh)
def test_address_to_scripthash(self): for priv_details in self.priv_pub_addr: sh = address_to_scripthash(priv_details['address']) self.assertEqual(priv_details['scripthash'], sh)
#!/usr/bin/env python3 import sys from .. import Network from electrum.util import json_encode, print_msg from electrum import bitcoin try: addr = sys.argv[1] except Exception: print("usage: get_history <bitcoin_address>") sys.exit(1) n = Network() n.start() _hash = bitcoin.address_to_scripthash(addr) h = n.get_history_for_scripthash(_hash) print_msg(json_encode(h))
#!/usr/bin/env python3 import sys import time from electrum import bitcoin from .. import SimpleConfig, Network from electrum.util import print_msg, json_encode try: addr = sys.argv[1] except Exception: print("usage: watch_address <bitcoin_address>") sys.exit(1) sh = bitcoin.address_to_scripthash(addr) # start network c = SimpleConfig() network = Network(c) network.start() # 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) # 2. send the subscription callback = lambda response: print_msg(json_encode(response.get('result')))